Compare commits
8
Commits
v8.0.8
...
ocisdev-855
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7f9cac8ce | ||
|
|
01b441f639 | ||
|
|
dbfd742112 | ||
|
|
8cc1953d55 | ||
|
|
ad3b71e0d7 | ||
|
|
aca3df1078 | ||
|
|
686aa52fe7 | ||
|
|
db40ce2a02 |
No files matched your search
@@ -0,0 +1,13 @@
|
||||
Bugfix: Remove the unmarshalable request body field from graph log messages
|
||||
|
||||
We've removed the `body` field from the log messages of the graph service's HTTP
|
||||
handlers. The field was set from `http.Request.Body`, an `io.ReadCloser`, which
|
||||
can never be serialized into a useful log value.
|
||||
|
||||
The tracing middleware replaces the request body with a wrapper that carries an
|
||||
exported function field, so serializing it failed outright and the log line was
|
||||
emitted with `"body": "marshaling error: json: unsupported type: func(int64)"`
|
||||
instead of the payload. Without the tracing middleware the field serialized to an
|
||||
empty object. In both cases the intended payload was never logged.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12918
|
||||
@@ -0,0 +1,28 @@
|
||||
Bugfix: Release the quota of upload sessions with unreadable node metadata
|
||||
|
||||
When an upload's target node lost its metadata, e.g. because an ancestor was
|
||||
moved to the trash while the upload was still in flight, the upload could never
|
||||
finish processing. It stayed in "Processing" forever, could not be downloaded or
|
||||
deleted, and kept consuming the space quota.
|
||||
|
||||
Cleaning such a session up with `ocis storage-users uploads sessions --clean`
|
||||
did not help either: it removed the uploaded bytes and the session info file
|
||||
before failing to revert the node, so it destroyed the only copy of the data
|
||||
without releasing any quota.
|
||||
|
||||
Cleanup now reverts the node before removing anything irreversible and falls
|
||||
back to the session metadata when the node cannot be read, so the quota is
|
||||
released and the orphaned node is removed. If the quota cannot be released the
|
||||
upload is kept so it can be retried instead of being lost.
|
||||
|
||||
A new `--orphaned` filter lists the affected sessions:
|
||||
|
||||
```
|
||||
ocis storage-users uploads sessions --orphaned
|
||||
ocis storage-users uploads sessions --orphaned --clean
|
||||
```
|
||||
|
||||
Note that evaluating the filter reads the node metadata of every session, so it
|
||||
is only done when the flag is set.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12739
|
||||
@@ -0,0 +1,25 @@
|
||||
Bugfix: Keep shares visible in sharedWithMe when a resource cannot be statted
|
||||
|
||||
The graph `sharedWithMe` handler resolves each received share by fanning out a per-resource
|
||||
`Stat` call with a concurrency limit, all sharing the request context. When a `Stat` failed
|
||||
for any reason (slow or stuck downstream, deleted space, gateway error, deadline exceeded)
|
||||
the worker logged at debug and returned without emitting a drive item, so the share was
|
||||
silently omitted from the response and the handler still returned `200 OK` with a partial,
|
||||
non-deterministic list. A single chronically-slow share could therefore make other,
|
||||
recently-accepted shares intermittently invisible, and repeated calls returned different
|
||||
subsets of the user's shares.
|
||||
|
||||
The handler now:
|
||||
|
||||
- bounds each per-share `Stat` with its own timeout derived from the request context, so one
|
||||
slow resource can no longer consume the deadline shared by all the other shares. The bound
|
||||
is configurable via `GRAPH_RECEIVED_SHARES_STAT_TIMEOUT` (default `10s`);
|
||||
- returns a degraded drive item built from the data already present in the share record
|
||||
(ids, permissions, grantees, timestamps, mountpoint name) when the resource cannot be statted
|
||||
due to a transient or indeterminate failure (timeout, slow or unavailable downstream), so the
|
||||
share stays visible instead of intermittently disappearing. A genuinely missing resource or
|
||||
revoked access (for example after the sharer was deleted) still drops the share, as before;
|
||||
- logs the dropped/degraded shares at warning level with a per-request count for operator
|
||||
visibility.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12430
|
||||
@@ -0,0 +1,10 @@
|
||||
Enhancement: Add TLS support for the frontend stat cache store connection
|
||||
|
||||
The frontend service was the only remaining place where a `nats-js-kv` store
|
||||
connection could not be secured. Its OCS stat cache forwarded the store type,
|
||||
nodes, database, table, TTL and credentials to reva, but not the TLS settings,
|
||||
so the connection stayed plaintext with no operator toggle to change it. The
|
||||
stat cache now honours `OCIS_CACHE_ENABLE_TLS`, `OCIS_CACHE_TLS_INSECURE` and
|
||||
`OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE` like every other cache and store.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12777
|
||||
@@ -0,0 +1,6 @@
|
||||
Bugfix: Correct introduction version for OCIS_LDAP_INSTANCE_MAPPER_CACHE_TTL
|
||||
|
||||
We changed the documented introduction version of the
|
||||
OCIS_LDAP_INSTANCE_MAPPER_CACHE_TTL from 8.0.0 to 8.3.0.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12949
|
||||
@@ -65,7 +65,7 @@ require (
|
||||
github.com/open-policy-agent/opa v1.19.0
|
||||
github.com/orcaman/concurrent-map v1.0.0
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260813081353-3dbd3c2711ea
|
||||
github.com/owncloud/reva/v2 v2.0.0-20261001074810-94c6e48f5c45
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/pkg/xattr v0.4.12
|
||||
github.com/prometheus/client_golang v1.24.1
|
||||
@@ -104,7 +104,7 @@ require (
|
||||
golang.org/x/term v0.45.0
|
||||
golang.org/x/text v0.41.0
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260803160001-6ac0973c030d
|
||||
google.golang.org/grpc v1.83.1
|
||||
google.golang.org/grpc v1.83.2
|
||||
google.golang.org/protobuf v1.36.12
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
gotest.tools/v3 v3.5.2
|
||||
|
||||
@@ -735,8 +735,8 @@ github.com/orcaman/concurrent-map v1.0.0 h1:I/2A2XPCb4IuQWcQhBhSwGfiuybl/J0ev9HD
|
||||
github.com/orcaman/concurrent-map v1.0.0/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245 h1:JRidLTAKhnvyLMRtVtSF4lhBa0NSAOs6fof+d6JnKII=
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245/go.mod h1:z61VMGAJRtR1nbgXWiNoCkxUXP1B3Je9rMuJbnGd+Og=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260813081353-3dbd3c2711ea h1:68rl8e2cYHE46s+PFJRpp0IP4VLyqAILQE8GD9F2FjE=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260813081353-3dbd3c2711ea/go.mod h1:LSXqMWTC7Ya6uxmqp1ksrWYZXBuZ6PhcmVimxyG8U5o=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20261001074810-94c6e48f5c45 h1://i0KWRVB8U7vN3mrc+z1c3U/j0vpw/tcrdD5RuKJvQ=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20261001074810-94c6e48f5c45/go.mod h1:LSXqMWTC7Ya6uxmqp1ksrWYZXBuZ6PhcmVimxyG8U5o=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
|
||||
github.com/pablodz/inotifywaitgo v0.0.12 h1:DVJJTFMDlSAdO46yisPF2vzozs/r+4k6ih8MVghq78M=
|
||||
@@ -1342,8 +1342,8 @@ google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3Iji
|
||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||
google.golang.org/grpc v1.83.1 h1:HIO0+BEtBP6soyqvqC8sNUjZ7bTs+0hFQuFF+RAy++Y=
|
||||
google.golang.org/grpc v1.83.1/go.mod h1:kDyl6SKsiHKt0uylY5gtn5cEjkrIOhQOGDgIc4JGwzQ=
|
||||
google.golang.org/grpc v1.83.2 h1:EManeRomTObA0BU7I8vXgg/78uE5MJ9M8B39EX2WscU=
|
||||
google.golang.org/grpc v1.83.2/go.mod h1:YPI1hK3kDked6iHvgX3tR0y+nX/qpMFKhPgFsokw1S8=
|
||||
google.golang.org/grpc/examples v0.0.0-20211102180624-670c133e568e h1:m7aQHHqd0q89mRwhwS9Bx2rjyl/hsFAeta+uGrHsQaU=
|
||||
google.golang.org/grpc/examples v0.0.0-20211102180624-670c133e568e/go.mod h1:gID3PKrg7pWKntu9Ss6zTLJ0ttC0X9IHgREOCZwbCVU=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
|
||||
@@ -131,18 +131,21 @@ type DataGateway struct {
|
||||
}
|
||||
|
||||
type OCS struct {
|
||||
Prefix string `yaml:"prefix" desc:"URL path prefix for the OCS service. Note that the string must not start with '/'." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The OCS API is deprecated" deprecationReplacement:""`
|
||||
SharePrefix string `yaml:"share_prefix" desc:"Path prefix for shares as part of an ocis resource. Note that the path must start with '/'." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The OCS API is deprecated" deprecationReplacement:""`
|
||||
HomeNamespace string `yaml:"home_namespace" desc:"Home namespace identifier." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The OCS API is deprecated" deprecationReplacement:""`
|
||||
AdditionalInfoAttribute string `yaml:"additional_info_attribute" desc:"Additional information attribute for the user like {{.Mail}}." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheType string `yaml:"stat_cache_type" env:"OCIS_CACHE_STORE" desc:"The type of the cache store. Supported values are: 'memory', 'redis-sentinel', 'nats-js-kv', 'noop'. See the text description for details." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_STORE in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheNodes []string `yaml:"stat_cache_nodes" env:"OCIS_CACHE_STORE_NODES" desc:"A list of nodes to access the configured store. This has no effect when 'memory' store is configured. Note that the behaviour how nodes are used is dependent on the library of the configured store. See the Environment Variable Types description for more details." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_STORE_NODES in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheDatabase string `yaml:"stat_cache_database" env:"OCIS_CACHE_DATABASE" desc:"The database name the configured store should use." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_DATABASE in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheTable string `yaml:"stat_cache_table" desc:"The database table the store should use." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheTTL time.Duration `yaml:"stat_cache_ttl" env:"OCIS_CACHE_TTL" desc:"Default time to live for user info in the cache. Only applied when access tokens has no expiration. See the Environment Variable Types description for more details." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_TTL in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheDisablePersistence bool `yaml:"stat_cache_disable_persistence" env:"OCIS_CACHE_DISABLE_PERSISTENCE" desc:"Disable persistence of the cache. Only applies when using the 'nats-js-kv' store type. Defaults to false." introductionVersion:"5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_DISABLE_PERSISTENCE in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheAuthUsername string `yaml:"stat_cache_auth_username" env:"OCIS_CACHE_AUTH_USERNAME" desc:"The username to use for authentication. Only applies when using the 'nats-js-kv' store type." introductionVersion:"5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_AUTH_USERNAME in the frontend service is deprecated because the OCS API is deprecated OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheAuthPassword string `yaml:"stat_cache_auth_password" env:"OCIS_CACHE_AUTH_PASSWORD" desc:"The password to use for authentication. Only applies when using the 'nats-js-kv' store type." introductionVersion:"5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_AUTH_PASSWORD in the frontend service is deprecated because the OCS API is deprecated OCS API is deprecated" deprecationReplacement:""`
|
||||
Prefix string `yaml:"prefix" desc:"URL path prefix for the OCS service. Note that the string must not start with '/'." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The OCS API is deprecated" deprecationReplacement:""`
|
||||
SharePrefix string `yaml:"share_prefix" desc:"Path prefix for shares as part of an ocis resource. Note that the path must start with '/'." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The OCS API is deprecated" deprecationReplacement:""`
|
||||
HomeNamespace string `yaml:"home_namespace" desc:"Home namespace identifier." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The OCS API is deprecated" deprecationReplacement:""`
|
||||
AdditionalInfoAttribute string `yaml:"additional_info_attribute" desc:"Additional information attribute for the user like {{.Mail}}." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheType string `yaml:"stat_cache_type" env:"OCIS_CACHE_STORE" desc:"The type of the cache store. Supported values are: 'memory', 'redis-sentinel', 'nats-js-kv', 'noop'. See the text description for details." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_STORE in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheNodes []string `yaml:"stat_cache_nodes" env:"OCIS_CACHE_STORE_NODES" desc:"A list of nodes to access the configured store. This has no effect when 'memory' store is configured. Note that the behaviour how nodes are used is dependent on the library of the configured store. See the Environment Variable Types description for more details." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_STORE_NODES in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheDatabase string `yaml:"stat_cache_database" env:"OCIS_CACHE_DATABASE" desc:"The database name the configured store should use." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_DATABASE in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheTable string `yaml:"stat_cache_table" desc:"The database table the store should use." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheTTL time.Duration `yaml:"stat_cache_ttl" env:"OCIS_CACHE_TTL" desc:"Default time to live for user info in the cache. Only applied when access tokens has no expiration. See the Environment Variable Types description for more details." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_TTL in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheDisablePersistence bool `yaml:"stat_cache_disable_persistence" env:"OCIS_CACHE_DISABLE_PERSISTENCE" desc:"Disable persistence of the cache. Only applies when using the 'nats-js-kv' store type. Defaults to false." introductionVersion:"5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_DISABLE_PERSISTENCE in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheAuthUsername string `yaml:"stat_cache_auth_username" env:"OCIS_CACHE_AUTH_USERNAME" desc:"The username to use for authentication. Only applies when using the 'nats-js-kv' store type." introductionVersion:"5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_AUTH_USERNAME in the frontend service is deprecated because the OCS API is deprecated OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheAuthPassword string `yaml:"stat_cache_auth_password" env:"OCIS_CACHE_AUTH_PASSWORD" desc:"The password to use for authentication. Only applies when using the 'nats-js-kv' store type." introductionVersion:"5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_AUTH_PASSWORD in the frontend service is deprecated because the OCS API is deprecated OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheEnableTLS bool `yaml:"stat_cache_enable_tls" env:"OCIS_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the stat cache store. Only applies when using the 'nats-js-kv' store type." introductionVersion:"8.3.0"`
|
||||
StatCacheTLSInsecure bool `yaml:"stat_cache_tls_insecure" env:"OCIS_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the stat cache store connection. Only applies when using the 'nats-js-kv' store type." introductionVersion:"8.3.0"`
|
||||
StatCacheTLSRootCACertificate string `yaml:"stat_cache_tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the stat cache store TLS connection. Only applies when using the 'nats-js-kv' store type." introductionVersion:"8.3.0"`
|
||||
|
||||
CacheWarmupDriver string `yaml:"cache_warmup_driver,omitempty"` // not supported by the oCIS product, therefore not part of docs
|
||||
CacheWarmupDrivers CacheWarmupDrivers `yaml:"cache_warmup_drivers,omitempty"` // not supported by the oCIS product, therefore not part of docs
|
||||
|
||||
@@ -163,14 +163,17 @@ func FrontendConfigFromStruct(cfg *config.Config, logger log.Logger) (map[string
|
||||
"share_prefix": cfg.OCS.SharePrefix,
|
||||
"home_namespace": cfg.OCS.HomeNamespace,
|
||||
"stat_cache_config": map[string]interface{}{
|
||||
"cache_store": cfg.OCS.StatCacheType,
|
||||
"cache_nodes": cfg.OCS.StatCacheNodes,
|
||||
"cache_database": cfg.OCS.StatCacheDatabase,
|
||||
"cache_table": cfg.OCS.StatCacheTable,
|
||||
"cache_ttl": cfg.OCS.StatCacheTTL,
|
||||
"cache_disable_persistence": cfg.OCS.StatCacheDisablePersistence,
|
||||
"cache_auth_username": cfg.OCS.StatCacheAuthUsername,
|
||||
"cache_auth_password": cfg.OCS.StatCacheAuthPassword,
|
||||
"cache_store": cfg.OCS.StatCacheType,
|
||||
"cache_nodes": cfg.OCS.StatCacheNodes,
|
||||
"cache_database": cfg.OCS.StatCacheDatabase,
|
||||
"cache_table": cfg.OCS.StatCacheTable,
|
||||
"cache_ttl": cfg.OCS.StatCacheTTL,
|
||||
"cache_disable_persistence": cfg.OCS.StatCacheDisablePersistence,
|
||||
"cache_auth_username": cfg.OCS.StatCacheAuthUsername,
|
||||
"cache_auth_password": cfg.OCS.StatCacheAuthPassword,
|
||||
"cache_enable_tls": cfg.OCS.StatCacheEnableTLS,
|
||||
"cache_tls_insecure": cfg.OCS.StatCacheTLSInsecure,
|
||||
"cache_tls_root_ca_certificate": cfg.OCS.StatCacheTLSRootCACertificate,
|
||||
},
|
||||
"prefix": cfg.OCS.Prefix,
|
||||
"additional_info_attribute": func() string {
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package revaconfig
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/config/envdecode"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/v2/services/frontend/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func TestStatCacheTLSPlumbing(t *testing.T) {
|
||||
t.Setenv("OCIS_CACHE_ENABLE_TLS", "true")
|
||||
t.Setenv("OCIS_CACHE_TLS_INSECURE", "true")
|
||||
t.Setenv("OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE", "/etc/ocis/ca.crt")
|
||||
|
||||
cfg := defaults.FullDefaultConfig()
|
||||
if err := envdecode.Decode(cfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
revaCfg, err := FrontendConfigFromStruct(cfg, log.NopLogger())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
statCache := revaCfg["http"].(map[string]interface{})["services"].(map[string]interface{})["ocs"].(map[string]interface{})["stat_cache_config"].(map[string]interface{})
|
||||
t.Logf("cache_enable_tls=%v cache_tls_insecure=%v cache_tls_root_ca_certificate=%v",
|
||||
statCache["cache_enable_tls"], statCache["cache_tls_insecure"], statCache["cache_tls_root_ca_certificate"])
|
||||
|
||||
if statCache["cache_enable_tls"] != true {
|
||||
t.Errorf("cache_enable_tls = %v, want true", statCache["cache_enable_tls"])
|
||||
}
|
||||
if statCache["cache_tls_insecure"] != true {
|
||||
t.Errorf("cache_tls_insecure = %v, want true", statCache["cache_tls_insecure"])
|
||||
}
|
||||
if statCache["cache_tls_root_ca_certificate"] != "/etc/ocis/ca.crt" {
|
||||
t.Errorf("cache_tls_root_ca_certificate = %v, want /etc/ocis/ca.crt", statCache["cache_tls_root_ca_certificate"])
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,8 @@ type Config struct {
|
||||
UnifiedRoles UnifiedRoles `yaml:"unified_roles"`
|
||||
MaxConcurrency int `yaml:"max_concurrency" env:"OCIS_MAX_CONCURRENCY;GRAPH_MAX_CONCURRENCY" desc:"The maximum number of concurrent requests the service will handle." introductionVersion:"7.0.0"`
|
||||
|
||||
ReceivedSharesStatTimeout time.Duration `yaml:"received_shares_stat_timeout" env:"GRAPH_RECEIVED_SHARES_STAT_TIMEOUT" desc:"The maximum duration to wait for the storage to respond while resolving a single received share's resource when listing 'sharedWithMe'. Bounding each resource lookup individually prevents one slow or unreachable resource from consuming the request deadline shared by all the other shares. A share whose resource cannot be statted within this time is still listed as a degraded item instead of being dropped. Defaults to '10s'. See the Environment Variable Types description for more details." introductionVersion:"8.2.0"`
|
||||
|
||||
Keycloak Keycloak `yaml:"keycloak"`
|
||||
ServiceAccount ServiceAccount `yaml:"service_account"`
|
||||
MultiInstance MultiInstanceConfig `yaml:"multi_instance"`
|
||||
@@ -115,7 +117,7 @@ type LDAP struct {
|
||||
InstanceMapperIDAttribute string `yaml:"instance_mapper_id_attribute" env:"OCIS_LDAP_INSTANCE_MAPPER_ID_ATTRIBUTE" desc:"LDAP Attribute of the instance ID. Requires OCIS_MULTI_INSTANCE_ENABLED." introductionVersion:"8.0.0"`
|
||||
CrossInstanceReferenceTemplate string `yaml:"cross_instance_reference_template" env:"OCIS_LDAP_CROSS_INSTANCE_REFERENCE_TEMPLATE" desc:"Template for the users unique reference across oCIS instances. Requires OCIS_MULTI_INSTANCE_ENABLED." introductionVersion:"8.0.0"`
|
||||
InstanceURLTemplate string `yaml:"instance_url_template" env:"OCIS_LDAP_INSTANCE_URL_TEMPLATE" desc:"Template for the instance URL. Requires OCIS_MULTI_INSTANCE_ENABLED." introductionVersion:"8.0.0"`
|
||||
InstanceMapperCacheTTL int `yaml:"instance_mapper_cache_ttl" env:"OCIS_LDAP_INSTANCE_MAPPER_CACHE_TTL" desc:"Max TTL in seconds for the LDAP instance mapper cache. Requires OCIS_MULTI_INSTANCE_ENABLED." introductionVersion:"8.0.0"`
|
||||
InstanceMapperCacheTTL int `yaml:"instance_mapper_cache_ttl" env:"OCIS_LDAP_INSTANCE_MAPPER_CACHE_TTL" desc:"Max TTL in seconds for the LDAP instance mapper cache. Requires OCIS_MULTI_INSTANCE_ENABLED." introductionVersion:"8.3.0"`
|
||||
}
|
||||
|
||||
// LDAPEducationConfig represents the LDAP configuration for education related resources
|
||||
|
||||
@@ -133,7 +133,8 @@ func DefaultConfig() *config.Config {
|
||||
Cluster: "ocis-cluster",
|
||||
EnableTLS: false,
|
||||
},
|
||||
MaxConcurrency: 20,
|
||||
MaxConcurrency: 20,
|
||||
ReceivedSharesStatTimeout: 10 * time.Second,
|
||||
UnifiedRoles: config.UnifiedRoles{
|
||||
AvailableRoles: nil, // will be populated with defaults in EnsureDefaults
|
||||
},
|
||||
|
||||
@@ -167,7 +167,7 @@ func (api DriveItemPermissionsApi) CreateLink(w http.ResponseWriter, r *http.Req
|
||||
|
||||
var createLink libregraph.DriveItemCreateLink
|
||||
if err = StrictJSONUnmarshal(r.Body, &createLink); err != nil {
|
||||
logger.Error().Err(err).Interface("body", r.Body).Msg("could not create link: invalid body schema definition")
|
||||
logger.Error().Err(err).Msg("could not create link: invalid body schema definition")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "invalid body schema definition")
|
||||
return
|
||||
}
|
||||
@@ -196,7 +196,7 @@ func (api DriveItemPermissionsApi) CreateSpaceRootLink(w http.ResponseWriter, r
|
||||
|
||||
var createLink libregraph.DriveItemCreateLink
|
||||
if err = StrictJSONUnmarshal(r.Body, &createLink); err != nil {
|
||||
logger.Error().Err(err).Interface("body", r.Body).Msg("could not create link: invalid body schema definition")
|
||||
logger.Error().Err(err).Msg("could not create link: invalid body schema definition")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "invalid body schema definition")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ func (g Graph) CreateAppRoleAssignment(w http.ResponseWriter, r *http.Request) {
|
||||
// DeleteAppRoleAssignment implements the Service interface.
|
||||
func (g Graph) DeleteAppRoleAssignment(w http.ResponseWriter, r *http.Request) {
|
||||
logger := g.logger.SubloggerWithRequestID(r.Context())
|
||||
logger.Info().Interface("body", r.Body).Msg("calling delete appRoleAssignment")
|
||||
logger.Info().Msg("calling delete appRoleAssignment")
|
||||
|
||||
userID := chi.URLParam(r, "userID")
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ func (g BaseGraphService) CS3ReceivedSharesToDriveItems(ctx context.Context, rec
|
||||
}
|
||||
|
||||
availableRoles := unifiedrole.GetRoles(unifiedrole.RoleFilterIDs(g.config.UnifiedRoles.AvailableRoles...))
|
||||
return cs3ReceivedSharesToDriveItems(ctx, g.logger, gatewayClient, g.identityCache, receivedShares, availableRoles)
|
||||
return cs3ReceivedSharesToDriveItems(ctx, g.logger, gatewayClient, g.identityCache, receivedShares, availableRoles, g.config.ReceivedSharesStatTimeout)
|
||||
}
|
||||
|
||||
func (g BaseGraphService) CS3ReceivedOCMSharesToDriveItems(ctx context.Context, receivedShares []*ocm.ReceivedShare) ([]libregraph.DriveItem, error) {
|
||||
|
||||
@@ -391,7 +391,7 @@ func (g Graph) createDrive(w http.ResponseWriter, r *http.Request, apiVersion AP
|
||||
|
||||
drive := libregraph.Drive{}
|
||||
if err := StrictJSONUnmarshal(r.Body, &drive); err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not create drive: invalid body schema definition")
|
||||
logger.Debug().Err(err).Msg("could not create drive: invalid body schema definition")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "invalid body schema definition")
|
||||
return
|
||||
}
|
||||
@@ -524,7 +524,7 @@ func (g Graph) updateDrive(w http.ResponseWriter, r *http.Request, apiVersion AP
|
||||
|
||||
drive := libregraph.DriveUpdate{}
|
||||
if err = StrictJSONUnmarshal(r.Body, &drive); err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not update drive, invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not update drive, invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: error: %v", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func (g Graph) PostEducationClass(w http.ResponseWriter, r *http.Request) {
|
||||
class := libregraph.NewEducationClassWithDefaults()
|
||||
err := StrictJSONUnmarshal(r.Body, class)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not create education class: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not create education class: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
@@ -110,7 +110,7 @@ func (g Graph) PatchEducationClass(w http.ResponseWriter, r *http.Request) {
|
||||
changes := libregraph.NewEducationClassWithDefaults()
|
||||
err = StrictJSONUnmarshal(r.Body, changes)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not change class: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not change class: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
@@ -315,10 +315,7 @@ func (g Graph) PostEducationClassMember(w http.ResponseWriter, r *http.Request)
|
||||
memberRef := libregraph.NewMemberReference()
|
||||
err = StrictJSONUnmarshal(r.Body, memberRef)
|
||||
if err != nil {
|
||||
logger.Debug().
|
||||
Err(err).
|
||||
Interface("body", r.Body).
|
||||
Msg("could not add class member: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not add class member: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
@@ -461,10 +458,7 @@ func (g Graph) PostEducationClassTeacher(w http.ResponseWriter, r *http.Request)
|
||||
memberRef := libregraph.NewMemberReference()
|
||||
err = StrictJSONUnmarshal(r.Body, memberRef)
|
||||
if err != nil {
|
||||
logger.Debug().
|
||||
Err(err).
|
||||
Interface("body", r.Body).
|
||||
Msg("could not add class teacher: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not add class teacher: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func (g Graph) PostEducationSchool(w http.ResponseWriter, r *http.Request) {
|
||||
school := libregraph.NewEducationSchool()
|
||||
err := StrictJSONUnmarshal(r.Body, school)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not create school: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not create school: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
@@ -131,7 +131,7 @@ func (g Graph) PatchEducationSchool(w http.ResponseWriter, r *http.Request) {
|
||||
school := libregraph.NewEducationSchool()
|
||||
err = StrictJSONUnmarshal(r.Body, school)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not update school: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not update school: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
@@ -330,10 +330,7 @@ func (g Graph) PostEducationSchoolUser(w http.ResponseWriter, r *http.Request) {
|
||||
memberRef := libregraph.NewMemberReference()
|
||||
err = StrictJSONUnmarshal(r.Body, memberRef)
|
||||
if err != nil {
|
||||
logger.Debug().
|
||||
Err(err).
|
||||
Interface("body", r.Body).
|
||||
Msg("could not add school user: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not add school user: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
@@ -485,10 +482,7 @@ func (g Graph) PostEducationSchoolClass(w http.ResponseWriter, r *http.Request)
|
||||
memberRef := libregraph.NewMemberReference()
|
||||
err = StrictJSONUnmarshal(r.Body, memberRef)
|
||||
if err != nil {
|
||||
logger.Debug().
|
||||
Err(err).
|
||||
Interface("body", r.Body).
|
||||
Msg("could not add school class: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not add school class: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -52,11 +52,11 @@ func (g Graph) GetEducationUsers(w http.ResponseWriter, r *http.Request) {
|
||||
// PostEducationUser implements the Service interface.
|
||||
func (g Graph) PostEducationUser(w http.ResponseWriter, r *http.Request) {
|
||||
logger := g.logger.SubloggerWithRequestID(r.Context())
|
||||
logger.Info().Interface("body", r.Body).Msg("calling create education user")
|
||||
logger.Info().Msg("calling create education user")
|
||||
u := libregraph.NewEducationUser()
|
||||
err := StrictJSONUnmarshal(r.Body, u)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not create education user: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not create education user: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %v", err.Error()))
|
||||
return
|
||||
}
|
||||
@@ -321,7 +321,7 @@ func (g Graph) PatchEducationUser(w http.ResponseWriter, r *http.Request) {
|
||||
changes := libregraph.NewEducationUser()
|
||||
err = StrictJSONUnmarshal(r.Body, changes)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not update education user: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not update education user: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest,
|
||||
fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
|
||||
@@ -99,7 +99,7 @@ func (g Graph) PostGroup(w http.ResponseWriter, r *http.Request) {
|
||||
grp := libregraph.NewGroup()
|
||||
err := StrictJSONUnmarshal(r.Body, grp)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not create group: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not create group: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
@@ -164,13 +164,13 @@ func (g Graph) PatchGroup(w http.ResponseWriter, r *http.Request) {
|
||||
changes := libregraph.NewGroup()
|
||||
err = StrictJSONUnmarshal(r.Body, changes)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not change group: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not change group: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if reflect.ValueOf(*changes).IsZero() {
|
||||
logger.Debug().Interface("body", r.Body).Msg("ignoring empyt request body")
|
||||
logger.Debug().Msg("ignoring empyt request body")
|
||||
render.Status(r, http.StatusNoContent)
|
||||
render.NoContent(w, r)
|
||||
return
|
||||
@@ -366,10 +366,7 @@ func (g Graph) PostGroupMember(w http.ResponseWriter, r *http.Request) {
|
||||
memberRef := libregraph.NewMemberReference()
|
||||
err = StrictJSONUnmarshal(r.Body, memberRef)
|
||||
if err != nil {
|
||||
logger.Debug().
|
||||
Err(err).
|
||||
Interface("body", r.Body).
|
||||
Msg("could not add group member: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not add group member: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func (g Graph) listSharedWithMe(ctx context.Context) ([]libregraph.DriveItem, er
|
||||
return nil, err
|
||||
}
|
||||
availableRoles := unifiedrole.GetRoles(unifiedrole.RoleFilterIDs(g.config.UnifiedRoles.AvailableRoles...))
|
||||
driveItems, err := cs3ReceivedSharesToDriveItems(ctx, g.logger, gatewayClient, g.identityCache, listReceivedSharesResponse.GetShares(), availableRoles)
|
||||
driveItems, err := cs3ReceivedSharesToDriveItems(ctx, g.logger, gatewayClient, g.identityCache, listReceivedSharesResponse.GetShares(), availableRoles, g.config.ReceivedSharesStatTimeout)
|
||||
if err != nil {
|
||||
g.logger.Error().Err(err).Msg("could not convert received shares to drive items")
|
||||
return nil, err
|
||||
|
||||
@@ -376,6 +376,157 @@ var _ = Describe("SharedWithMe", func() {
|
||||
Expect(jsonData.Get("id").String()).To(Equal(getUserResponseShareCreator.User.Id.OpaqueId))
|
||||
})
|
||||
|
||||
It("returns a degraded drive item when a share's resource stat times out", func() {
|
||||
// a second share, pointing at a different resource, whose Stat times out (transport error)
|
||||
brokenShare := &collaborationv1beta1.ReceivedShare{
|
||||
Share: &collaborationv1beta1.Share{
|
||||
ResourceId: toResourceID("7$8!9"),
|
||||
Id: &collaborationv1beta1.ShareId{
|
||||
OpaqueId: "broken:share:id",
|
||||
},
|
||||
Permissions: &collaborationv1beta1.SharePermissions{
|
||||
Permissions: roleconversions.NewViewerRole().CS3ResourcePermissions(),
|
||||
},
|
||||
Creator: getUserResponseShareCreator.User.Id,
|
||||
Ctime: utils.TSNow(),
|
||||
},
|
||||
MountPoint: &providerv1beta1.Reference{Path: "broken folder"},
|
||||
State: collaborationv1beta1.ShareState_SHARE_STATE_ACCEPTED,
|
||||
}
|
||||
listReceivedSharesResponse.Shares = append(listReceivedSharesResponse.Shares, brokenShare)
|
||||
|
||||
// reset and re-register the gateway expectations so Stat fails for the
|
||||
// broken share's resource but succeeds for the others.
|
||||
gatewayClient.ExpectedCalls = nil
|
||||
gatewayClient.On("GetUser", mock.Anything, mock.Anything).Return(getUserResponseDefault, nil)
|
||||
gatewayClient.On("ListReceivedShares", mock.Anything, mock.Anything).Return(listReceivedSharesResponse, nil)
|
||||
gatewayClient.On("Stat", mock.Anything, mock.Anything).Return(func(_ context.Context, r *providerv1beta1.StatRequest, _ ...grpc.CallOption) (*providerv1beta1.StatResponse, error) {
|
||||
if r.Ref.ResourceId == brokenShare.Share.ResourceId {
|
||||
return nil, context.DeadlineExceeded
|
||||
}
|
||||
return &providerv1beta1.StatResponse{
|
||||
Status: status.NewOK(ctx),
|
||||
Info: &providerv1beta1.ResourceInfo{
|
||||
Id: r.Ref.ResourceId,
|
||||
Type: providerv1beta1.ResourceType_RESOURCE_TYPE_CONTAINER,
|
||||
},
|
||||
}, nil
|
||||
})
|
||||
|
||||
svc.ListSharedWithMe(
|
||||
tape,
|
||||
httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe", nil),
|
||||
)
|
||||
|
||||
driveItems := libregraph.CollectionOfDriveItems{}
|
||||
err := json.Unmarshal(tape.Body.Bytes(), &driveItems)
|
||||
Expect(err).To(BeNil())
|
||||
|
||||
// both shares must be present: the broken one is returned as a degraded
|
||||
// item built from the share record, not silently dropped.
|
||||
Expect(len(driveItems.Value)).To(Equal(2))
|
||||
|
||||
var remoteIDs []string
|
||||
for _, di := range driveItems.GetValue() {
|
||||
ri := di.GetRemoteItem()
|
||||
remoteIDs = append(remoteIDs, ri.GetId())
|
||||
}
|
||||
Expect(remoteIDs).To(ContainElement(storagespace.FormatResourceID(brokenShare.Share.ResourceId)))
|
||||
})
|
||||
|
||||
It("bounds the per-share Stat with the configured GRAPH_RECEIVED_SHARES_STAT_TIMEOUT", func() {
|
||||
// Use a value distinct from the 10s default so we can tell the
|
||||
// configured timeout (not the default) is the one applied. The service
|
||||
// holds cfg by pointer, so setting it here is observed by the handler.
|
||||
cfg.ReceivedSharesStatTimeout = 3 * time.Second
|
||||
|
||||
var statDeadline time.Time
|
||||
var statHadDeadline bool
|
||||
gatewayClient.ExpectedCalls = nil
|
||||
gatewayClient.On("GetUser", mock.Anything, mock.Anything).Return(getUserResponseDefault, nil)
|
||||
gatewayClient.On("ListReceivedShares", mock.Anything, mock.Anything).Return(listReceivedSharesResponse, nil)
|
||||
gatewayClient.On("Stat", mock.Anything, mock.Anything).Return(func(statCtx context.Context, r *providerv1beta1.StatRequest, _ ...grpc.CallOption) (*providerv1beta1.StatResponse, error) {
|
||||
// the worker writes these before returning; cs3ReceivedSharesToDriveItems
|
||||
// only returns after group.Wait(), so reading them after the handler
|
||||
// call is race-free.
|
||||
statDeadline, statHadDeadline = statCtx.Deadline()
|
||||
return &providerv1beta1.StatResponse{
|
||||
Status: status.NewOK(ctx),
|
||||
Info: &providerv1beta1.ResourceInfo{
|
||||
Id: r.Ref.ResourceId,
|
||||
Type: providerv1beta1.ResourceType_RESOURCE_TYPE_CONTAINER,
|
||||
},
|
||||
}, nil
|
||||
})
|
||||
|
||||
svc.ListSharedWithMe(
|
||||
tape,
|
||||
httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe", nil),
|
||||
)
|
||||
|
||||
Expect(tape.Code).To(Equal(http.StatusOK))
|
||||
// the per-share Stat must carry a deadline derived from the configured
|
||||
// timeout: never above the configured 3s, and clearly below the 10s default.
|
||||
Expect(statHadDeadline).To(BeTrue())
|
||||
Expect(time.Until(statDeadline)).To(BeNumerically("<=", 3*time.Second))
|
||||
Expect(time.Until(statDeadline)).To(BeNumerically(">", 2*time.Second))
|
||||
})
|
||||
|
||||
It("drops a share when the storage returns an error for its resource (e.g. the sharer was deleted)", func() {
|
||||
// a second share whose resource the storage cannot serve (definitive status error) must not be listed
|
||||
goneShare := &collaborationv1beta1.ReceivedShare{
|
||||
Share: &collaborationv1beta1.Share{
|
||||
ResourceId: toResourceID("7$8!9"),
|
||||
Id: &collaborationv1beta1.ShareId{
|
||||
OpaqueId: "gone:share:id",
|
||||
},
|
||||
Permissions: &collaborationv1beta1.SharePermissions{
|
||||
Permissions: roleconversions.NewViewerRole().CS3ResourcePermissions(),
|
||||
},
|
||||
Creator: getUserResponseShareCreator.User.Id,
|
||||
Ctime: utils.TSNow(),
|
||||
},
|
||||
MountPoint: &providerv1beta1.Reference{Path: "gone folder"},
|
||||
State: collaborationv1beta1.ShareState_SHARE_STATE_ACCEPTED,
|
||||
}
|
||||
listReceivedSharesResponse.Shares = append(listReceivedSharesResponse.Shares, goneShare)
|
||||
|
||||
gatewayClient.ExpectedCalls = nil
|
||||
gatewayClient.On("GetUser", mock.Anything, mock.Anything).Return(getUserResponseDefault, nil)
|
||||
gatewayClient.On("ListReceivedShares", mock.Anything, mock.Anything).Return(listReceivedSharesResponse, nil)
|
||||
gatewayClient.On("Stat", mock.Anything, mock.Anything).Return(func(_ context.Context, r *providerv1beta1.StatRequest, _ ...grpc.CallOption) (*providerv1beta1.StatResponse, error) {
|
||||
if r.Ref.ResourceId == goneShare.Share.ResourceId {
|
||||
return &providerv1beta1.StatResponse{Status: status.NewInternal(ctx, "node broken after sharer deletion")}, nil
|
||||
}
|
||||
return &providerv1beta1.StatResponse{
|
||||
Status: status.NewOK(ctx),
|
||||
Info: &providerv1beta1.ResourceInfo{
|
||||
Id: r.Ref.ResourceId,
|
||||
Type: providerv1beta1.ResourceType_RESOURCE_TYPE_CONTAINER,
|
||||
},
|
||||
}, nil
|
||||
})
|
||||
|
||||
svc.ListSharedWithMe(
|
||||
tape,
|
||||
httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe", nil),
|
||||
)
|
||||
|
||||
driveItems := libregraph.CollectionOfDriveItems{}
|
||||
err := json.Unmarshal(tape.Body.Bytes(), &driveItems)
|
||||
Expect(err).To(BeNil())
|
||||
|
||||
// the dead share (resource gone) is dropped; only the healthy share remains
|
||||
Expect(len(driveItems.Value)).To(Equal(1))
|
||||
|
||||
var remoteIDs []string
|
||||
for _, di := range driveItems.GetValue() {
|
||||
ri := di.GetRemoteItem()
|
||||
remoteIDs = append(remoteIDs, ri.GetId())
|
||||
}
|
||||
Expect(remoteIDs).ToNot(ContainElement(storagespace.FormatResourceID(goneShare.Share.ResourceId)))
|
||||
})
|
||||
|
||||
It("returns a single drive item when multiple shares exist for the same resource", func() {
|
||||
anotherShare := &collaborationv1beta1.ReceivedShare{
|
||||
Share: &collaborationv1beta1.Share{
|
||||
|
||||
@@ -54,7 +54,7 @@ func (g Graph) AssignTags(w http.ResponseWriter, r *http.Request) {
|
||||
)
|
||||
|
||||
if err := StrictJSONUnmarshal(r.Body, &assignment); err != nil {
|
||||
g.logger.Debug().Err(err).Interface("body", r.Body).Msg("could not decode tag assignment request")
|
||||
g.logger.Debug().Err(err).Msg("could not decode tag assignment request")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "invalid body schema definition")
|
||||
return
|
||||
}
|
||||
@@ -161,7 +161,7 @@ func (g Graph) UnassignTags(w http.ResponseWriter, r *http.Request) {
|
||||
)
|
||||
|
||||
if err := StrictJSONUnmarshal(r.Body, &unassignment); err != nil {
|
||||
g.logger.Debug().Err(err).Interface("body", r.Body).Msg("could not decode tag assignment request")
|
||||
g.logger.Debug().Err(err).Msg("could not decode tag assignment request")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "invalid body schema definition")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -861,7 +861,7 @@ func (g Graph) PatchMe(w http.ResponseWriter, r *http.Request) {
|
||||
changes := libregraph.NewUserUpdate()
|
||||
err := StrictJSONUnmarshal(r.Body, changes)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not update user: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not update user: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest,
|
||||
fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
@@ -893,7 +893,7 @@ func (g Graph) PatchUser(w http.ResponseWriter, r *http.Request) {
|
||||
changes := libregraph.NewUserUpdate()
|
||||
err = StrictJSONUnmarshal(r.Body, changes)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not update user: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not update user: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest,
|
||||
fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
@@ -934,7 +934,7 @@ func (g Graph) patchUser(w http.ResponseWriter, r *http.Request, nameOrID string
|
||||
}
|
||||
|
||||
if reflect.ValueOf(*changes).IsZero() {
|
||||
logger.Debug().Interface("body", r.Body).Msg("ignoring empty request body")
|
||||
logger.Debug().Msg("ignoring empty request body")
|
||||
render.Status(r, http.StatusNoContent)
|
||||
render.NoContent(w, r)
|
||||
return
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"net/http"
|
||||
"path"
|
||||
"reflect"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
|
||||
cs3User "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||
@@ -170,18 +172,39 @@ func identitySetToSpacePermissionID(identitySet libregraph.SharePointIdentitySet
|
||||
return id
|
||||
}
|
||||
|
||||
// _receivedShareStatTimeout is the default bound for how long the resource Stat
|
||||
// for a single received share may take. It is used when the configured
|
||||
// GRAPH_RECEIVED_SHARES_STAT_TIMEOUT is not set (or non-positive). Without a
|
||||
// per-share bound, one slow or stuck downstream resource consumes the whole
|
||||
// request deadline budget, which causes the other shares to be dropped from the
|
||||
// sharedWithMe listing (and the request to occasionally 502). Keeping it small
|
||||
// relative to a typical request deadline lets one bad share fail fast without
|
||||
// affecting the visibility of the others.
|
||||
const _receivedShareStatTimeout = 10 * time.Second
|
||||
|
||||
func cs3ReceivedSharesToDriveItems(ctx context.Context,
|
||||
logger *log.Logger,
|
||||
gatewayClient gateway.GatewayAPIClient,
|
||||
identityCache identity.IdentityCache,
|
||||
receivedShares []*collaboration.ReceivedShare,
|
||||
availableRoles []*libregraph.UnifiedRoleDefinition,
|
||||
statTimeout time.Duration,
|
||||
) ([]libregraph.DriveItem, error) {
|
||||
|
||||
// Fall back to the default when unconfigured: a non-positive timeout would
|
||||
// make context.WithTimeout cancel immediately and drop every share.
|
||||
if statTimeout <= 0 {
|
||||
statTimeout = _receivedShareStatTimeout
|
||||
}
|
||||
|
||||
group := new(errgroup.Group)
|
||||
// Set max concurrency
|
||||
group.SetLimit(10)
|
||||
|
||||
// number of shares that could not be fully resolved and were returned as a
|
||||
// degraded drive item built from the share record alone.
|
||||
var degradedShares atomic.Int64
|
||||
|
||||
receivedSharesByResourceID := make(map[string][]*collaboration.ReceivedShare, len(receivedShares))
|
||||
for _, receivedShare := range receivedShares {
|
||||
if receivedShare == nil {
|
||||
@@ -197,18 +220,39 @@ func cs3ReceivedSharesToDriveItems(ctx context.Context,
|
||||
receivedShares := receivedSharesForResource
|
||||
|
||||
group.Go(func() error {
|
||||
var err error // redeclare
|
||||
shareStat, err := gatewayClient.Stat(ctx, &storageprovider.StatRequest{
|
||||
// Bound the per-share Stat so one slow/stuck resource cannot consume
|
||||
// the request deadline shared by all the other shares.
|
||||
statCtx, cancel := context.WithTimeout(ctx, statTimeout)
|
||||
defer cancel()
|
||||
shareStat, err := gatewayClient.Stat(statCtx, &storageprovider.StatRequest{
|
||||
Ref: &storageprovider.Reference{
|
||||
ResourceId: receivedShares[0].GetShare().GetResourceId(),
|
||||
},
|
||||
})
|
||||
|
||||
if err := errorcode.FromCS3Status(shareStat.GetStatus(), err); err != nil {
|
||||
logger.Debug().Err(err).
|
||||
if err != nil {
|
||||
// The storage could not be reached in time (per-share timeout,
|
||||
// cancellation, or an unavailable downstream). The resource most
|
||||
// likely still exists, so keep the share visible as a degraded item
|
||||
// built from the share record instead of dropping it: a single slow
|
||||
// share must neither vanish nor take the other shares down with it.
|
||||
logger.Warn().Err(err).
|
||||
Str("shareid", receivedShares[0].GetShare().GetId().GetOpaqueId()).
|
||||
Str("resourceid", storagespace.FormatResourceID(receivedShares[0].GetShare().GetResourceId())).
|
||||
Msg("could not stat received share, skipping")
|
||||
Msg("could not stat received share, returning a degraded drive item")
|
||||
degradedShares.Add(1)
|
||||
ch <- *buildDegradedDriveItemFromReceivedShares(ctx, logger, identityCache, receivedShares, availableRoles)
|
||||
return nil
|
||||
}
|
||||
|
||||
if statErr := errorcode.FromCS3Status(shareStat.GetStatus(), nil); statErr != nil {
|
||||
// The storage answered with a definitive error (resource gone,
|
||||
// access revoked, or a broken node, e.g. after the sharer was
|
||||
// deleted). The share is dead and must not be listed.
|
||||
logger.Debug().Err(statErr).
|
||||
Str("shareid", receivedShares[0].GetShare().GetId().GetOpaqueId()).
|
||||
Str("resourceid", storagespace.FormatResourceID(receivedShares[0].GetShare().GetResourceId())).
|
||||
Msg("could not stat received share, skipping (resource unavailable)")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -348,9 +392,68 @@ func cs3ReceivedSharesToDriveItems(ctx context.Context,
|
||||
driveItems = append(driveItems, di)
|
||||
}
|
||||
|
||||
if n := degradedShares.Load(); n > 0 {
|
||||
logger.Warn().
|
||||
Int64("degraded", n).
|
||||
Int("total", len(receivedSharesByResourceID)).
|
||||
Msg("some received shares could not be fully resolved and were returned as degraded drive items")
|
||||
}
|
||||
|
||||
return driveItems, err
|
||||
}
|
||||
|
||||
// buildDegradedDriveItemFromReceivedShares constructs a DriveItem for a set of
|
||||
// received shares pointing at the same resource when that resource could not be
|
||||
// statted. It exposes the data already contained in the share records (ids,
|
||||
// permissions, grantees, timestamps, mountpoint name) so the share stays
|
||||
// visible in the sharedWithMe listing instead of being silently dropped.
|
||||
// Properties that are only known from a successful Stat (size, etag, mime type,
|
||||
// owner, file/folder type) are intentionally left unset. It never returns an
|
||||
// error: if even the degraded build fails it falls back to a minimal item that
|
||||
// still carries the share identity.
|
||||
func buildDegradedDriveItemFromReceivedShares(ctx context.Context, logger *log.Logger,
|
||||
identityCache identity.IdentityCache, receivedShares []*collaboration.ReceivedShare,
|
||||
availableRoles []*libregraph.UnifiedRoleDefinition) *libregraph.DriveItem {
|
||||
|
||||
driveItem, err := fillDriveItemPropertiesFromReceivedShare(ctx, logger, identityCache, receivedShares, nil, availableRoles)
|
||||
if err != nil {
|
||||
logger.Warn().Err(err).
|
||||
Str("shareid", receivedShares[0].GetShare().GetId().GetOpaqueId()).
|
||||
Msg("could not build degraded drive item, returning a minimal item")
|
||||
driveItem = libregraph.NewDriveItem()
|
||||
driveItem.SetId(storagespace.FormatResourceID(&storageprovider.ResourceId{
|
||||
StorageId: utils.ShareStorageProviderID,
|
||||
OpaqueId: receivedShares[0].GetShare().GetId().GetOpaqueId(),
|
||||
SpaceId: utils.ShareStorageSpaceID,
|
||||
}))
|
||||
driveItem.RemoteItem = libregraph.NewRemoteItem()
|
||||
}
|
||||
|
||||
// the item lives in the virtual share jail, same as the fully-resolved item
|
||||
driveItem.ParentReference = libregraph.NewItemReference()
|
||||
driveItem.ParentReference.SetDriveType(_spaceTypeVirtual)
|
||||
driveItem.ParentReference.SetDriveId(storagespace.FormatStorageID(utils.ShareStorageProviderID, utils.ShareStorageSpaceID))
|
||||
driveItem.ParentReference.SetId(storagespace.FormatResourceID(&storageprovider.ResourceId{
|
||||
StorageId: utils.ShareStorageProviderID,
|
||||
OpaqueId: utils.ShareStorageSpaceID,
|
||||
SpaceId: utils.ShareStorageSpaceID,
|
||||
}))
|
||||
|
||||
if rid := receivedShares[0].GetShare().GetResourceId(); rid != nil {
|
||||
driveItem.RemoteItem.SetId(storagespace.FormatResourceID(rid))
|
||||
driveItem.RemoteItem.SpaceId = libregraph.PtrString(storagespace.FormatStorageID(rid.GetStorageId(), rid.GetSpaceId()))
|
||||
}
|
||||
|
||||
// fall back to the mountpoint name when the resource name is unknown
|
||||
if driveItem.GetName() == "" {
|
||||
if name := receivedShares[0].GetMountPoint().GetPath(); name != "" {
|
||||
driveItem.SetName(name)
|
||||
}
|
||||
}
|
||||
|
||||
return driveItem
|
||||
}
|
||||
|
||||
func fillDriveItemPropertiesFromReceivedShare(ctx context.Context, logger *log.Logger,
|
||||
identityCache identity.IdentityCache, receivedShares []*collaboration.ReceivedShare,
|
||||
resourceInfo *storageprovider.ResourceInfo, availableRoles []*libregraph.UnifiedRoleDefinition) (*libregraph.DriveItem, error) {
|
||||
@@ -443,26 +546,36 @@ func cs3ReceivedShareToLibreGraphPermissions(ctx context.Context, logger *log.Lo
|
||||
}
|
||||
|
||||
if permissionSet := receivedShare.GetShare().GetPermissions().GetPermissions(); permissionSet != nil {
|
||||
condition, err := roleConditionForResourceType(resourceInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// resourceInfo is nil for a degraded item, i.e. when the underlying
|
||||
// resource could not be statted. The resource type, and therefore the
|
||||
// unified role, cannot be determined in that case, so expose the raw
|
||||
// actions instead of failing the whole listing.
|
||||
if resourceInfo == nil {
|
||||
if actions := unifiedrole.CS3ResourcePermissionsToLibregraphActions(permissionSet); len(actions) > 0 {
|
||||
permission.SetLibreGraphPermissionsActions(actions)
|
||||
}
|
||||
} else {
|
||||
condition, err := roleConditionForResourceType(resourceInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
role := unifiedrole.CS3ResourcePermissionsToRole(
|
||||
availableRoles,
|
||||
permissionSet,
|
||||
condition,
|
||||
false,
|
||||
)
|
||||
if role != nil {
|
||||
permission.SetRoles([]string{role.GetId()})
|
||||
}
|
||||
role := unifiedrole.CS3ResourcePermissionsToRole(
|
||||
availableRoles,
|
||||
permissionSet,
|
||||
condition,
|
||||
false,
|
||||
)
|
||||
if role != nil {
|
||||
permission.SetRoles([]string{role.GetId()})
|
||||
}
|
||||
|
||||
actions := unifiedrole.CS3ResourcePermissionsToLibregraphActions(permissionSet)
|
||||
actions := unifiedrole.CS3ResourcePermissionsToLibregraphActions(permissionSet)
|
||||
|
||||
// actions only make sense if no role is set
|
||||
if role == nil && len(actions) > 0 {
|
||||
permission.SetLibreGraphPermissionsActions(actions)
|
||||
// actions only make sense if no role is set
|
||||
if role == nil && len(actions) > 0 {
|
||||
permission.SetLibreGraphPermissionsActions(actions)
|
||||
}
|
||||
}
|
||||
}
|
||||
switch grantee := receivedShare.GetShare().GetGrantee(); {
|
||||
|
||||
@@ -86,6 +86,7 @@ OPTIONS:
|
||||
--processing filter sessions by processing status (default: unset)
|
||||
--expired filter sessions by expired status (default: unset)
|
||||
--has-virus filter sessions by virus scan result (default: unset)
|
||||
--orphaned filter sessions by whether their node metadata is unreadable (default: unset)
|
||||
--json output as json (default: false)
|
||||
--restart send restart event for all listed sessions (default: false)
|
||||
--resume send resume event for all listed sessions (default: false)
|
||||
@@ -140,6 +141,23 @@ ocis storage-users uploads sessions --expired=true --clean
|
||||
ocis storage-users uploads sessions --processing=true --has-virus=false --resume
|
||||
```
|
||||
|
||||
Uploads whose node metadata can no longer be read are orphaned: they can never finish
|
||||
postprocessing, because the destination of the upload cannot be resolved. Such uploads stay
|
||||
in processing state indefinitely and keep consuming the quota of their space. Use the
|
||||
`--orphaned` filter to list them, and `--clean` to remove them and release the quota.
|
||||
|
||||
```bash
|
||||
# lists all orphaned upload sessions
|
||||
ocis storage-users uploads sessions --orphaned=true
|
||||
|
||||
# removes them and releases the quota they consume
|
||||
ocis storage-users uploads sessions --orphaned=true --clean
|
||||
```
|
||||
|
||||
Note: `--orphaned` reads the node metadata of every upload session, so it is slower than the
|
||||
other filters. Cleaning an orphaned session deletes the uploaded bytes, which are the only
|
||||
copy as long as postprocessing has not finished. Run the command without `--clean` first.
|
||||
|
||||
|
||||
#### Delete Stale Nodes command
|
||||
|
||||
@@ -184,6 +202,92 @@ ocis storage-users uploads delete-stale-nodes --dry-run=false --verbose
|
||||
```
|
||||
|
||||
|
||||
### Check and Inspect the Blobstore
|
||||
|
||||
The `blobstore` command group provides tools to verify connectivity to the configured blobstore and to inspect individual blobs. Both the `ocis` and `s3ng` storage drivers are supported.
|
||||
|
||||
```bash
|
||||
ocis storage-users blobstore <command>
|
||||
```
|
||||
|
||||
```plaintext
|
||||
COMMANDS:
|
||||
check check blobstore connectivity via an upload/download/delete round-trip
|
||||
get get a blob from the blobstore by ID
|
||||
```
|
||||
|
||||
#### Check
|
||||
|
||||
Verifies that the blobstore is reachable and fully operational by uploading a random blob, downloading and verifying it, then deleting it again. All three steps must succeed.
|
||||
|
||||
```bash
|
||||
ocis storage-users blobstore check [command options]
|
||||
```
|
||||
|
||||
```
|
||||
OPTIONS:
|
||||
--blob-size value size of the random blob to upload, e.g. 64, 1KB, 1MB, 4MiB (default: "64")
|
||||
--help, -h show help
|
||||
```
|
||||
|
||||
**Examples:**
|
||||
|
||||
```bash
|
||||
# Basic connectivity check using the default 64-byte payload
|
||||
ocis storage-users blobstore check
|
||||
|
||||
# Use a larger payload to also stress-test throughput
|
||||
ocis storage-users blobstore check --blob-size=4MiB
|
||||
```
|
||||
|
||||
```plaintext
|
||||
Uploading test blob: spaceID=a5c9bd5c-7348-4e9e-a462-d4d9e5287d01 blobID=3f1e5a82-b7e3-4c91-a110-1d5e2f3a4b6c
|
||||
Upload: OK
|
||||
Download and verify: OK
|
||||
Delete: OK
|
||||
Blobstore check successful.
|
||||
```
|
||||
|
||||
#### Get
|
||||
|
||||
Downloads a single blob by its ID to verify it exists and is readable. Useful when investigating errors in log lines that contain a blob path such as:
|
||||
|
||||
```
|
||||
decomposedfs: error download blob '04ba5496-...': blob path: b19ec764-.../61/03/ab/c3/-b08a-...: The specified key does not exist.
|
||||
```
|
||||
|
||||
The blob can be identified either by passing the raw path from the log line with `--path`, or by supplying `--blob-id` and `--space-id` individually.
|
||||
|
||||
```bash
|
||||
ocis storage-users blobstore get [command options]
|
||||
```
|
||||
|
||||
```
|
||||
OPTIONS:
|
||||
--path value blobstore path as it appears in log lines; spaceID and blobID are extracted automatically.
|
||||
Supports both s3ng format ("<spaceID>/<pathified_blobID>") and ocis format
|
||||
("…/spaces/<pathified_spaceID>/blobs/<pathified_blobID>").
|
||||
--blob-id value blob ID to download (required when --path is not set)
|
||||
--space-id value space ID the blob belongs to (required when --path is not set)
|
||||
--blob-size value expected blob size in bytes; only needed for the s3ng driver when the size is known
|
||||
upfront. If omitted or wrong, a size mismatch triggers one automatic retry with the
|
||||
actual size returned by s3ng. (default: 0)
|
||||
--help, -h show help
|
||||
```
|
||||
|
||||
**Examples:**
|
||||
|
||||
```bash
|
||||
# Identify a blob using the path from a log line (s3ng)
|
||||
ocis storage-users blobstore get --path="b19ec764-5398-458a-8ff1-1925bd906999/61/03/ab/c3/-b08a-4556-9937-2bf3065c1202"
|
||||
|
||||
# Identify a blob using the full filesystem path from a log line (ocis driver)
|
||||
ocis storage-users blobstore get --path="/var/lib/ocis/storage/users/spaces/b1/9ec764-5398-458a-8ff1-1925bd906999/blobs/61/03/ab/c3/-b08a-4556-9937-2bf3065c1202"
|
||||
|
||||
# Identify a blob using explicit IDs
|
||||
ocis storage-users blobstore get --space-id=b19ec764-5398-458a-8ff1-1925bd906999 --blob-id=6103abc3-b08a-4556-9937-2bf3065c1202
|
||||
```
|
||||
|
||||
### Manage Spaces
|
||||
|
||||
This command set provides commands to manage spaces, including purging disabled spaces that exceed the retention period.
|
||||
@@ -321,3 +425,106 @@ Store specific notes:
|
||||
- When using `redis-sentinel`, the Redis master to use is configured via e.g. `OCIS_CACHE_STORE_NODES` in the form of `<sentinel-host>:<sentinel-port>/<redis-master>` like `10.10.0.200:26379/mymaster`.
|
||||
- When using `nats-js-kv` it is recommended to set `OCIS_CACHE_STORE_NODES` to the same value as `OCIS_EVENTS_ENDPOINT`. That way the cache uses the same nats instance as the event bus.
|
||||
- When using the `nats-js-kv` store, it is possible to set `OCIS_CACHE_DISABLE_PERSISTENCE` to instruct nats to not persist cache data on disc.
|
||||
|
||||
## Vault Mode
|
||||
|
||||
Vault mode provides a dedicated, separately stored vault storage that can be MFA-protected. Vault resources are isolated from the default user storage and have their own search, shares, and spaces — while public links are explicitly disallowed.
|
||||
|
||||
### Architecture
|
||||
|
||||
* A dedicated `storage-users` vault storage instance is configured with a `VaultStorageProviderID` and mounted at `/vault/users` and `/vault/projects`.
|
||||
* The `graph` service API is extended to serve the `/vault` prefix when vault mode is active.
|
||||
* WebDAV access is supported for vault resources.
|
||||
* Search is scoped separately for default and vault files, including their shares and spaces.
|
||||
* Public links are disallowed for vault resources. The capabilities endpoint accepts a `vault=true` query parameter to advertise vault-specific capabilities.
|
||||
|
||||
#### The `vault mode` Configuration and Environment Variables
|
||||
|
||||
Set\
|
||||
`OCIS_MFA_ENABLED: true`\
|
||||
`OCIS_ENABLE_VAULT_MODE: true` and\
|
||||
to enable the vault mode in a OCIS.\
|
||||
Only applicapable if the storage-users-vault service, a special configured storage-users service is configured.
|
||||
|
||||
The storage-users-vault configuration:
|
||||
```
|
||||
STORAGE_USERS_SERVICE_NAME: storage-users-vault
|
||||
STORAGE_USERS_GRPC_ADDR: storage-users-vault:9285
|
||||
STORAGE_USERS_HTTP_ADDR: storage-users-vault:9286
|
||||
STORAGE_USERS_DATA_SERVER_URL: http://storage-users-vault:9286/data
|
||||
STORAGE_USERS_DEBUG_ADDR: storage-users-vault:9287
|
||||
STORAGE_USERS_OCIS_ROOT: /var/lib/ocis/storage/users-vault
|
||||
STORAGE_USERS_EVENTS_CONSUMER_GROUP: vault-dcfs
|
||||
```
|
||||
|
||||
```
|
||||
~/.ocis/storage
|
||||
$ tree users*
|
||||
users
|
||||
├── indexes
|
||||
│ ├── by-group-id
|
||||
│ ├── by-type
|
||||
│ │ └── personal.mpk
|
||||
│ └── by-user-id
|
||||
│ └── a032f2bd-fa5c-430b-a163-2c19f54190d0.mpk
|
||||
├── spaces
|
||||
│ └── a0
|
||||
│ └── 32f2bd-fa5c-430b-a163-2c19f54190d0
|
||||
│ └── nodes
|
||||
│ └── a0
|
||||
│ └── 32
|
||||
│ └── f2
|
||||
│ └── bd
|
||||
│ ├── -fa5c-430b-a163-2c19f54190d0
|
||||
│ ├── -fa5c-430b-a163-2c19f54190d0.mlock
|
||||
│ └── -fa5c-430b-a163-2c19f54190d0.mpk
|
||||
└── uploads
|
||||
users-vault
|
||||
├── indexes
|
||||
│ ├── by-group-id
|
||||
│ ├── by-type
|
||||
│ │ └── personal.mpk
|
||||
│ └── by-user-id
|
||||
│ └── a032f2bd-fa5c-430b-a163-2c19f54190d0.mpk
|
||||
├── spaces
|
||||
│ └── a0
|
||||
│ └── 32f2bd-fa5c-430b-a163-2c19f54190d0
|
||||
│ └── nodes
|
||||
│ └── a0
|
||||
│ └── 32
|
||||
│ └── f2
|
||||
│ └── bd
|
||||
│ ├── -fa5c-430b-a163-2c19f54190d0
|
||||
│ ├── -fa5c-430b-a163-2c19f54190d0.mlock
|
||||
│ └── -fa5c-430b-a163-2c19f54190d0.mpk
|
||||
└── uploads
|
||||
```
|
||||
|
||||
### Checking Vault Mode in the Frontend
|
||||
|
||||
To check whether vault mode is enabled in the frontend, use the `@ownclouders/web-pkg` package:
|
||||
|
||||
```typescript
|
||||
import { useAbility } from '@ownclouders/web-pkg'
|
||||
import { useCapabilityStore } from '@ownclouders/web-pkg'
|
||||
|
||||
const capabilityStore = useCapabilityStore()
|
||||
const { can } = useAbility()
|
||||
|
||||
const isVaultModeEnabled = capabilityStore.vaultEnabled && can('read-all', 'Vault')
|
||||
```
|
||||
|
||||
### Running with Docker
|
||||
|
||||
To enable vault mode in the `ocis_full` docker-compose stack, edit `deployments/examples/ocis_full/.env` and uncomment the following lines:
|
||||
|
||||
```.env
|
||||
KEYCLOAK=:keycloak.yml
|
||||
VAULT_STORAGE=:vault-storage.yml
|
||||
```
|
||||
|
||||
Then start the stack:
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
@@ -93,6 +93,11 @@ func ListUploadSessions(cfg *config.Config) *cli.Command {
|
||||
DefaultText: "unset",
|
||||
Usage: "filter sessions by virus scan result",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "orphaned",
|
||||
DefaultText: "unset",
|
||||
Usage: "filter sessions by whether their node metadata is unreadable. Such sessions can never finish processing and can be removed with --clean",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "json",
|
||||
Usage: "output as json",
|
||||
@@ -259,6 +264,10 @@ func buildFilter(c *cli.Context) storage.UploadSessionFilter {
|
||||
infectedValue := c.Bool("has-virus")
|
||||
filter.HasVirus = &infectedValue
|
||||
}
|
||||
if c.IsSet("orphaned") {
|
||||
orphanedValue := c.Bool("orphaned")
|
||||
filter.Orphaned = &orphanedValue
|
||||
}
|
||||
if c.IsSet("id") {
|
||||
idValue := c.String("id")
|
||||
filter.ID = &idValue
|
||||
@@ -315,6 +324,24 @@ func buildInfo(filter storage.UploadSessionFilter) string {
|
||||
}
|
||||
}
|
||||
|
||||
if filter.Orphaned != nil {
|
||||
if b.Len() != 0 {
|
||||
b.WriteString(", ")
|
||||
}
|
||||
if !*filter.Orphaned {
|
||||
if b.Len() == 0 {
|
||||
b.WriteString("Not ")
|
||||
} else {
|
||||
b.WriteString("not ")
|
||||
}
|
||||
}
|
||||
if b.Len() == 0 {
|
||||
b.WriteString("Orphaned")
|
||||
} else {
|
||||
b.WriteString("orphaned")
|
||||
}
|
||||
}
|
||||
|
||||
if b.Len() == 0 {
|
||||
b.WriteString("Session")
|
||||
} else {
|
||||
|
||||
@@ -63,6 +63,26 @@ func TestBuildInfo(t *testing.T) {
|
||||
filter: storage.UploadSessionFilter{Processing: boolPtr(true), Expired: boolPtr(false), HasVirus: boolPtr(true), ID: strPtr("123")},
|
||||
expectedInfo: "Processing, not expired, virusinfected session with id '123':",
|
||||
},
|
||||
{
|
||||
alias: "orphaned",
|
||||
filter: storage.UploadSessionFilter{Orphaned: boolPtr(true)},
|
||||
expectedInfo: "Orphaned sessions:",
|
||||
},
|
||||
{
|
||||
alias: "not orphaned",
|
||||
filter: storage.UploadSessionFilter{Orphaned: boolPtr(false)},
|
||||
expectedInfo: "Not orphaned sessions:",
|
||||
},
|
||||
{
|
||||
alias: "processing and orphaned",
|
||||
filter: storage.UploadSessionFilter{Processing: boolPtr(true), Orphaned: boolPtr(true)},
|
||||
expectedInfo: "Processing, orphaned sessions:",
|
||||
},
|
||||
{
|
||||
alias: "expired, not virus infected and orphaned",
|
||||
filter: storage.UploadSessionFilter{Expired: boolPtr(true), HasVirus: boolPtr(false), Orphaned: boolPtr(true)},
|
||||
expectedInfo: "Expired, not virusinfected, orphaned sessions:",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
||||
Generated
Vendored
+4
-2
@@ -440,8 +440,10 @@ func (s *Service) InitiateFileUpload(ctx context.Context, req *provider.Initiate
|
||||
st = status.NewFailedPrecondition(ctx, err, "failed precondition")
|
||||
case errtypes.Locked:
|
||||
st = status.NewLocked(ctx, "locked")
|
||||
case errtypes.IsTooEarly:
|
||||
st = status.NewAborted(ctx, err, "upload in progress, retry later")
|
||||
case errtypes.Aborted:
|
||||
st = status.NewAborted(ctx, err, "response from InitiateUpload")
|
||||
case errtypes.AlreadyExists:
|
||||
st = status.NewAlreadyExists(ctx, err, "response from InitiateUpload")
|
||||
default:
|
||||
st = status.NewInternal(ctx, "error getting upload id: "+err.Error())
|
||||
}
|
||||
|
||||
+2
-1
@@ -24,6 +24,7 @@ package errtypes
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
|
||||
@@ -384,7 +385,7 @@ func NewErrtypeFromHTTPStatusCode(code int, message string) error {
|
||||
case StatusChecksumMismatch:
|
||||
return ChecksumMismatch(message)
|
||||
default:
|
||||
return InternalError(message)
|
||||
return InternalError("http " + strconv.Itoa(code) + ": " + message)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
@@ -523,6 +523,14 @@ func (m *manager) ListPublicShares(ctx context.Context, u *user.User, filters []
|
||||
continue
|
||||
}
|
||||
|
||||
if local.ResourceId == nil {
|
||||
log.Warn().
|
||||
Str("share_id", local.PublicShare.GetId().GetOpaqueId()).
|
||||
Str("share_token", local.Token).
|
||||
Msg("ListPublicShares: skipping share with nil resource_id")
|
||||
continue
|
||||
}
|
||||
|
||||
key := strings.Join([]string{local.ResourceId.StorageId, local.ResourceId.OpaqueId}, "!")
|
||||
if _, hit := cache[key]; !hit && !publicshare.IsCreatedByUser(&local.PublicShare, u) {
|
||||
sRes, err := client.Stat(ctx, &provider.StatRequest{Ref: &provider.Reference{ResourceId: local.ResourceId}})
|
||||
|
||||
Generated
Vendored
+128
-55
@@ -22,13 +22,13 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/rand/v2"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
backoff "github.com/cenkalti/backoff/v5"
|
||||
collaboration "github.com/cs3org/go-cs3apis/cs3/sharing/collaboration/v1beta1"
|
||||
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
|
||||
"github.com/owncloud/reva/v2/pkg/appctx"
|
||||
@@ -37,6 +37,8 @@ import (
|
||||
"github.com/owncloud/reva/v2/pkg/storage/utils/metadata"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
grpccodes "google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// name is the Tracer name used to identify this instrumentation library.
|
||||
@@ -95,12 +97,12 @@ func (c *Cache) lockUser(userID string) func() {
|
||||
func (c *Cache) Add(ctx context.Context, userID, spaceID string, rs *collaboration.ReceivedShare) error {
|
||||
ctx, span := appctx.GetTracerProvider(ctx).Tracer(tracerName).Start(ctx, "Grab lock")
|
||||
unlock := c.lockUser(userID)
|
||||
span.End()
|
||||
span.SetAttributes(attribute.String("cs3.userid", userID))
|
||||
span.End()
|
||||
defer unlock()
|
||||
|
||||
if _, ok := c.ReceivedSpaces.Load(userID); !ok {
|
||||
err := c.syncIfStale(ctx, userID)
|
||||
err := c.syncWithRetry(ctx, userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -139,11 +141,11 @@ func (c *Cache) Add(ctx context.Context, userID, spaceID string, rs *collaborati
|
||||
func (c *Cache) Get(ctx context.Context, userID, spaceID, shareID string) (*State, error) {
|
||||
ctx, span := appctx.GetTracerProvider(ctx).Tracer(tracerName).Start(ctx, "Grab lock")
|
||||
unlock := c.lockUser(userID)
|
||||
span.End()
|
||||
span.SetAttributes(attribute.String("cs3.userid", userID))
|
||||
span.End()
|
||||
defer unlock()
|
||||
|
||||
err := c.syncIfStale(ctx, userID)
|
||||
err := c.syncWithRetry(ctx, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -158,8 +160,8 @@ func (c *Cache) Get(ctx context.Context, userID, spaceID, shareID string) (*Stat
|
||||
func (c *Cache) Remove(ctx context.Context, userID, spaceID, shareID string) error {
|
||||
ctx, span := appctx.GetTracerProvider(ctx).Tracer(tracerName).Start(ctx, "Grab lock")
|
||||
unlock := c.lockUser(userID)
|
||||
span.End()
|
||||
span.SetAttributes(attribute.String("cs3.userid", userID))
|
||||
span.End()
|
||||
defer unlock()
|
||||
|
||||
ctx, span = appctx.GetTracerProvider(ctx).Tracer(tracerName).Start(ctx, "Remove")
|
||||
@@ -200,7 +202,7 @@ func (c *Cache) List(ctx context.Context, userID string) (map[string]*Space, err
|
||||
unlock := c.lockUser(userID)
|
||||
defer unlock()
|
||||
|
||||
err := c.syncIfStale(ctx, userID)
|
||||
err := c.syncWithRetry(ctx, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -226,7 +228,21 @@ func (c *Cache) List(ctx context.Context, userID string) (map[string]*Space, err
|
||||
func isSyncTransient(err error) bool {
|
||||
_, isTooEarly := err.(errtypes.IsTooEarly)
|
||||
_, isInternal := err.(errtypes.IsInternalError)
|
||||
return isTooEarly || isInternal
|
||||
return isTooEarly || isInternal || isTransientGRPCStatus(err)
|
||||
}
|
||||
|
||||
// isTransientGRPCStatus catches raw gRPC transport errors that metadata.CS3 never wraps in errtypes.
|
||||
func isTransientGRPCStatus(err error) bool {
|
||||
st, ok := status.FromError(err)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
switch st.Code() {
|
||||
case grpccodes.Unavailable, grpccodes.DeadlineExceeded, grpccodes.Canceled, grpccodes.ResourceExhausted:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cache) retryPersist(ctx context.Context, userID, spaceID string, persistFunc func() error) error {
|
||||
@@ -235,6 +251,102 @@ func (c *Cache) retryPersist(ctx context.Context, userID, spaceID string, persis
|
||||
Str("userID", userID).
|
||||
Str("spaceID", spaceID).Logger()
|
||||
|
||||
bo := backoff.NewExponentialBackOff()
|
||||
bo.InitialInterval = 500 * time.Microsecond
|
||||
bo.Multiplier = 2.0
|
||||
bo.RandomizationFactor = 1.0
|
||||
bo.MaxInterval = 50 * time.Millisecond
|
||||
|
||||
const maxPersistAttempts = 20
|
||||
const maxIterations = 2 * maxPersistAttempts
|
||||
|
||||
var err error
|
||||
needsResync := false
|
||||
persistAttempts := 0
|
||||
for iter := 0; iter < maxIterations && persistAttempts < maxPersistAttempts; iter++ {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
default:
|
||||
}
|
||||
|
||||
if needsResync {
|
||||
// a previous persist attempt failed and the re-read to pick up fresh state
|
||||
// was itself transient; keep retrying the re-read instead of hammering
|
||||
// persistFunc again with the same stale in-memory rss/etag
|
||||
serr := c.sync(ctx, userID)
|
||||
if serr == nil {
|
||||
needsResync = false
|
||||
continue // fresh state is in memory; retry persistFunc next attempt, no need to wait
|
||||
}
|
||||
// keep err at its last real (persist or resync) failure; never let a
|
||||
// budget-exhausting resync success clobber it into a false nil return
|
||||
err = serr
|
||||
if !isSyncTransient(serr) {
|
||||
log.Error().Int("attempt", iter).Err(serr).Msg("lost update: re-read failed, aborting")
|
||||
return serr
|
||||
}
|
||||
log.Warn().Int("attempt", iter).Err(serr).Msg("lost update: re-read before retry")
|
||||
} else {
|
||||
persistAttempts++
|
||||
err = persistFunc()
|
||||
switch {
|
||||
case err == nil:
|
||||
return nil
|
||||
case isTransientGRPCStatus(err):
|
||||
log.Debug().Int("attempt", iter).Err(err).Msg("persist failed: transient gRPC error, retrying")
|
||||
default:
|
||||
switch err.(type) {
|
||||
case errtypes.Aborted:
|
||||
// expected when the if-match etag check fails; on some branches TooEarly also surfaces as Aborted
|
||||
// continue with sync below
|
||||
log.Debug().Int("attempt", iter).Msg("CAS failed: Aborted (etag changed or upload in progress), retrying")
|
||||
case errtypes.PreconditionFailed:
|
||||
// actually, this is the wrong status code and we treat it like errtypes.Aborted because of inconsistencies on the server side
|
||||
// continue with sync below
|
||||
log.Debug().Int("attempt", iter).Msg("CAS failed: PreconditionFailed (etag changed), retrying")
|
||||
case errtypes.AlreadyExists:
|
||||
// CS3 uses an already exists error instead of precondition failed when using an If-None-Match=* header / IfExists flag in the InitiateFileUpload call.
|
||||
// Thas happens when the cache thinks there is no file.
|
||||
// continue with sync below
|
||||
log.Debug().Int("attempt", iter).Msg("CAS failed: AlreadyExists (file created concurrently), retrying")
|
||||
case errtypes.TooEarly:
|
||||
// storage-system has an upload in progress for this node; wait for it to finish
|
||||
// continue with sync below
|
||||
log.Debug().Int("attempt", iter).Msg("CAS failed: TooEarly (upload in progress), retrying")
|
||||
case errtypes.InternalError:
|
||||
// transient backend error (e.g. disk.go's flock contention under write fan-in);
|
||||
// CAS conflicts no longer masquerade as this since storageprovider.go's Aborted/
|
||||
// AlreadyExists mapping fix (b1a5804ec)
|
||||
log.Debug().Int("attempt", iter).Err(err).Msg("persist failed: InternalError (transient), retrying")
|
||||
default:
|
||||
log.Error().Int("attempt", iter).Err(err).Msg("persisting received share failed, giving up")
|
||||
return err
|
||||
}
|
||||
}
|
||||
needsResync = true
|
||||
}
|
||||
|
||||
timer := time.NewTimer(bo.NextBackOff())
|
||||
select {
|
||||
case <-timer.C:
|
||||
case <-ctx.Done():
|
||||
timer.Stop()
|
||||
return ctx.Err()
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// syncWithRetry retries sync's cold-start read on transient errors, since
|
||||
// Add/Get/List call it directly with no other retry wrapper around it.
|
||||
func (c *Cache) syncWithRetry(ctx context.Context, userID string) error {
|
||||
bo := backoff.NewExponentialBackOff()
|
||||
bo.InitialInterval = 500 * time.Microsecond
|
||||
bo.Multiplier = 2.0
|
||||
bo.RandomizationFactor = 1.0
|
||||
bo.MaxInterval = 50 * time.Millisecond
|
||||
|
||||
var err error
|
||||
for attempt := 0; attempt < 20; attempt++ {
|
||||
select {
|
||||
@@ -242,52 +354,27 @@ func (c *Cache) retryPersist(ctx context.Context, userID, spaceID string, persis
|
||||
return ctx.Err()
|
||||
default:
|
||||
}
|
||||
err = persistFunc()
|
||||
switch err.(type) {
|
||||
case nil:
|
||||
err = c.sync(ctx, userID)
|
||||
if err == nil {
|
||||
return nil
|
||||
case errtypes.Aborted:
|
||||
// this is the expected status code from the server when the if-match etag check fails
|
||||
// continue with sync below
|
||||
log.Debug().Int("attempt", attempt).Msg("CAS failed: Aborted (etag changed), retrying")
|
||||
case errtypes.PreconditionFailed:
|
||||
// actually, this is the wrong status code and we treat it like errtypes.Aborted because of inconsistencies on the server side
|
||||
// continue with sync below
|
||||
log.Debug().Int("attempt", attempt).Msg("CAS failed: PreconditionFailed (etag changed), retrying")
|
||||
case errtypes.AlreadyExists:
|
||||
// CS3 uses an already exists error instead of precondition failed when using an If-None-Match=* header / IfExists flag in the InitiateFileUpload call.
|
||||
// Thas happens when the cache thinks there is no file.
|
||||
// continue with sync below
|
||||
log.Debug().Int("attempt", attempt).Msg("CAS failed: AlreadyExists (file created concurrently), retrying")
|
||||
case errtypes.TooEarly:
|
||||
// storage-system has an upload in progress for this node; wait for it to finish
|
||||
// continue with sync below
|
||||
log.Debug().Int("attempt", attempt).Msg("CAS failed: TooEarly (upload in progress), retrying")
|
||||
default:
|
||||
log.Error().Int("attempt", attempt).Err(err).Msg("persisting received share failed, giving up")
|
||||
}
|
||||
if !isSyncTransient(err) {
|
||||
return err
|
||||
}
|
||||
timer := time.NewTimer(expBackoff(attempt))
|
||||
timer := time.NewTimer(bo.NextBackOff())
|
||||
select {
|
||||
case <-timer.C:
|
||||
case <-ctx.Done():
|
||||
timer.Stop()
|
||||
return ctx.Err()
|
||||
}
|
||||
if serr := c.syncIfStale(ctx, userID); serr != nil {
|
||||
if !isSyncTransient(serr) {
|
||||
log.Error().Int("attempt", attempt).Err(serr).Msg("lost update: re-read failed, aborting")
|
||||
return serr
|
||||
}
|
||||
log.Warn().Int("attempt", attempt).Err(serr).Msg("lost update: re-read before retry")
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// syncIfStale pulls the authoritative state from storage when the local replica is stale; caller must hold the user lock.
|
||||
func (c *Cache) syncIfStale(ctx context.Context, userID string) error {
|
||||
ctx, span := appctx.GetTracerProvider(ctx).Tracer(tracerName).Start(ctx, "SyncIfStale")
|
||||
// sync pulls the authoritative state from storage; caller must hold the user lock.
|
||||
func (c *Cache) sync(ctx context.Context, userID string) error {
|
||||
ctx, span := appctx.GetTracerProvider(ctx).Tracer(tracerName).Start(ctx, "Sync")
|
||||
defer span.End()
|
||||
span.SetAttributes(attribute.String("cs3.userid", userID))
|
||||
|
||||
@@ -308,9 +395,6 @@ func (c *Cache) syncIfStale(ctx context.Context, userID string) error {
|
||||
span.AddEvent("updating local cache")
|
||||
case errtypes.NotFound:
|
||||
span.SetStatus(codes.Ok, "")
|
||||
if err := c.persist(ctx, userID); err != nil {
|
||||
log.Warn().Err(err).Msg("failed to create empty received share cache file")
|
||||
}
|
||||
return nil
|
||||
case errtypes.NotModified:
|
||||
span.SetStatus(codes.Ok, "")
|
||||
@@ -386,17 +470,6 @@ func (c *Cache) persist(ctx context.Context, userID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// expBackoff returns full-jitter delay: rand(0, min(100ms, 2^attempt ms)).
|
||||
// attempt: 0 1 2 3 4 5 6 7+
|
||||
// max ms: 1 2 4 8 16 32 64 100
|
||||
func expBackoff(attempt int) time.Duration {
|
||||
base := time.Duration(1<<uint(attempt)) * time.Millisecond
|
||||
if base > 100*time.Millisecond {
|
||||
base = 100 * time.Millisecond
|
||||
}
|
||||
return time.Duration(rand.Int64N(int64(base) + 1))
|
||||
}
|
||||
|
||||
func userJSONPath(userID string) string {
|
||||
return filepath.Join("/users", userID, "received.json")
|
||||
}
|
||||
|
||||
+4
@@ -87,4 +87,8 @@ type UploadSessionFilter struct {
|
||||
Processing *bool
|
||||
Expired *bool
|
||||
HasVirus *bool
|
||||
// Orphaned filters sessions by whether their target node can still be
|
||||
// resolved. Evaluating it requires reading the node metadata of every
|
||||
// session, so it is only evaluated when set.
|
||||
Orphaned *bool
|
||||
}
|
||||
Generated
Vendored
+9
-1
@@ -296,7 +296,12 @@ func (fs *Decomposedfs) Postprocessing(ch <-chan events.Event) {
|
||||
|
||||
n, err := session.Node(ctx)
|
||||
if err != nil {
|
||||
sublog.Error().Err(err).Msg("could not read node")
|
||||
// The node metadata is unreadable, so this upload can never finish:
|
||||
// the destination cannot be resolved. Clean the session up instead of
|
||||
// leaving it behind to be retried forever. Cleanup falls back to the
|
||||
// session metadata to release the quota.
|
||||
sublog.Error().Err(err).Msg("could not read node, cleaning up orphaned session")
|
||||
session.Cleanup(true, true, true, false)
|
||||
continue
|
||||
}
|
||||
sublog = log.With().Str("spaceid", session.SpaceID()).Str("nodeid", session.NodeID()).Logger()
|
||||
@@ -1123,6 +1128,9 @@ func (fs *Decomposedfs) Download(ctx context.Context, ref *provider.Reference, o
|
||||
}
|
||||
var reader io.ReadCloser
|
||||
if openReaderFunc(ri) {
|
||||
if n.IsProcessing(ctx) {
|
||||
return nil, nil, errtypes.TooEarly(n.ID)
|
||||
}
|
||||
reader, err = fs.tp.ReadBlob(n)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "Decomposedfs: error download blob '"+n.ID+"'")
|
||||
|
||||
+5
-2
@@ -135,7 +135,6 @@ func (fs *Decomposedfs) InitiateUpload(ctx context.Context, ref *provider.Refere
|
||||
_, span := tracer.Start(ctx, "InitiateUpload")
|
||||
defer span.End()
|
||||
log := appctx.GetLogger(ctx)
|
||||
log.Debug().Interface("ref", ref).Msg("decomposedfs:InitiateUpload:start")
|
||||
|
||||
// remember the path from the reference
|
||||
refpath := ref.GetPath()
|
||||
@@ -336,7 +335,6 @@ func (fs *Decomposedfs) InitiateUpload(ctx context.Context, ref *provider.Refere
|
||||
}
|
||||
}
|
||||
|
||||
log.Debug().Str("uploadid", session.ID()).Msg("decomposedfs:InitiateUpload:complete")
|
||||
return map[string]string{
|
||||
"simple": session.ID(),
|
||||
"tus": session.ID(),
|
||||
@@ -411,6 +409,11 @@ func (fs *Decomposedfs) ListUploadSessions(ctx context.Context, filter storage.U
|
||||
continue
|
||||
}
|
||||
}
|
||||
// evaluated last: unlike the other filters this reads the node metadata
|
||||
// from disk, so it is only done for sessions that passed all other filters
|
||||
if filter.Orphaned != nil && *filter.Orphaned != session.IsOrphaned(ctx) {
|
||||
continue
|
||||
}
|
||||
filteredSessions = append(filteredSessions, session)
|
||||
}
|
||||
return filteredSessions, nil
|
||||
|
||||
Generated
Vendored
+38
@@ -34,6 +34,7 @@ import (
|
||||
typespb "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
|
||||
"github.com/owncloud/reva/v2/pkg/appctx"
|
||||
ctxpkg "github.com/owncloud/reva/v2/pkg/ctx"
|
||||
"github.com/owncloud/reva/v2/pkg/errtypes"
|
||||
"github.com/owncloud/reva/v2/pkg/storage/utils/decomposedfs/node"
|
||||
"github.com/owncloud/reva/v2/pkg/utils"
|
||||
)
|
||||
@@ -166,6 +167,43 @@ func (s *OcisSession) Node(ctx context.Context) (*node.Node, error) {
|
||||
return node.ReadNode(ctx, s.store.lu, s.SpaceID(), s.info.Storage["NodeId"], false, nil, true)
|
||||
}
|
||||
|
||||
// IsOrphaned returns true if the session's target node can no longer be
|
||||
// resolved. This happens when the node file still exists but its metadata is
|
||||
// gone, e.g. because an ancestor was moved to the trash while the upload was in
|
||||
// flight. Such a session can never finish postprocessing: reading the node
|
||||
// fails before the destination can be determined.
|
||||
func (s *OcisSession) IsOrphaned(ctx context.Context) bool {
|
||||
_, err := s.Node(ctx)
|
||||
return err != nil
|
||||
}
|
||||
|
||||
// syntheticNode builds a node from the session metadata alone, without reading
|
||||
// the node from disk. It is used to clean up sessions whose node metadata is
|
||||
// unreadable: the parent id is still recorded in the session, which is all that
|
||||
// is needed to walk up the tree and revert the size propagation.
|
||||
func (s *OcisSession) syntheticNode(ctx context.Context) (*node.Node, error) {
|
||||
if s.NodeID() == "" || s.NodeParentID() == "" {
|
||||
return nil, errtypes.InternalError("session has no node and parent id")
|
||||
}
|
||||
n := node.New(
|
||||
s.SpaceID(),
|
||||
s.NodeID(),
|
||||
s.NodeParentID(),
|
||||
s.Filename(),
|
||||
s.Size(),
|
||||
s.ID(),
|
||||
provider.ResourceType_RESOURCE_TYPE_FILE,
|
||||
nil,
|
||||
s.store.lu,
|
||||
)
|
||||
spaceRoot, err := node.ReadNode(ctx, s.store.lu, s.SpaceID(), s.SpaceID(), false, nil, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
n.SpaceRoot = spaceRoot
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// ID returns the upload session id
|
||||
func (s *OcisSession) ID() string {
|
||||
return s.info.ID
|
||||
|
||||
Generated
Vendored
+62
-20
@@ -114,13 +114,12 @@ func (session *OcisSession) GetReader(ctx context.Context) (io.ReadCloser, error
|
||||
// implements tusd.DataStore interface
|
||||
// returns tusd errors
|
||||
func (session *OcisSession) FinishUpload(ctx context.Context) error {
|
||||
log := appctx.GetLogger(ctx)
|
||||
log.Debug().Msg("decomposedfs:FinishUpload:start")
|
||||
err := session.FinishUploadDecomposed(ctx)
|
||||
|
||||
if err != nil {
|
||||
// this is part of the tusd integration and we might be able to
|
||||
// log the error in another place
|
||||
log := appctx.GetLogger(ctx)
|
||||
log.Error().Err(err).Msg("failed to finish upload")
|
||||
}
|
||||
|
||||
@@ -141,7 +140,6 @@ func (session *OcisSession) FinishUploadDecomposed(ctx context.Context) error {
|
||||
ctx, span := tracer.Start(session.Context(ctx), "FinishUpload")
|
||||
defer span.End()
|
||||
log := appctx.GetLogger(ctx)
|
||||
log.Debug().Str("session", session.ID()).Msg("decomposedfs:FinishUploadDecomposed:start")
|
||||
|
||||
ctx = ctxpkg.ContextSetInitiator(ctx, session.InitiatorID())
|
||||
|
||||
@@ -248,7 +246,6 @@ func (session *OcisSession) FinishUploadDecomposed(ctx context.Context) error {
|
||||
metrics.UploadSessionsFinalized.Inc()
|
||||
}
|
||||
|
||||
log.Debug().Str("session", session.ID()).Msg("decomposedfs:FinishUploadDecomposed:complete")
|
||||
return session.store.tp.Propagate(ctx, n, session.SizeDiff())
|
||||
}
|
||||
|
||||
@@ -330,10 +327,71 @@ func (session *OcisSession) removeNode(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// revertNode undoes the node changes made when the upload was initiated. For a
|
||||
// readable node this restores the previous revision. When the node metadata can
|
||||
// no longer be read the node is orphaned and can never finish postprocessing; in
|
||||
// that case the node is removed and the optimistic size propagation is reverted
|
||||
// using the parent id recorded in the session, so the space quota is released.
|
||||
func (session *OcisSession) revertNode(ctx context.Context) error {
|
||||
n, err := session.Node(ctx)
|
||||
if err == nil {
|
||||
curUpload, perr := n.ProcessingID(ctx)
|
||||
if perr == nil && curUpload == session.ID() {
|
||||
if rerr := n.RevertCurrentRevision(ctx); rerr != nil {
|
||||
return rerr
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// The node is unreadable. Fall back to the session metadata, which still
|
||||
// carries the node and parent ids needed to release the quota.
|
||||
log := appctx.GetLogger(ctx)
|
||||
log.Info().Err(err).Str("sessionid", session.ID()).Msg("node unreadable, cleaning up orphaned upload")
|
||||
|
||||
sn, serr := session.syntheticNode(ctx)
|
||||
if serr != nil {
|
||||
return serr
|
||||
}
|
||||
|
||||
if sizeDiff := session.SizeDiff(); sizeDiff != 0 {
|
||||
if perr := session.store.tp.Propagate(ctx, sn, -sizeDiff); perr != nil {
|
||||
// Without the propagation the quota would stay consumed. Stop here
|
||||
// so the session can be retried instead of losing the upload.
|
||||
return perr
|
||||
}
|
||||
}
|
||||
|
||||
// The orphaned node file cannot be resolved by any other means, remove it
|
||||
// together with its metadata files. A missing node is not an error here:
|
||||
// the node may never have been created.
|
||||
nodePath := sn.InternalPath()
|
||||
if rerr := utils.RemoveItem(nodePath); rerr != nil && !errors.Is(rerr, fs.ErrNotExist) {
|
||||
log.Error().Err(rerr).Str("nodepath", nodePath).Msg("removing orphaned node failed")
|
||||
}
|
||||
if perr := session.store.lu.MetadataBackend().Purge(ctx, nodePath); perr != nil && !errors.Is(perr, fs.ErrNotExist) {
|
||||
log.Error().Err(perr).Str("nodepath", nodePath).Msg("purging orphaned node metadata failed")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// cleanup cleans up after the upload is finished
|
||||
func (session *OcisSession) Cleanup(revertNodeMetadata, cleanBin, cleanInfo, unmarkPostprocessing bool) {
|
||||
ctx := session.Context(context.Background())
|
||||
|
||||
if revertNodeMetadata {
|
||||
// Revert before removing the bin and info files. Both are needed to
|
||||
// recover from a failure here: the bin file holds the only copy of the
|
||||
// uploaded data as long as the blob has not been written, and the info
|
||||
// file is the only remaining source of the node's parent id once the
|
||||
// node metadata is gone.
|
||||
if err := session.revertNode(ctx); err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("sessionid", session.ID()).Msg("reverting node failed, keeping upload")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if cleanBin {
|
||||
if err := os.Remove(session.binPath()); err != nil && !errors.Is(err, fs.ErrNotExist) {
|
||||
appctx.GetLogger(ctx).Error().Str("path", session.binPath()).Err(err).Msg("removing upload failed")
|
||||
@@ -346,22 +404,6 @@ func (session *OcisSession) Cleanup(revertNodeMetadata, cleanBin, cleanInfo, unm
|
||||
}
|
||||
}
|
||||
|
||||
if revertNodeMetadata {
|
||||
n, err := session.Node(ctx)
|
||||
if err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("sessionid", session.ID()).Msg("reading node for session failed")
|
||||
return
|
||||
}
|
||||
|
||||
curUpload, err := n.ProcessingID(ctx)
|
||||
if err == nil && curUpload == session.ID() {
|
||||
if err := n.RevertCurrentRevision(ctx); err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("nodepath", n.InternalPath()).Msg("reverting node metadata failed")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if unmarkPostprocessing && !revertNodeMetadata { // node reverting automatically unmarks processing
|
||||
n, err := session.Node(ctx)
|
||||
if err != nil {
|
||||
|
||||
+6
-1
@@ -127,10 +127,15 @@ func acquireLock(file string, write bool) (*flock.Flock, error) {
|
||||
}
|
||||
|
||||
if !ok {
|
||||
err = ErrAcquireLockFailed
|
||||
// never actually acquired the OS-level lock; release the local
|
||||
// bookkeeping entry too, or every future call for this path is
|
||||
// permanently wedged regardless of whether the real lock clears
|
||||
releaseMutexedFlock(n)
|
||||
return nil, ErrAcquireLockFailed
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
releaseMutexedFlock(n)
|
||||
return nil, err
|
||||
}
|
||||
return flock, nil
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package metadata
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
// BarrierStorage wraps a Storage and holds Upload calls until n goroutines have
|
||||
// arrived, then releases them all at once, to deterministically reproduce
|
||||
// concurrent-write races in tests.
|
||||
type BarrierStorage struct {
|
||||
Storage
|
||||
arrived int32
|
||||
n int32
|
||||
ready chan struct{}
|
||||
closeOnce sync.Once
|
||||
}
|
||||
|
||||
// NewBarrierStorage returns a BarrierStorage wrapping s that releases once n Upload calls have arrived.
|
||||
func NewBarrierStorage(s Storage, n int) *BarrierStorage {
|
||||
return &BarrierStorage{Storage: s, n: int32(n), ready: make(chan struct{})}
|
||||
}
|
||||
|
||||
// Upload blocks until n calls have arrived, then delegates to the wrapped Storage.
|
||||
func (b *BarrierStorage) Upload(ctx context.Context, req UploadRequest) (*UploadResponse, error) {
|
||||
if atomic.AddInt32(&b.arrived, 1) >= b.n {
|
||||
b.closeOnce.Do(func() { close(b.ready) })
|
||||
}
|
||||
select {
|
||||
case <-b.ready:
|
||||
case <-ctx.Done():
|
||||
return nil, ctx.Err()
|
||||
}
|
||||
return b.Storage.Upload(ctx, req)
|
||||
}
|
||||
-11
@@ -39,7 +39,6 @@ import (
|
||||
"google.golang.org/grpc/metadata"
|
||||
|
||||
"github.com/owncloud/reva/v2/internal/http/services/owncloud/ocdav/net"
|
||||
"github.com/owncloud/reva/v2/pkg/appctx"
|
||||
ctxpkg "github.com/owncloud/reva/v2/pkg/ctx"
|
||||
"github.com/owncloud/reva/v2/pkg/errtypes"
|
||||
"github.com/owncloud/reva/v2/pkg/rgrpc/todo/pool"
|
||||
@@ -65,7 +64,6 @@ type CS3 struct {
|
||||
dataGatewayClient *http.Client
|
||||
}
|
||||
|
||||
|
||||
// NewCS3 returns a new CS3 instance. Use an authenticated context and be sure to define SpaceRoot manually.
|
||||
func NewCS3(gwAddr, providerAddr string) (s *CS3) {
|
||||
return &CS3{
|
||||
@@ -164,8 +162,6 @@ func (cs3 *CS3) SimpleUpload(ctx context.Context, uploadpath string, content []b
|
||||
ctx, span := tracer.Start(ctx, "SimpleUpload")
|
||||
defer span.End()
|
||||
|
||||
log := appctx.GetLogger(ctx)
|
||||
log.Debug().Str("path", uploadpath).Msg("cs3.SimpleUpload.start")
|
||||
_, err := cs3.Upload(ctx, UploadRequest{
|
||||
Path: uploadpath,
|
||||
Content: content,
|
||||
@@ -178,9 +174,6 @@ func (cs3 *CS3) Upload(ctx context.Context, req UploadRequest) (*UploadResponse,
|
||||
ctx, span := tracer.Start(ctx, "Upload")
|
||||
defer span.End()
|
||||
|
||||
log := appctx.GetLogger(ctx)
|
||||
log.Debug().Str("path", req.Path).Msg("cs3.Upload.start")
|
||||
|
||||
client, err := cs3.providerClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -245,8 +238,6 @@ func (cs3 *CS3) Upload(ctx context.Context, req UploadRequest) (*UploadResponse,
|
||||
return nil, errors.New("metadata storage doesn't support the simple upload protocol")
|
||||
}
|
||||
|
||||
log.Debug().Str("path", req.Path).Str("endpoint", endpoint).Msg("cs3.Upload.initiate_done")
|
||||
|
||||
httpReq, err := http.NewRequest(http.MethodPut, endpoint, bytes.NewReader(req.Content))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -262,7 +253,6 @@ func (cs3 *CS3) Upload(ctx context.Context, req UploadRequest) (*UploadResponse,
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
log.Debug().Str("path", req.Path).Int("status", resp.StatusCode).Msg("cs3.Upload.put_done")
|
||||
if err := errtypes.NewErrtypeFromHTTPStatusCode(resp.StatusCode, httpReq.URL.Path); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -270,7 +260,6 @@ func (cs3 *CS3) Upload(ctx context.Context, req UploadRequest) (*UploadResponse,
|
||||
if ocEtag := resp.Header.Get("OC-ETag"); ocEtag != "" {
|
||||
etag = ocEtag
|
||||
}
|
||||
log.Debug().Str("path", req.Path).Str("etag", etag).Msg("cs3.Upload.complete")
|
||||
return &UploadResponse{
|
||||
Etag: etag,
|
||||
FileID: resp.Header.Get("OC-Fileid"),
|
||||
|
||||
+33
-4
@@ -30,7 +30,9 @@ import (
|
||||
|
||||
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
|
||||
typesv1beta1 "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
|
||||
"github.com/google/renameio/v2"
|
||||
"github.com/owncloud/reva/v2/pkg/errtypes"
|
||||
"github.com/owncloud/reva/v2/pkg/storage/utils/filelocks"
|
||||
)
|
||||
|
||||
// Disk represents a disk metadata storage
|
||||
@@ -91,8 +93,22 @@ func (disk *Disk) SimpleUpload(ctx context.Context, uploadpath string, content [
|
||||
}
|
||||
|
||||
// Upload stores a file on disk
|
||||
func (disk *Disk) Upload(_ context.Context, req UploadRequest) (*UploadResponse, error) {
|
||||
func (disk *Disk) Upload(_ context.Context, req UploadRequest) (res *UploadResponse, err error) {
|
||||
p := disk.targetPath(req.Path)
|
||||
|
||||
// Serialize check+write across processes to eliminate the TOCTOU race.
|
||||
lock, err := filelocks.AcquireWriteLock(p)
|
||||
if err != nil {
|
||||
// transient under high write fan-in; classify so callers retry instead of aborting
|
||||
return nil, errtypes.InternalError(fmt.Sprintf("acquiring write lock: %s", err))
|
||||
}
|
||||
defer func() {
|
||||
rerr := filelocks.ReleaseLock(lock)
|
||||
if err == nil {
|
||||
err = rerr
|
||||
}
|
||||
}()
|
||||
|
||||
if req.IfMatchEtag != "" {
|
||||
info, err := os.Stat(p)
|
||||
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
@@ -107,6 +123,14 @@ func (disk *Disk) Upload(_ context.Context, req UploadRequest) (*UploadResponse,
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, v := range req.IfNoneMatch {
|
||||
if v == "*" {
|
||||
if _, err := os.Stat(p); err == nil {
|
||||
return nil, errtypes.AlreadyExists(p)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
if req.IfUnmodifiedSince != (time.Time{}) {
|
||||
info, err := os.Stat(p)
|
||||
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
@@ -117,8 +141,7 @@ func (disk *Disk) Upload(_ context.Context, req UploadRequest) (*UploadResponse,
|
||||
}
|
||||
}
|
||||
}
|
||||
err := os.WriteFile(p, req.Content, 0644)
|
||||
if err != nil {
|
||||
if err := renameio.WriteFile(p, req.Content, 0644); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -126,7 +149,7 @@ func (disk *Disk) Upload(_ context.Context, req UploadRequest) (*UploadResponse,
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res := &UploadResponse{}
|
||||
res = &UploadResponse{}
|
||||
res.Etag, err = calcEtag(info.ModTime(), info.Size())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -160,6 +183,12 @@ func (disk *Disk) Download(_ context.Context, req DownloadRequest) (*DownloadRes
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, etag := range req.IfNoneMatch {
|
||||
if etag == res.Etag {
|
||||
return nil, errtypes.NotModified(req.Path)
|
||||
}
|
||||
}
|
||||
|
||||
res.Content, err = io.ReadAll(f)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
+6
@@ -522,6 +522,12 @@ func (t *http2Server) operateHeaders(ctx context.Context, frame *http2.MetaHeade
|
||||
delete(mdata, "host")
|
||||
}
|
||||
|
||||
// If :authority is still missing, i.e. no host or :authority header is
|
||||
// present, reject the request as invalid.
|
||||
if len(mdata[":authority"]) == 0 {
|
||||
t.writeEarlyAbort(streamID, s.contentSubtype, status.New(codes.Internal, "no host or :authority header present"), http.StatusBadRequest, !frame.StreamEnded())
|
||||
return nil
|
||||
}
|
||||
if frame.StreamEnded() {
|
||||
// s is just created by the caller. No lock needed.
|
||||
s.state = streamReadDone
|
||||
|
||||
+1
-1
@@ -19,4 +19,4 @@
|
||||
package grpc
|
||||
|
||||
// Version is the current grpc version.
|
||||
const Version = "1.83.1"
|
||||
const Version = "1.83.2"
|
||||
Vendored
+2
-2
@@ -1325,7 +1325,7 @@ github.com/orcaman/concurrent-map
|
||||
# github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245
|
||||
## explicit; go 1.18
|
||||
github.com/owncloud/libre-graph-api-go
|
||||
# github.com/owncloud/reva/v2 v2.0.0-20260813081353-3dbd3c2711ea
|
||||
# github.com/owncloud/reva/v2 v2.0.0-20261001074810-94c6e48f5c45
|
||||
## explicit; go 1.24.0
|
||||
github.com/owncloud/reva/v2/cmd/revad/internal/grace
|
||||
github.com/owncloud/reva/v2/cmd/revad/runtime
|
||||
@@ -2419,7 +2419,7 @@ google.golang.org/genproto/googleapis/api/httpbody
|
||||
## explicit; go 1.25.0
|
||||
google.golang.org/genproto/googleapis/rpc/errdetails
|
||||
google.golang.org/genproto/googleapis/rpc/status
|
||||
# google.golang.org/grpc v1.83.1
|
||||
# google.golang.org/grpc v1.83.2
|
||||
## explicit; go 1.25.0
|
||||
google.golang.org/grpc
|
||||
google.golang.org/grpc/attributes
|
||||
|
||||
Reference in new issue
Block a user