Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omit some lookups in gateway #9715

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/unreleased/bump-reva.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enhancement: Bump reva

https://github.com/owncloud/ocis/pull/9715
5 changes: 5 additions & 0 deletions changelog/unreleased/omit-some-lookups-in-gateway.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Gateways should directly talk to themselves

The CS3 gateway can directly to itself when it wants to talk to the registries running in the same reva runtime.

https://github.com/owncloud/ocis/pull/9714
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/coreos/go-oidc/v3 v3.10.0
github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb
github.com/cs3org/reva/v2 v2.22.0
github.com/cs3org/reva/v2 v2.22.1-0.20240730105121-548644c31544
github.com/dhowden/tag v0.0.0-20230630033851-978a0926ee25
github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e
github.com/egirna/icap-client v0.1.1
Expand Down Expand Up @@ -307,6 +307,7 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/segmentio/kafka-go v0.4.47 // indirect
github.com/segmentio/ksuid v1.0.4 // indirect
github.com/sercand/kuberesolver/v5 v5.1.1 // indirect
github.com/sergi/go-diff v1.3.1 // indirect
github.com/sethvargo/go-password v0.2.0 // indirect
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,8 @@ github.com/crewjam/saml v0.4.14 h1:g9FBNx62osKusnFzs3QTN5L9CVA/Egfgm+stJShzw/c=
github.com/crewjam/saml v0.4.14/go.mod h1:UVSZCf18jJkk6GpWNVqcyQJMD5HsRugBPf4I1nl2mME=
github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb h1:KmYZDReplv/yfwc1LNYpDcVhVujC3Pasv6WjXx1haSU=
github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb/go.mod h1:yyP8PRo0EZou3nSH7H4qjlzQwaydPeIRNgX50npQHpE=
github.com/cs3org/reva/v2 v2.22.0 h1:dMZGJDdrTCYYyMlVSzchbEUyFrHgvFI2Md/aLLiez54=
github.com/cs3org/reva/v2 v2.22.0/go.mod h1:y9ujkcxepugOsv50baQSCtudfY5VY5S5eigNTvGfSZI=
github.com/cs3org/reva/v2 v2.22.1-0.20240730105121-548644c31544 h1:cBqx8oou5aXM9SqiG96bYGBD4akYwecPoopsFva51yI=
github.com/cs3org/reva/v2 v2.22.1-0.20240730105121-548644c31544/go.mod h1:R6OO/ZPMr8MivSiESfk7pUfsdXdr709L8kJErLgqvDI=
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
Expand Down Expand Up @@ -1948,6 +1948,8 @@ github.com/segmentio/kafka-go v0.4.47 h1:IqziR4pA3vrZq7YdRxaT3w1/5fvIH5qpCwstUan
github.com/segmentio/kafka-go v0.4.47/go.mod h1:HjF6XbOKh0Pjlkr5GVZxt6CsjjwnmhVOfURM5KMd8qg=
github.com/segmentio/ksuid v1.0.4 h1:sBo2BdShXjmcugAMwjugoGUdUV0pcxY5mW4xKRn3v4c=
github.com/segmentio/ksuid v1.0.4/go.mod h1:/XUiZBD3kVx5SmUOl55voK5yeAbBNNIed+2O73XgrPE=
github.com/sercand/kuberesolver/v5 v5.1.1 h1:CYH+d67G0sGBj7q5wLK61yzqJJ8gLLC8aeprPTHb6yY=
github.com/sercand/kuberesolver/v5 v5.1.1/go.mod h1:Fs1KbKhVRnB2aDWN12NjKCB+RgYMWZJ294T3BtmVCpQ=
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
github.com/sethgrid/pester v1.2.0/go.mod h1:hEUINb4RqvDxtoCaU0BNT/HV4ig5kfgOasrf1xcvr0A=
Expand Down
24 changes: 21 additions & 3 deletions ocis-pkg/config/helpers.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package config

import (
gofig "github.com/gookit/config/v2"
gooyaml "github.com/gookit/config/v2/yaml"
"github.com/owncloud/ocis/v2/ocis-pkg/config/defaults"
"io/fs"
"os"
"path"
"strings"

gofig "github.com/gookit/config/v2"
gooyaml "github.com/gookit/config/v2/yaml"
"github.com/owncloud/ocis/v2/ocis-pkg/config/defaults"
)

var (
Expand Down Expand Up @@ -49,3 +50,20 @@ func bindSourcesToStructs(fileSystem fs.FS, filePath, service string, dst interf

return nil
}

// LocalEndpoint returns the local endpoint for a given protocol and address.
// Use it when configuring the reva runtime to get a service endpoint in the same
// runtime, e.g. a gateway talking to an authregistry service.
func LocalEndpoint(protocol, addr string) string {
localEndpoint := addr
switch protocol {
case "tcp":
parts := strings.SplitN(addr, ":", 2)
if len(parts) == 2 {
localEndpoint = "dns:127.0.0.1:" + parts[1]
}
case "unix":
localEndpoint = "unix:" + addr
}
return localEndpoint
}
7 changes: 5 additions & 2 deletions services/gateway/pkg/revaconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ import (
"strings"

"github.com/cs3org/reva/v2/pkg/utils"
pkgconfig "github.com/owncloud/ocis/v2/ocis-pkg/config"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
"github.com/owncloud/ocis/v2/services/gateway/pkg/config"
)

// GatewayConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service.
func GatewayConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]interface{} {
localEndpoint := pkgconfig.LocalEndpoint(cfg.GRPC.Protocol, cfg.GRPC.Addr)

rcfg := map[string]interface{}{
"core": map[string]interface{}{
"tracing_enabled": cfg.Tracing.Enabled,
Expand Down Expand Up @@ -39,8 +42,8 @@ func GatewayConfigFromStruct(cfg *config.Config, logger log.Logger) map[string]i
"gateway": map[string]interface{}{
"applicationauthsvc": cfg.AuthAppEndpoint,
// registries are located on the gateway
"authregistrysvc": cfg.Reva.Address,
"storageregistrysvc": cfg.Reva.Address,
"authregistrysvc": localEndpoint,
"storageregistrysvc": localEndpoint,
"appregistrysvc": cfg.AppRegistryEndpoint,
// user metadata is located on the users services
"preferencessvc": cfg.UsersEndpoint,
Expand Down
27 changes: 15 additions & 12 deletions services/storage-system/pkg/revaconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ package revaconfig

import (
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
pkgconfig "github.com/owncloud/ocis/v2/ocis-pkg/config"
"github.com/owncloud/ocis/v2/services/storage-system/pkg/config"
)

// StorageSystemFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service.
func StorageSystemFromStruct(cfg *config.Config) map[string]interface{} {
localEndpoint := pkgconfig.LocalEndpoint(cfg.GRPC.Protocol, cfg.GRPC.Addr)

rcfg := map[string]interface{}{
"shared": map[string]interface{}{
"jwt_secret": cfg.TokenManager.JWTSecret,
Expand All @@ -25,12 +28,12 @@ func StorageSystemFromStruct(cfg *config.Config) map[string]interface{} {
"services": map[string]interface{}{
"gateway": map[string]interface{}{
// registries are located on the gateway
"authregistrysvc": "com.owncloud.api.storage-system",
"storageregistrysvc": "com.owncloud.api.storage-system",
"authregistrysvc": localEndpoint,
"storageregistrysvc": localEndpoint,
// user metadata is located on the users services
"userprovidersvc": "com.owncloud.api.storage-system",
"groupprovidersvc": "com.owncloud.api.storage-system",
"permissionssvc": "com.owncloud.api.storage-system",
"userprovidersvc": localEndpoint,
"groupprovidersvc": localEndpoint,
"permissionssvc": localEndpoint,
// other
"disable_home_creation_on_login": true, // metadata manually creates a space
// metadata always uses the simple upload, so no transfer secret or datagateway needed
Expand Down Expand Up @@ -60,7 +63,7 @@ func StorageSystemFromStruct(cfg *config.Config) map[string]interface{} {
"drivers": map[string]interface{}{
"static": map[string]interface{}{
"rules": map[string]interface{}{
"machine": "com.owncloud.api.storage-system",
"machine": localEndpoint,
},
},
},
Expand All @@ -70,7 +73,7 @@ func StorageSystemFromStruct(cfg *config.Config) map[string]interface{} {
"auth_managers": map[string]interface{}{
"machine": map[string]interface{}{
"api_key": cfg.SystemUserAPIKey,
"gateway_addr": "com.owncloud.api.storage-system",
"gateway_addr": localEndpoint,
},
},
},
Expand All @@ -86,15 +89,15 @@ func StorageSystemFromStruct(cfg *config.Config) map[string]interface{} {
"static": map[string]interface{}{
"rules": map[string]interface{}{
"/": map[string]interface{}{
"address": "com.owncloud.api.storage-system",
"address": localEndpoint,
},
},
},
},
},
"storageprovider": map[string]interface{}{
"driver": cfg.Driver,
"drivers": metadataDrivers(cfg),
"drivers": metadataDrivers(localEndpoint, cfg),
"data_server_url": cfg.DataServerURL,
},
},
Expand All @@ -113,7 +116,7 @@ func StorageSystemFromStruct(cfg *config.Config) map[string]interface{} {
"dataprovider": map[string]interface{}{
"prefix": "data",
"driver": cfg.Driver,
"drivers": metadataDrivers(cfg),
"drivers": metadataDrivers(localEndpoint, cfg),
"data_txs": map[string]interface{}{
"simple": map[string]interface{}{
"cache_store": "noop",
Expand Down Expand Up @@ -144,15 +147,15 @@ func StorageSystemFromStruct(cfg *config.Config) map[string]interface{} {
return rcfg
}

func metadataDrivers(cfg *config.Config) map[string]interface{} {
func metadataDrivers(localEndpoint string, cfg *config.Config) map[string]interface{} {
return map[string]interface{}{
"ocis": map[string]interface{}{
"metadata_backend": cfg.Drivers.OCIS.MetadataBackend,
"root": cfg.Drivers.OCIS.Root,
"user_layout": "{{.Id.OpaqueId}}",
"treetime_accounting": false,
"treesize_accounting": false,
"permissionssvc": "com.owncloud.api.storage-system",
"permissionssvc": localEndpoint,
"max_acquire_lock_cycles": cfg.Drivers.OCIS.MaxAcquireLockCycles,
"lock_cycle_duration_factor": cfg.Drivers.OCIS.LockCycleDurationFactor,
"disable_versioning": true,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 25 additions & 3 deletions vendor/github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool/connection.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 28 additions & 8 deletions vendor/github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool/selector.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions vendor/github.com/cs3org/reva/v2/pkg/trace/trace.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/sercand/kuberesolver/v5/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading