From 0b448f6e0299e76c35e35845d9169821d7bf5657 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 10:31:30 +0100 Subject: [PATCH 01/24] refactor accounts tracing and server method --- accounts/pkg/command/server.go | 158 +++++++++----------------------- accounts/pkg/tracing/tracing.go | 90 ++++++++++++++++++ 2 files changed, 132 insertions(+), 116 deletions(-) create mode 100644 accounts/pkg/tracing/tracing.go diff --git a/accounts/pkg/command/server.go b/accounts/pkg/command/server.go index 7228316e9d6..5e0ce5f332b 100644 --- a/accounts/pkg/command/server.go +++ b/accounts/pkg/command/server.go @@ -3,25 +3,18 @@ package command import ( "context" "strings" - "time" "github.com/owncloud/ocis/ocis-pkg/sync" - "contrib.go.opencensus.io/exporter/jaeger" - "contrib.go.opencensus.io/exporter/ocagent" - "contrib.go.opencensus.io/exporter/zipkin" "github.com/micro/cli/v2" "github.com/oklog/run" - openzipkin "github.com/openzipkin/zipkin-go" - zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" "github.com/owncloud/ocis/accounts/pkg/config" "github.com/owncloud/ocis/accounts/pkg/flagset" "github.com/owncloud/ocis/accounts/pkg/metrics" "github.com/owncloud/ocis/accounts/pkg/server/grpc" "github.com/owncloud/ocis/accounts/pkg/server/http" svc "github.com/owncloud/ocis/accounts/pkg/service/v0" - "go.opencensus.io/stats/view" - "go.opencensus.io/trace" + "github.com/owncloud/ocis/accounts/pkg/tracing" ) // Server is the entry point for the server command. @@ -47,87 +40,13 @@ func Server(cfg *config.Config) *cli.Command { }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - exporter, err := ocagent.NewExporter( - ocagent.WithReconnectionPeriod(5*time.Second), - ocagent.WithAddress(cfg.Tracing.Endpoint), - ocagent.WithServiceName(cfg.Tracing.Service), - ) - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create agent tracing") - return err - } - trace.RegisterExporter(exporter) - view.RegisterExporter(exporter) - case "jaeger": - exporter, err := jaeger.NewExporter( - jaeger.Options{ - AgentEndpoint: cfg.Tracing.Endpoint, - CollectorEndpoint: cfg.Tracing.Collector, - Process: jaeger.Process{ - ServiceName: cfg.Tracing.Service, - }, - }, - ) - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create jaeger tracing") - return err - } - trace.RegisterExporter(exporter) - case "zipkin": - endpoint, err := openzipkin.NewEndpoint( - cfg.Tracing.Service, - cfg.Tracing.Endpoint, - ) - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create zipkin tracing") - return err - } - exporter := zipkin.NewExporter( - zipkinhttp.NewReporter( - cfg.Tracing.Collector, - ), - endpoint, - ) - trace.RegisterExporter(exporter) - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - trace.ApplyConfig( - trace.Config{ - DefaultSampler: trace.AlwaysSample(), - }, - ) - } else { - logger.Debug(). - Msg("Tracing is not enabled") + err := tracing.Configure(cfg, logger) + if err != nil { + return err } - var ( - gr = run.Group{} - ctx, cancel = func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() - mtrcs = metrics.New() - ) + gr := run.Group{} + ctx, cancel := defineContext(cfg) + mtrcs := metrics.New() defer cancel() @@ -139,37 +58,33 @@ func Server(cfg *config.Config) *cli.Command { return err } - { - server := http.Server( - http.Logger(logger), - http.Name(cfg.Server.Name), - http.Context(ctx), - http.Config(cfg), - http.Metrics(mtrcs), - http.Handler(handler), - ) + httpServer := http.Server( + http.Config(cfg), + http.Logger(logger), + http.Name(cfg.Server.Name), + http.Context(ctx), + http.Metrics(mtrcs), + http.Handler(handler), + ) - gr.Add(server.Run, func(_ error) { - logger.Info().Str("server", "http").Msg("Shutting down server") - cancel() - }) - } + gr.Add(httpServer.Run, func(_ error) { + logger.Info().Str("server", "http").Msg("shutting down server") + cancel() + }) - { - server := grpc.Server( - grpc.Logger(logger), - grpc.Name(cfg.Server.Name), - grpc.Context(ctx), - grpc.Config(cfg), - grpc.Metrics(mtrcs), - grpc.Handler(handler), - ) + grpcServer := grpc.Server( + grpc.Config(cfg), + grpc.Logger(logger), + grpc.Name(cfg.Server.Name), + grpc.Context(ctx), + grpc.Metrics(mtrcs), + grpc.Handler(handler), + ) - gr.Add(server.Run, func(_ error) { - logger.Info().Str("server", "grpc").Msg("Shutting down server") - cancel() - }) - } + gr.Add(grpcServer.Run, func(_ error) { + logger.Info().Str("server", "grpc").Msg("shutting down server") + cancel() + }) if !cfg.Supervised { sync.Trap(&gr, cancel) @@ -179,3 +94,14 @@ func Server(cfg *config.Config) *cli.Command { }, } } + +// defineContext sets the context for the extension. If there is a context configured it will create a new child from it, +// if not, it will create a root context that can be cancelled. +func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) { + return func() (context.Context, context.CancelFunc) { + if cfg.Context == nil { + return context.WithCancel(context.Background()) + } + return context.WithCancel(cfg.Context) + }() +} diff --git a/accounts/pkg/tracing/tracing.go b/accounts/pkg/tracing/tracing.go new file mode 100644 index 00000000000..d16ded696fa --- /dev/null +++ b/accounts/pkg/tracing/tracing.go @@ -0,0 +1,90 @@ +package tracing + +import ( + "time" + + "contrib.go.opencensus.io/exporter/jaeger" + "contrib.go.opencensus.io/exporter/ocagent" + "contrib.go.opencensus.io/exporter/zipkin" + openzipkin "github.com/openzipkin/zipkin-go" + zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" + "github.com/owncloud/ocis/accounts/pkg/config" + "github.com/owncloud/ocis/ocis-pkg/log" + "go.opencensus.io/stats/view" + "go.opencensus.io/trace" +) + +func Configure(cfg *config.Config, logger log.Logger) error { + if cfg.Tracing.Enabled { + switch t := cfg.Tracing.Type; t { + case "agent": + exporter, err := ocagent.NewExporter( + ocagent.WithReconnectionPeriod(5*time.Second), + ocagent.WithAddress(cfg.Tracing.Endpoint), + ocagent.WithServiceName(cfg.Tracing.Service), + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create agent tracing") + return err + } + trace.RegisterExporter(exporter) + view.RegisterExporter(exporter) + case "jaeger": + exporter, err := jaeger.NewExporter( + jaeger.Options{ + AgentEndpoint: cfg.Tracing.Endpoint, + CollectorEndpoint: cfg.Tracing.Collector, + Process: jaeger.Process{ + ServiceName: cfg.Tracing.Service, + }, + }, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create jaeger tracing") + return err + } + trace.RegisterExporter(exporter) + case "zipkin": + endpoint, err := openzipkin.NewEndpoint( + cfg.Tracing.Service, + cfg.Tracing.Endpoint, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create zipkin tracing") + return err + } + exporter := zipkin.NewExporter( + zipkinhttp.NewReporter( + cfg.Tracing.Collector, + ), + endpoint, + ) + trace.RegisterExporter(exporter) + default: + logger.Warn(). + Str("type", t). + Msg("Unknown tracing backend") + } + trace.ApplyConfig( + trace.Config{ + DefaultSampler: trace.AlwaysSample(), + }, + ) + } else { + logger.Debug(). + Msg("Tracing is not enabled") + } + return nil +} From 0092c749595245de6e20280a6030ca075c56051c Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 10:50:54 +0100 Subject: [PATCH 02/24] refactor a reva storage tracing config --- storage/pkg/command/frontend.go | 370 +++++++++++++++----------------- storage/pkg/tracing/tracing.go | 38 ++++ 2 files changed, 207 insertions(+), 201 deletions(-) create mode 100644 storage/pkg/tracing/tracing.go diff --git a/storage/pkg/command/frontend.go b/storage/pkg/command/frontend.go index 237f927d25b..bfbd4c48a11 100644 --- a/storage/pkg/command/frontend.go +++ b/storage/pkg/command/frontend.go @@ -8,17 +8,17 @@ import ( "path" "strings" - "github.com/owncloud/ocis/ocis-pkg/sync" - "github.com/cs3org/reva/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/micro/cli/v2" "github.com/oklog/run" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/conversions" + "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" + "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" ) @@ -36,215 +36,51 @@ func Frontend(cfg *config.Config) *cli.Command { Action: func(c *cli.Context) error { logger := NewLogger(cfg) - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - logger.Error(). - Str("type", t). - Msg("Reva only supports the jaeger tracing backend") - - case "jaeger": - logger.Info(). - Str("type", t). - Msg("configuring storage to use the jaeger tracing backend") - - case "zipkin": - logger.Error(). - Str("type", t). - Msg("Reva only supports the jaeger tracing backend") - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - } else { - logger.Debug(). - Msg("Tracing is not enabled") - } + tracing.Configure(cfg, logger) - var ( - gr = run.Group{} - ctx, cancel = context.WithCancel(context.Background()) - //metrics = metrics.New() - ) + gr := run.Group{} + ctx, cancel := context.WithCancel(context.Background()) + //metrics = metrics.New() defer cancel() - { - uuid := uuid.Must(uuid.NewV4()) - pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") - - // pregenerate list of valid localhost ports for the desktop redirect_uri - // TODO use custom scheme like "owncloud://localhost/user/callback" tracked in - var desktopRedirectURIs [65535 - 1024]string - for port := 0; port < len(desktopRedirectURIs); port++ { - desktopRedirectURIs[port] = fmt.Sprintf("http://localhost:%d", (port + 1024)) - } + uuid := uuid.Must(uuid.NewV4()) + pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") - filesCfg := map[string]interface{}{ - "private_links": false, - "bigfilechunking": false, - "blacklisted_files": []string{}, - "undelete": true, - "versioning": true, - } + // pregenerate list of valid localhost ports for the desktop redirect_uri + // TODO use custom scheme like "owncloud://localhost/user/callback" tracked in + var desktopRedirectURIs [65535 - 1024]string + for port := 0; port < len(desktopRedirectURIs); port++ { + desktopRedirectURIs[port] = fmt.Sprintf("http://localhost:%d", (port + 1024)) + } - if cfg.Reva.DefaultUploadProtocol == "tus" { - filesCfg["tus_support"] = map[string]interface{}{ - "version": "1.0.0", - "resumable": "1.0.0", - "extension": "creation,creation-with-upload", - "http_method_override": cfg.Reva.UploadHTTPMethodOverride, - "max_chunk_size": int(cfg.Reva.UploadMaxChunkSize), - } - } + filesCfg := map[string]interface{}{ + "private_links": false, + "bigfilechunking": false, + "blacklisted_files": []string{}, + "undelete": true, + "versioning": true, + } - rcfg := map[string]interface{}{ - "core": map[string]interface{}{ - "max_cpus": cfg.Reva.Users.MaxCPUs, - "tracing_enabled": cfg.Tracing.Enabled, - "tracing_endpoint": cfg.Tracing.Endpoint, - "tracing_collector": cfg.Tracing.Collector, - "tracing_service_name": c.Command.Name, - }, - "shared": map[string]interface{}{ - "jwt_secret": cfg.Reva.JWTSecret, - "gatewaysvc": cfg.Reva.Gateway.Endpoint, // Todo or address? - }, - "http": map[string]interface{}{ - "network": cfg.Reva.Frontend.HTTPNetwork, - "address": cfg.Reva.Frontend.HTTPAddr, - "middlewares": map[string]interface{}{ - "cors": map[string]interface{}{ - "allow_credentials": true, - }, - "auth": map[string]interface{}{ - "credentials_by_user_agent": cfg.Reva.Frontend.Middleware.Auth.CredentialsByUserAgent, - }, - }, - // TODO build services dynamically - "services": map[string]interface{}{ - "datagateway": map[string]interface{}{ - "prefix": cfg.Reva.Frontend.DatagatewayPrefix, - "transfer_shared_secret": cfg.Reva.TransferSecret, - "timeout": 86400, - "insecure": true, - }, - "ocdav": map[string]interface{}{ - "prefix": cfg.Reva.Frontend.OCDavPrefix, - "files_namespace": cfg.Reva.OCDav.DavFilesNamespace, - "webdav_namespace": cfg.Reva.OCDav.WebdavNamespace, - "timeout": 86400, - "insecure": true, - }, - "ocs": map[string]interface{}{ - "share_prefix": cfg.Reva.Frontend.OCSSharePrefix, - "prefix": cfg.Reva.Frontend.OCSPrefix, - "config": map[string]interface{}{ - "version": "1.8", - "website": "reva", - "host": cfg.Reva.Frontend.PublicURL, - "contact": "admin@localhost", - "ssl": "false", - }, - "default_upload_protocol": cfg.Reva.DefaultUploadProtocol, - "capabilities": map[string]interface{}{ - "capabilities": map[string]interface{}{ - "core": map[string]interface{}{ - "poll_interval": 60, - "webdav_root": "remote.php/webdav", - "status": map[string]interface{}{ - "installed": true, - "maintenance": false, - "needsDbUpgrade": false, - "version": "10.0.11.5", - "versionstring": "10.0.11", - "edition": "community", - "productname": "reva", - "hostname": "", - }, - "support_url_signing": true, - }, - "checksums": map[string]interface{}{ - "supported_types": cfg.Reva.ChecksumSupportedTypes, - "preferred_upload_type": cfg.Reva.ChecksumPreferredUploadType, - }, - "files": filesCfg, - "dav": map[string]interface{}{}, - "files_sharing": map[string]interface{}{ - "api_enabled": true, - "resharing": true, - "group_sharing": true, - "auto_accept_share": true, - "share_with_group_members_only": true, - "share_with_membership_groups_only": true, - "default_permissions": 22, - "search_min_length": 3, - "public": map[string]interface{}{ - "enabled": true, - "send_mail": true, - "social_share": true, - "upload": true, - "multiple": true, - "supports_upload_only": true, - "password": map[string]interface{}{ - "enforced": true, - "enforced_for": map[string]interface{}{ - "read_only": true, - "read_write": true, - "upload_only": true, - }, - }, - "expire_date": map[string]interface{}{ - "enabled": false, - }, - }, - "user": map[string]interface{}{ - "send_mail": true, - }, - "user_enumeration": map[string]interface{}{ - "enabled": true, - "group_members_only": true, - }, - "federation": map[string]interface{}{ - "outgoing": true, - "incoming": true, - }, - }, - "notifications": map[string]interface{}{ - "endpoints": []string{"disable"}, - }, - }, - "version": map[string]interface{}{ - "edition": "reva", - "major": 10, - "minor": 0, - "micro": 11, - "string": "10.0.11", - }, - }, - }, - }, - }, + if cfg.Reva.DefaultUploadProtocol == "tus" { + filesCfg["tus_support"] = map[string]interface{}{ + "version": "1.0.0", + "resumable": "1.0.0", + "extension": "creation,creation-with-upload", + "http_method_override": cfg.Reva.UploadHTTPMethodOverride, + "max_chunk_size": cfg.Reva.UploadMaxChunkSize, } + } - gr.Add(func() error { - runtime.RunWithOptions( - rcfg, - pidFile, - runtime.WithLogger(&logger.Logger), - ) - return nil - }, func(_ error) { - logger.Info(). - Str("server", c.Command.Name). - Msg("Shutting down server") + revaCfg := revaConfigFromStruct(c, cfg, filesCfg) - cancel() - }) - } + gr.Add(func() error { + runtime.RunWithOptions(revaCfg, pidFile, runtime.WithLogger(&logger.Logger)) + return nil + }, func(_ error) { + logger.Info().Str("server", c.Command.Name).Msg("Shutting down server") + cancel() + }) { server, err := debug.Server( @@ -278,6 +114,138 @@ func Frontend(cfg *config.Config) *cli.Command { } } +// revaConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service. +func revaConfigFromStruct(c *cli.Context, cfg *config.Config, filesCfg map[string]interface{}) map[string]interface{} { + return map[string]interface{}{ + "core": map[string]interface{}{ + "max_cpus": cfg.Reva.Users.MaxCPUs, + "tracing_enabled": cfg.Tracing.Enabled, + "tracing_endpoint": cfg.Tracing.Endpoint, + "tracing_collector": cfg.Tracing.Collector, + "tracing_service_name": c.Command.Name, + }, + "shared": map[string]interface{}{ + "jwt_secret": cfg.Reva.JWTSecret, + "gatewaysvc": cfg.Reva.Gateway.Endpoint, // Todo or address? + }, + "http": map[string]interface{}{ + "network": cfg.Reva.Frontend.HTTPNetwork, + "address": cfg.Reva.Frontend.HTTPAddr, + "middlewares": map[string]interface{}{ + "cors": map[string]interface{}{ + "allow_credentials": true, + }, + "auth": map[string]interface{}{ + "credentials_by_user_agent": cfg.Reva.Frontend.Middleware.Auth.CredentialsByUserAgent, + }, + }, + // TODO build services dynamically + "services": map[string]interface{}{ + "datagateway": map[string]interface{}{ + "prefix": cfg.Reva.Frontend.DatagatewayPrefix, + "transfer_shared_secret": cfg.Reva.TransferSecret, + "timeout": 86400, + "insecure": true, + }, + "ocdav": map[string]interface{}{ + "prefix": cfg.Reva.Frontend.OCDavPrefix, + "files_namespace": cfg.Reva.OCDav.DavFilesNamespace, + "webdav_namespace": cfg.Reva.OCDav.WebdavNamespace, + "timeout": 86400, + "insecure": true, + }, + "ocs": map[string]interface{}{ + "share_prefix": cfg.Reva.Frontend.OCSSharePrefix, + "prefix": cfg.Reva.Frontend.OCSPrefix, + "config": map[string]interface{}{ + "version": "1.8", + "website": "reva", + "host": cfg.Reva.Frontend.PublicURL, + "contact": "admin@localhost", + "ssl": "false", + }, + "default_upload_protocol": cfg.Reva.DefaultUploadProtocol, + "capabilities": map[string]interface{}{ + "capabilities": map[string]interface{}{ + "core": map[string]interface{}{ + "poll_interval": 60, + "webdav_root": "remote.php/webdav", + "status": map[string]interface{}{ + "installed": true, + "maintenance": false, + "needsDbUpgrade": false, + "version": "10.0.11.5", + "versionstring": "10.0.11", + "edition": "community", + "productname": "reva", + "hostname": "", + }, + "support_url_signing": true, + }, + "checksums": map[string]interface{}{ + "supported_types": cfg.Reva.ChecksumSupportedTypes, + "preferred_upload_type": cfg.Reva.ChecksumPreferredUploadType, + }, + "files": filesCfg, + "dav": map[string]interface{}{}, + "files_sharing": map[string]interface{}{ + "api_enabled": true, + "resharing": true, + "group_sharing": true, + "auto_accept_share": true, + "share_with_group_members_only": true, + "share_with_membership_groups_only": true, + "default_permissions": 22, + "search_min_length": 3, + "public": map[string]interface{}{ + "enabled": true, + "send_mail": true, + "social_share": true, + "upload": true, + "multiple": true, + "supports_upload_only": true, + "password": map[string]interface{}{ + "enforced": true, + "enforced_for": map[string]interface{}{ + "read_only": true, + "read_write": true, + "upload_only": true, + }, + }, + "expire_date": map[string]interface{}{ + "enabled": false, + }, + }, + "user": map[string]interface{}{ + "send_mail": true, + }, + "user_enumeration": map[string]interface{}{ + "enabled": true, + "group_members_only": true, + }, + "federation": map[string]interface{}{ + "outgoing": true, + "incoming": true, + }, + }, + "notifications": map[string]interface{}{ + "endpoints": []string{"disable"}, + }, + }, + "version": map[string]interface{}{ + "edition": "reva", + "major": 10, + "minor": 0, + "micro": 11, + "string": "10.0.11", + }, + }, + }, + }, + }, + } +} + // loadUserAgent reads the user-agent-whitelist-lock-in, since it is a string flag, and attempts to construct a map of // "user-agent":"challenge" locks in for Reva. // Modifies cfg. Spaces don't need to be trimmed as urfavecli takes care of it. User agents with spaces are valid. i.e: diff --git a/storage/pkg/tracing/tracing.go b/storage/pkg/tracing/tracing.go new file mode 100644 index 00000000000..2670283e806 --- /dev/null +++ b/storage/pkg/tracing/tracing.go @@ -0,0 +1,38 @@ +package tracing + +import ( + "github.com/owncloud/ocis/ocis-pkg/log" + "github.com/owncloud/ocis/storage/pkg/config" +) + +// Configure for Reva serves only as informational / instructive log messages. Tracing config will be delegated directly +// to Reva services. +func Configure(cfg *config.Config, logger log.Logger) { + if cfg.Tracing.Enabled { + switch t := cfg.Tracing.Type; t { + case "agent": + logger.Error(). + Str("type", t). + Msg("Reva only supports the jaeger tracing backend") + + case "jaeger": + logger.Info(). + Str("type", t). + Msg("configuring storage to use the jaeger tracing backend") + + case "zipkin": + logger.Error(). + Str("type", t). + Msg("Reva only supports the jaeger tracing backend") + + default: + logger.Warn(). + Str("type", t). + Msg("Unknown tracing backend") + } + + } else { + logger.Debug(). + Msg("Tracing is not enabled") + } +} From 9dd2cfa2e97bbecf769870c14de0e3c06795e855 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 10:57:15 +0100 Subject: [PATCH 03/24] refactor a authbearer storage tracing config --- graph-explorer/go.mod | 2 + graph-explorer/go.sum | 37 +++++++ graph/go.mod | 2 + graph/go.sum | 34 ++++++ storage/pkg/command/authbearer.go | 174 ++++++++++++------------------ storage/pkg/command/frontend.go | 6 +- 6 files changed, 149 insertions(+), 106 deletions(-) diff --git a/graph-explorer/go.mod b/graph-explorer/go.mod index 43e16d2f2cc..537ef9be7a8 100644 --- a/graph-explorer/go.mod +++ b/graph-explorer/go.mod @@ -13,7 +13,9 @@ require ( github.com/oklog/run v1.1.0 github.com/openzipkin/zipkin-go v0.2.5 github.com/owncloud/ocis/ocis-pkg v0.0.0-20210216094451-dc73176dc62d + github.com/prometheus/client_golang v1.7.1 github.com/spf13/viper v1.7.1 + github.com/thejerf/suture/v4 v4.0.0 go.opencensus.io v0.23.0 golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect golang.org/x/mod v0.4.1 // indirect diff --git a/graph-explorer/go.sum b/graph-explorer/go.sum index da8fc249299..59e12e709d0 100644 --- a/graph-explorer/go.sum +++ b/graph-explorer/go.sum @@ -68,6 +68,7 @@ github.com/Azure/go-autorest/autorest/to v0.2.0/go.mod h1:GunWKJp1AEqgMaGLV+iocm github.com/Azure/go-autorest/autorest/validation v0.1.0/go.mod h1:Ha3z/SqBeaalWQvokg3NZAlQTalVMtOIAs1aGK7G6u8= github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= github.com/Azure/go-autorest/tracing v0.1.0/go.mod h1:ROEEAFwXycQw7Sn3DXNtEedEvdeRAgDr0izn4z5Ij88= +github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c h1:/IBSNwUN8+eKzUzbJPqhK839ygXJ82sde8x3ogr6R28= github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -161,6 +162,7 @@ github.com/aws/aws-sdk-go v1.37.3/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zK github.com/aws/aws-sdk-go v1.37.10/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-xray-sdk-go v0.9.4/go.mod h1:XtMKdBQfpVut+tJEwI7+dJFRxxRdxHDyVNp2tHXRq04= github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc= +github.com/beevik/etree v1.1.0 h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs= github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A= github.com/beevik/ntp v0.2.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg= github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -271,7 +273,9 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/crewjam/httperr v0.0.0-20190612203328-a946449404da/go.mod h1:+rmNIXRvYMqLQeR4DHyTvs6y0MEMymTz4vyFpFkKTPs= +github.com/crewjam/httperr v0.2.0 h1:b2BfXR8U3AlIHwNeFFvZ+BV1LFvKLlzMjzaTnZMybNo= github.com/crewjam/httperr v0.2.0/go.mod h1:Jlz+Sg/XqBQhyMjdDiC+GNNRzZTD7x39Gu3pglZ5oH4= +github.com/crewjam/saml v0.4.0 h1:gvSlboe4BO1APaU2eDdsbql3itRat310Q5qs2Seim2k= github.com/crewjam/saml v0.4.0/go.mod h1:geQUbAAwmTKNJFDzoXaTssZHY26O89PHIm3K3YWjWnI= github.com/cs3org/cato v0.0.0-20200626150132-28a40e643719/go.mod h1:XJEZ3/EQuI3BXTp/6DUzFr850vlxq11I6satRtz0YQ4= github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e/go.mod h1:XJEZ3/EQuI3BXTp/6DUzFr850vlxq11I6satRtz0YQ4= @@ -293,8 +297,10 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9/go.mod h1:GgB8SF9nRG+GqaDtLcwJZsQFhcogVCJ79j4EdT0c2V4= +github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ= github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= github.com/decker502/dnspod-go v0.2.0/go.mod h1:qsurYu1FgxcDwfSwXJdLt4kRsBLZeosEb9uq4Sy+08g= +github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= github.com/dgraph-io/ristretto v0.0.1/go.mod h1:T40EBc7CJke8TkpiYfGGKAeFjSaxuFXhuXRyumBd6RE= github.com/dgraph-io/ristretto v0.0.2/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= @@ -327,6 +333,7 @@ github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/eternnoir/gncp v0.0.0-20170707042257-c70df2d0cd68 h1:DHBMBKJK69xBWnD/jNkTN0sOT7nT7I5If9VMsk9Jj5Y= github.com/eternnoir/gncp v0.0.0-20170707042257-c70df2d0cd68/go.mod h1:8FuQ7lU9ZvIJGvc04F/qblkjqIfBahAoEFV+XPxByGw= github.com/evanphx/json-patch/v5 v5.0.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= github.com/eventials/go-tus v0.0.0-20200718001131-45c7ec8f5d59/go.mod h1:XYuK1S5+kS6FGhlIUFuZFPvWiSrOIoLk6+ro33Xce3Y= @@ -362,6 +369,7 @@ github.com/go-acme/lego/v3 v3.3.0/go.mod h1:iGSY2vQrvQs3WezicSB/oVbO2eCrD88dpWPw github.com/go-acme/lego/v3 v3.4.0/go.mod h1:xYbLDuxq3Hy4bMUT1t9JIuz6GWIWb3m5X+TeTHYaT7M= github.com/go-asn1-ber/asn1-ber v1.3.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0= github.com/go-asn1-ber/asn1-ber v1.4.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0= +github.com/go-asn1-ber/asn1-ber v1.5.1 h1:pDbRAunXzIUXfx4CB2QJFv5IuPiuoW+sWvr/Us009o8= github.com/go-asn1-ber/asn1-ber v1.5.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0= github.com/go-bindata/go-bindata v3.1.1+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo= github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= @@ -386,6 +394,7 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-ldap/ldap/v3 v3.1.7/go.mod h1:5Zun81jBTabRaI8lzN7E1JjyEl1g6zI6u9pd8luAK4Q= github.com/go-ldap/ldap/v3 v3.2.3/go.mod h1:iYS1MdmrmceOJ1QOTnRXrIs7i3kloqtmGQjRvjKpyMg= +github.com/go-ldap/ldap/v3 v3.2.4 h1:PFavAq2xTgzo/loE8qNXcQaofAaqIpI4WgaLdv+1l3E= github.com/go-ldap/ldap/v3 v3.2.4/go.mod h1:iYS1MdmrmceOJ1QOTnRXrIs7i3kloqtmGQjRvjKpyMg= github.com/go-log/log v0.1.0/go.mod h1:4mBwpdRMFLiuXZDCwU2lKQFsoSCo72j3HqBK9d81N2M= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= @@ -709,6 +718,7 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-jsonnet v0.16.0/go.mod h1:sOcuej3UW1vpPTZOr8L7RQimqai1a57bt5j22LzGZCw= +github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -745,9 +755,11 @@ github.com/gorilla/mux v1.7.0/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/pat v0.0.0-20180118222023-199c85a7f6d1/go.mod h1:YeAe0gNeiNT5hoiZRI4yiOky6jVdNvfO2N6Kav/HmxY= github.com/gorilla/schema v1.1.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= +github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc= github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/sessions v1.1.2/go.mod h1:8KCfur6+4Mqcc6S0FEfKuN15Vl5MgXW92AE8ovaJD0w= @@ -862,6 +874,7 @@ github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhB github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901/go.mod h1:Z86h9688Y0wesXCyonoVr47MasHilkuLMqGhRZ4Hpak= github.com/joho/godotenv v1.2.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= +github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/joncalhoun/qson v0.0.0-20170526102502-8a9cab3a62b1/go.mod h1:DFXrEwSRX0p/aSvxE21319menCBFeQO0jXpRj7LEZUA= github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -1000,6 +1013,7 @@ github.com/mattn/goveralls v0.0.5/go.mod h1:Xg2LHi51faXLyKXwsndxiW6uxEEQT9+3sjGz github.com/mattn/goveralls v0.0.6/go.mod h1:h8b4ow6FxSPMQHF6o2ve3qsclnffZjYTNEKmLesRwqw= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103 h1:Z/i1e+gTZrmcGeZyWckaLfucYG6KYOXLWo4co8pZYNY= github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103/go.mod h1:o9YPB5aGP8ob35Vy6+vyq3P3bWe7NQWzf+JLiXCiMaE= github.com/mennanov/fieldmask-utils v0.3.3/go.mod h1:OcOWam4DG685inAjtNuFONKpkitiCCK1W5yKljvWwCY= github.com/mholt/certmagic v0.7.5/go.mod h1:91uJzK5K8IWtYQqTi5R2tsxV1pCde+wdGfaRaOZi6aQ= @@ -1155,6 +1169,7 @@ github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnh github.com/openzipkin/zipkin-go v0.2.5 h1:UwtQQx2pyPIgWYHRg+epgdx1/HnBQTgN3/oIYEJTQzU= github.com/openzipkin/zipkin-go v0.2.5/go.mod h1:KpXfKdgRDnnhsxw4pNIH9Md5lyFqKUa4YDFlwRYAMyE= github.com/oracle/oci-go-sdk v7.0.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888= +github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6 h1:lNCW6THrCKBiJBpz8kbVGjC7MgdCGKwuvBgc7LoD6sw= github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI= github.com/ory/analytics-go/v4 v4.0.0/go.mod h1:FMx9cLRD9xN+XevPvZ5FDMfignpmcqPP6FUKnJ9/MmE= github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= @@ -1190,21 +1205,33 @@ github.com/owncloud/ocis-pkg/v2 v2.4.0/go.mod h1:FSzIvhx9HcZcq4jgNaDowNvM7PTX/XC github.com/owncloud/ocis-pkg/v2 v2.4.1-0.20200902134813-1e87c6173ada/go.mod h1:WdcVM54z0X7aQzS8eyGl7S5sjEMVBtLpfpzsPX3Z+Pw= github.com/owncloud/ocis-settings v0.3.2-0.20200828091056-47af10a0e872/go.mod h1:vRge9QDkOsc6j76gPBmZs1Z5uOPrV4DIkZCgZCEFwBA= github.com/owncloud/ocis/accounts v0.5.3-0.20201103104733-ff2c41028d9b/go.mod h1:IX7T4MJ1U8Y4z9dfDW1J2jq1nv/SHCM7n2zt1fmBHI8= +github.com/owncloud/ocis/accounts v0.5.3-0.20210216094451-dc73176dc62d h1:ldnujTsp0KoVxsU3NlBN8kEkHuoRC8BDsZNN7digIoA= github.com/owncloud/ocis/accounts v0.5.3-0.20210216094451-dc73176dc62d/go.mod h1:OnkGCXo0/ka3o2gwb1jj4pml9X2p769deD0lL66QmrQ= +github.com/owncloud/ocis/glauth v0.0.0-20210216094451-dc73176dc62d h1:gV4N4hAx0FGXWtNSgQf5kRN+6q/LJ592PpyYCMOCNvQ= github.com/owncloud/ocis/glauth v0.0.0-20210216094451-dc73176dc62d/go.mod h1:Xv/WMORry6e4nNDV7G70ruQ8gYPRvxKAWas/E5RMz2Y= +github.com/owncloud/ocis/graph v0.0.0-20210216094451-dc73176dc62d h1:zcJKzZPDbGzxcbcKZovaVgGzeWMvCd4AoDxV/NcUst8= github.com/owncloud/ocis/graph v0.0.0-20210216094451-dc73176dc62d/go.mod h1:cpCxSvyOOTCZVihIYVOlbsw1ypNJUHVz3wI4v5OGkC4= github.com/owncloud/ocis/graph-explorer v0.0.0-20210216094451-dc73176dc62d/go.mod h1:f0eIfgXI6rOaF+ZcCw+Y3tz05iH7ttP8+nhERuoOW6I= +github.com/owncloud/ocis/idp v0.0.0-20210216094451-dc73176dc62d h1:+cNvIzfpxFaCSRGFurmz1DYkOS4Om+GgpbaMiIm0kCU= github.com/owncloud/ocis/idp v0.0.0-20210216094451-dc73176dc62d/go.mod h1:WPb1FsdlgQMZlzeK1JG7n30qT0TxCNDCejdJHW1zKL0= +github.com/owncloud/ocis/ocs v0.0.0-20210216094451-dc73176dc62d h1:SpeMd/IVNAhAhdnuXeVXuCwLw7/bD9NjetctCu51T9I= github.com/owncloud/ocis/ocs v0.0.0-20210216094451-dc73176dc62d/go.mod h1:y86i4SBJ3+tFEHD4Uc6YgfTHGBZYrvcADuIYGrmOBqI= +github.com/owncloud/ocis/onlyoffice v0.0.0-20210216094451-dc73176dc62d h1:n5jXhWS3q8+qGTf/XDcHAiWCPt5/Lpajnq4nKwrcwQA= github.com/owncloud/ocis/onlyoffice v0.0.0-20210216094451-dc73176dc62d/go.mod h1:Nx7rVDtxnz3nlQ715BMhAOQH34Nh6S7sVfwtpy5wYCM= +github.com/owncloud/ocis/proxy v0.0.0-20210216094451-dc73176dc62d h1:Zx49HeHqa1Ub39w7mYG+hf+36Kugjr1XZfymTna6dMs= github.com/owncloud/ocis/proxy v0.0.0-20210216094451-dc73176dc62d/go.mod h1:DqfrD/LUKJSvXbHxhg78l8AbAc7ce4pEAJDBcijgAzE= github.com/owncloud/ocis/settings v0.0.0-20200918114005-1a0ddd2190ee/go.mod h1:5w91idmyOd8LgYK3eGuqsFBOfVJnSDeEp7S6dHheW14= +github.com/owncloud/ocis/settings v0.0.0-20210216094451-dc73176dc62d h1:z//obMJqTCZVV+HMQfqpqp7z6pOza0Yk63pSTAZ/smE= github.com/owncloud/ocis/settings v0.0.0-20210216094451-dc73176dc62d/go.mod h1:hyv2ZUTiVFJrPgbnL/ftfmKrOF4cEybmD2hGTOMv5+g= github.com/owncloud/ocis/storage v0.0.0-20201015120921-38358ba4d4df/go.mod h1:s9kJvxtBlHEi5qc1TuPAdz2bprk9yGFe+FSOeC76Pbs= +github.com/owncloud/ocis/storage v0.0.0-20210216094451-dc73176dc62d h1:J5GVMffvdXSSrAZggF2INZVZMRRABdeb8CwZHXOpWsQ= github.com/owncloud/ocis/storage v0.0.0-20210216094451-dc73176dc62d/go.mod h1:TWGerkBpvDDr1b2A+Szv0xcaiIlBe7Nkv1hHDuAewao= github.com/owncloud/ocis/thumbnails v0.0.0-20200918125107-fcca9faa81c8/go.mod h1:G17VPMT1FM4aOec1pUkqgEsvM9vInXjbcx7PElpqnm8= +github.com/owncloud/ocis/thumbnails v0.0.0-20210216094451-dc73176dc62d h1:oPpm42TV4bcr3lg+WbDKjdkOgGYyToJhPtCZTlE+eq0= github.com/owncloud/ocis/thumbnails v0.0.0-20210216094451-dc73176dc62d/go.mod h1:IU4JjxsasmAxreD7LckETo3Bmy6cYIkTuDweE7JPVTE= +github.com/owncloud/ocis/web v0.0.0-20210216094451-dc73176dc62d h1:Rrtlx6JY8FYna9HUEqlBx4Tt33mrqnHe7LeeB9moikQ= github.com/owncloud/ocis/web v0.0.0-20210216094451-dc73176dc62d/go.mod h1:0Lp5LNf56BqqmzRA+vNWQIabWo+w3hKxOuHB7fNNwJ0= +github.com/owncloud/ocis/webdav v0.0.0-20210216094451-dc73176dc62d h1:fAS4HJ32vsTB8kcqUgNzbDlN+Ljd8OsJhVqSEIWY6HM= github.com/owncloud/ocis/webdav v0.0.0-20210216094451-dc73176dc62d/go.mod h1:1lGcucrE+581kZV/0WC6LDjKRvfpOaZhAg956+rQ+zo= 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= @@ -1306,6 +1333,7 @@ github.com/rogpeppe/go-internal v1.3.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE github.com/rogpeppe/go-internal v1.4.0/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.5.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= @@ -1315,6 +1343,7 @@ github.com/rs/zerolog v1.19.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJ github.com/rs/zerolog v1.20.0 h1:38k9hgtUBdxFwE34yS8rTHmHBa4eN16E4DJlv177LNs= github.com/rs/zerolog v1.20.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJRjo= github.com/rubenv/sql-migrate v0.0.0-20190212093014-1007f53448d7/go.mod h1:WS0rl9eEliYI8DPnr3TOwz4439pay+qNgzJoVya/DmY= +github.com/russellhaering/goxmldsig v0.0.0-20180430223755-7acd5e4a6ef7 h1:J4AOUcOh/t1XbQcJfkEqhzgvMJ2tDxdCVvmHxW5QXao= github.com/russellhaering/goxmldsig v0.0.0-20180430223755-7acd5e4a6ef7/go.mod h1:Oz4y6ImuOQZxynhbSXk7btjEfNBtGlj2dcaOvXl2FSM= github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= @@ -1324,6 +1353,7 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb github.com/sacloud/libsacloud v1.26.1/go.mod h1:79ZwATmHLIFZIMd7sxA3LwzVy/B77uj3LDoToVTxDoQ= github.com/santhosh-tekuri/jsonschema v1.2.4/go.mod h1:TEAUOeZSmIxTTuHatJzrvARHiuO9LYd+cIxzgEHCQI4= github.com/santhosh-tekuri/jsonschema/v2 v2.1.0/go.mod h1:yzJzKUGV4RbWqWIBBP4wSOBqavX5saE02yirLS0OTyg= +github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/segmentio/analytics-go v3.0.1+incompatible/go.mod h1:C7CYBtQWk4vRk2RyLu0qOcbHJ18E3F1HV2C/8JvKN48= @@ -1376,6 +1406,7 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/skratchdot/open-golang v0.0.0-20160302144031-75fb7ed4208c/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= @@ -1450,6 +1481,7 @@ github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpP github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog= +github.com/thejerf/suture/v4 v4.0.0 h1:GX3X+1Qaewtj9flL2wgoTBfLA5NcmrCY39TJRpPbUrI= github.com/thejerf/suture/v4 v4.0.0/go.mod h1:g0e8vwskm9tI0jRjxrnA6lSr0q6OfPdWJVX7G5bVWRs= github.com/tidwall/gjson v1.3.2/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls= github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E= @@ -1855,6 +1887,7 @@ golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -2150,8 +2183,12 @@ sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck= sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0= +stash.kopano.io/kc/konnect v0.33.3 h1:2X6iBnCMTsBwcwwVjokuKiOhU4PvaInKVQaYxqDvTrA= stash.kopano.io/kc/konnect v0.33.3/go.mod h1:CUQEd8gy8jpVETGY8V1g5zUq38jha8+qDZhDvSf0A7s= +stash.kopano.io/kgol/kcc-go/v5 v5.0.1 h1:urR9hOR6TnTKjGkzZKac/a9cA8ws1WecWLTgiYubLQw= stash.kopano.io/kgol/kcc-go/v5 v5.0.1/go.mod h1:0ZmjWapy3zp+TAjZI6iCrcfh+BthZbB2WM1VfhDgNB4= stash.kopano.io/kgol/ksurveyclient-go v0.6.0/go.mod h1:LJMDQBROS2oXxBN04eSI6j1KhgWlqMFd8xKjXV4Irtw= +stash.kopano.io/kgol/oidc-go v0.3.1 h1:tIEZV4WMFFlUe2AS06GrG3qrS6uSfJFFGJSkV+jGJP8= stash.kopano.io/kgol/oidc-go v0.3.1/go.mod h1:roVKz8FVmPcdL4pUu+Gzk+GH2kOhz1UvnuMNTkjHyH8= +stash.kopano.io/kgol/rndm v1.1.0 h1:Yyr92qtm3NENoCru56phnGv9z5mgFxiNKxzNZahm0w4= stash.kopano.io/kgol/rndm v1.1.0/go.mod h1:CBvpAHlOwyu/XipxfLGk02UN3K3P6hQ8E2JoTbNWfJU= diff --git a/graph/go.mod b/graph/go.mod index b8e73203ed2..e0bde89a836 100644 --- a/graph/go.mod +++ b/graph/go.mod @@ -17,8 +17,10 @@ require ( github.com/oklog/run v1.1.0 github.com/openzipkin/zipkin-go v0.2.5 github.com/owncloud/ocis/ocis-pkg v0.0.0-20210216094451-dc73176dc62d + github.com/prometheus/client_golang v1.7.1 github.com/spf13/afero v1.3.4 // indirect github.com/spf13/viper v1.7.1 + github.com/thejerf/suture/v4 v4.0.0 github.com/yaegashi/msgraph.go v0.1.4 go.opencensus.io v0.23.0 golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect diff --git a/graph/go.sum b/graph/go.sum index 4fd371ad05f..ffa8cf2d6e5 100644 --- a/graph/go.sum +++ b/graph/go.sum @@ -160,6 +160,7 @@ github.com/aws/aws-sdk-go v1.37.3/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zK github.com/aws/aws-sdk-go v1.37.10/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-xray-sdk-go v0.9.4/go.mod h1:XtMKdBQfpVut+tJEwI7+dJFRxxRdxHDyVNp2tHXRq04= github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc= +github.com/beevik/etree v1.1.0 h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs= github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A= github.com/beevik/ntp v0.2.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg= github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -270,7 +271,9 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/crewjam/httperr v0.0.0-20190612203328-a946449404da/go.mod h1:+rmNIXRvYMqLQeR4DHyTvs6y0MEMymTz4vyFpFkKTPs= +github.com/crewjam/httperr v0.2.0 h1:b2BfXR8U3AlIHwNeFFvZ+BV1LFvKLlzMjzaTnZMybNo= github.com/crewjam/httperr v0.2.0/go.mod h1:Jlz+Sg/XqBQhyMjdDiC+GNNRzZTD7x39Gu3pglZ5oH4= +github.com/crewjam/saml v0.4.0 h1:gvSlboe4BO1APaU2eDdsbql3itRat310Q5qs2Seim2k= github.com/crewjam/saml v0.4.0/go.mod h1:geQUbAAwmTKNJFDzoXaTssZHY26O89PHIm3K3YWjWnI= github.com/cs3org/cato v0.0.0-20200626150132-28a40e643719/go.mod h1:XJEZ3/EQuI3BXTp/6DUzFr850vlxq11I6satRtz0YQ4= github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e/go.mod h1:XJEZ3/EQuI3BXTp/6DUzFr850vlxq11I6satRtz0YQ4= @@ -292,8 +295,10 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9/go.mod h1:GgB8SF9nRG+GqaDtLcwJZsQFhcogVCJ79j4EdT0c2V4= +github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ= github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= github.com/decker502/dnspod-go v0.2.0/go.mod h1:qsurYu1FgxcDwfSwXJdLt4kRsBLZeosEb9uq4Sy+08g= +github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= github.com/dgraph-io/ristretto v0.0.1/go.mod h1:T40EBc7CJke8TkpiYfGGKAeFjSaxuFXhuXRyumBd6RE= github.com/dgraph-io/ristretto v0.0.2/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= @@ -326,6 +331,7 @@ github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/eternnoir/gncp v0.0.0-20170707042257-c70df2d0cd68 h1:DHBMBKJK69xBWnD/jNkTN0sOT7nT7I5If9VMsk9Jj5Y= github.com/eternnoir/gncp v0.0.0-20170707042257-c70df2d0cd68/go.mod h1:8FuQ7lU9ZvIJGvc04F/qblkjqIfBahAoEFV+XPxByGw= github.com/evanphx/json-patch/v5 v5.0.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= github.com/eventials/go-tus v0.0.0-20200718001131-45c7ec8f5d59/go.mod h1:XYuK1S5+kS6FGhlIUFuZFPvWiSrOIoLk6+ro33Xce3Y= @@ -711,6 +717,7 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-jsonnet v0.16.0/go.mod h1:sOcuej3UW1vpPTZOr8L7RQimqai1a57bt5j22LzGZCw= +github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -747,9 +754,11 @@ github.com/gorilla/mux v1.7.0/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/pat v0.0.0-20180118222023-199c85a7f6d1/go.mod h1:YeAe0gNeiNT5hoiZRI4yiOky6jVdNvfO2N6Kav/HmxY= github.com/gorilla/schema v1.1.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= +github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc= github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/sessions v1.1.2/go.mod h1:8KCfur6+4Mqcc6S0FEfKuN15Vl5MgXW92AE8ovaJD0w= @@ -864,6 +873,7 @@ github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhB github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901/go.mod h1:Z86h9688Y0wesXCyonoVr47MasHilkuLMqGhRZ4Hpak= github.com/joho/godotenv v1.2.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= +github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/joncalhoun/qson v0.0.0-20170526102502-8a9cab3a62b1/go.mod h1:DFXrEwSRX0p/aSvxE21319menCBFeQO0jXpRj7LEZUA= github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -1002,6 +1012,7 @@ github.com/mattn/goveralls v0.0.5/go.mod h1:Xg2LHi51faXLyKXwsndxiW6uxEEQT9+3sjGz github.com/mattn/goveralls v0.0.6/go.mod h1:h8b4ow6FxSPMQHF6o2ve3qsclnffZjYTNEKmLesRwqw= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103 h1:Z/i1e+gTZrmcGeZyWckaLfucYG6KYOXLWo4co8pZYNY= github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103/go.mod h1:o9YPB5aGP8ob35Vy6+vyq3P3bWe7NQWzf+JLiXCiMaE= github.com/mennanov/fieldmask-utils v0.3.3/go.mod h1:OcOWam4DG685inAjtNuFONKpkitiCCK1W5yKljvWwCY= github.com/mholt/certmagic v0.7.5/go.mod h1:91uJzK5K8IWtYQqTi5R2tsxV1pCde+wdGfaRaOZi6aQ= @@ -1157,6 +1168,7 @@ github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnh github.com/openzipkin/zipkin-go v0.2.5 h1:UwtQQx2pyPIgWYHRg+epgdx1/HnBQTgN3/oIYEJTQzU= github.com/openzipkin/zipkin-go v0.2.5/go.mod h1:KpXfKdgRDnnhsxw4pNIH9Md5lyFqKUa4YDFlwRYAMyE= github.com/oracle/oci-go-sdk v7.0.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888= +github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6 h1:lNCW6THrCKBiJBpz8kbVGjC7MgdCGKwuvBgc7LoD6sw= github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI= github.com/ory/analytics-go/v4 v4.0.0/go.mod h1:FMx9cLRD9xN+XevPvZ5FDMfignpmcqPP6FUKnJ9/MmE= github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= @@ -1192,21 +1204,33 @@ github.com/owncloud/ocis-pkg/v2 v2.4.0/go.mod h1:FSzIvhx9HcZcq4jgNaDowNvM7PTX/XC github.com/owncloud/ocis-pkg/v2 v2.4.1-0.20200902134813-1e87c6173ada/go.mod h1:WdcVM54z0X7aQzS8eyGl7S5sjEMVBtLpfpzsPX3Z+Pw= github.com/owncloud/ocis-settings v0.3.2-0.20200828091056-47af10a0e872/go.mod h1:vRge9QDkOsc6j76gPBmZs1Z5uOPrV4DIkZCgZCEFwBA= github.com/owncloud/ocis/accounts v0.5.3-0.20201103104733-ff2c41028d9b/go.mod h1:IX7T4MJ1U8Y4z9dfDW1J2jq1nv/SHCM7n2zt1fmBHI8= +github.com/owncloud/ocis/accounts v0.5.3-0.20210216094451-dc73176dc62d h1:ldnujTsp0KoVxsU3NlBN8kEkHuoRC8BDsZNN7digIoA= github.com/owncloud/ocis/accounts v0.5.3-0.20210216094451-dc73176dc62d/go.mod h1:OnkGCXo0/ka3o2gwb1jj4pml9X2p769deD0lL66QmrQ= +github.com/owncloud/ocis/glauth v0.0.0-20210216094451-dc73176dc62d h1:gV4N4hAx0FGXWtNSgQf5kRN+6q/LJ592PpyYCMOCNvQ= github.com/owncloud/ocis/glauth v0.0.0-20210216094451-dc73176dc62d/go.mod h1:Xv/WMORry6e4nNDV7G70ruQ8gYPRvxKAWas/E5RMz2Y= github.com/owncloud/ocis/graph v0.0.0-20210216094451-dc73176dc62d/go.mod h1:cpCxSvyOOTCZVihIYVOlbsw1ypNJUHVz3wI4v5OGkC4= +github.com/owncloud/ocis/graph-explorer v0.0.0-20210216094451-dc73176dc62d h1:ib7gWElgxJiLUDdssHGgz+S2T7fR8Ae9wn+PNCT0x18= github.com/owncloud/ocis/graph-explorer v0.0.0-20210216094451-dc73176dc62d/go.mod h1:f0eIfgXI6rOaF+ZcCw+Y3tz05iH7ttP8+nhERuoOW6I= +github.com/owncloud/ocis/idp v0.0.0-20210216094451-dc73176dc62d h1:+cNvIzfpxFaCSRGFurmz1DYkOS4Om+GgpbaMiIm0kCU= github.com/owncloud/ocis/idp v0.0.0-20210216094451-dc73176dc62d/go.mod h1:WPb1FsdlgQMZlzeK1JG7n30qT0TxCNDCejdJHW1zKL0= +github.com/owncloud/ocis/ocs v0.0.0-20210216094451-dc73176dc62d h1:SpeMd/IVNAhAhdnuXeVXuCwLw7/bD9NjetctCu51T9I= github.com/owncloud/ocis/ocs v0.0.0-20210216094451-dc73176dc62d/go.mod h1:y86i4SBJ3+tFEHD4Uc6YgfTHGBZYrvcADuIYGrmOBqI= +github.com/owncloud/ocis/onlyoffice v0.0.0-20210216094451-dc73176dc62d h1:n5jXhWS3q8+qGTf/XDcHAiWCPt5/Lpajnq4nKwrcwQA= github.com/owncloud/ocis/onlyoffice v0.0.0-20210216094451-dc73176dc62d/go.mod h1:Nx7rVDtxnz3nlQ715BMhAOQH34Nh6S7sVfwtpy5wYCM= +github.com/owncloud/ocis/proxy v0.0.0-20210216094451-dc73176dc62d h1:Zx49HeHqa1Ub39w7mYG+hf+36Kugjr1XZfymTna6dMs= github.com/owncloud/ocis/proxy v0.0.0-20210216094451-dc73176dc62d/go.mod h1:DqfrD/LUKJSvXbHxhg78l8AbAc7ce4pEAJDBcijgAzE= github.com/owncloud/ocis/settings v0.0.0-20200918114005-1a0ddd2190ee/go.mod h1:5w91idmyOd8LgYK3eGuqsFBOfVJnSDeEp7S6dHheW14= +github.com/owncloud/ocis/settings v0.0.0-20210216094451-dc73176dc62d h1:z//obMJqTCZVV+HMQfqpqp7z6pOza0Yk63pSTAZ/smE= github.com/owncloud/ocis/settings v0.0.0-20210216094451-dc73176dc62d/go.mod h1:hyv2ZUTiVFJrPgbnL/ftfmKrOF4cEybmD2hGTOMv5+g= github.com/owncloud/ocis/storage v0.0.0-20201015120921-38358ba4d4df/go.mod h1:s9kJvxtBlHEi5qc1TuPAdz2bprk9yGFe+FSOeC76Pbs= +github.com/owncloud/ocis/storage v0.0.0-20210216094451-dc73176dc62d h1:J5GVMffvdXSSrAZggF2INZVZMRRABdeb8CwZHXOpWsQ= github.com/owncloud/ocis/storage v0.0.0-20210216094451-dc73176dc62d/go.mod h1:TWGerkBpvDDr1b2A+Szv0xcaiIlBe7Nkv1hHDuAewao= github.com/owncloud/ocis/thumbnails v0.0.0-20200918125107-fcca9faa81c8/go.mod h1:G17VPMT1FM4aOec1pUkqgEsvM9vInXjbcx7PElpqnm8= +github.com/owncloud/ocis/thumbnails v0.0.0-20210216094451-dc73176dc62d h1:oPpm42TV4bcr3lg+WbDKjdkOgGYyToJhPtCZTlE+eq0= github.com/owncloud/ocis/thumbnails v0.0.0-20210216094451-dc73176dc62d/go.mod h1:IU4JjxsasmAxreD7LckETo3Bmy6cYIkTuDweE7JPVTE= +github.com/owncloud/ocis/web v0.0.0-20210216094451-dc73176dc62d h1:Rrtlx6JY8FYna9HUEqlBx4Tt33mrqnHe7LeeB9moikQ= github.com/owncloud/ocis/web v0.0.0-20210216094451-dc73176dc62d/go.mod h1:0Lp5LNf56BqqmzRA+vNWQIabWo+w3hKxOuHB7fNNwJ0= +github.com/owncloud/ocis/webdav v0.0.0-20210216094451-dc73176dc62d h1:fAS4HJ32vsTB8kcqUgNzbDlN+Ljd8OsJhVqSEIWY6HM= github.com/owncloud/ocis/webdav v0.0.0-20210216094451-dc73176dc62d/go.mod h1:1lGcucrE+581kZV/0WC6LDjKRvfpOaZhAg956+rQ+zo= 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= @@ -1310,6 +1334,7 @@ github.com/rogpeppe/go-internal v1.3.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE github.com/rogpeppe/go-internal v1.4.0/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.5.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= @@ -1319,6 +1344,7 @@ github.com/rs/zerolog v1.19.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJ github.com/rs/zerolog v1.20.0 h1:38k9hgtUBdxFwE34yS8rTHmHBa4eN16E4DJlv177LNs= github.com/rs/zerolog v1.20.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJRjo= github.com/rubenv/sql-migrate v0.0.0-20190212093014-1007f53448d7/go.mod h1:WS0rl9eEliYI8DPnr3TOwz4439pay+qNgzJoVya/DmY= +github.com/russellhaering/goxmldsig v0.0.0-20180430223755-7acd5e4a6ef7 h1:J4AOUcOh/t1XbQcJfkEqhzgvMJ2tDxdCVvmHxW5QXao= github.com/russellhaering/goxmldsig v0.0.0-20180430223755-7acd5e4a6ef7/go.mod h1:Oz4y6ImuOQZxynhbSXk7btjEfNBtGlj2dcaOvXl2FSM= github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= @@ -1328,6 +1354,7 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb github.com/sacloud/libsacloud v1.26.1/go.mod h1:79ZwATmHLIFZIMd7sxA3LwzVy/B77uj3LDoToVTxDoQ= github.com/santhosh-tekuri/jsonschema v1.2.4/go.mod h1:TEAUOeZSmIxTTuHatJzrvARHiuO9LYd+cIxzgEHCQI4= github.com/santhosh-tekuri/jsonschema/v2 v2.1.0/go.mod h1:yzJzKUGV4RbWqWIBBP4wSOBqavX5saE02yirLS0OTyg= +github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/segmentio/analytics-go v3.0.1+incompatible/go.mod h1:C7CYBtQWk4vRk2RyLu0qOcbHJ18E3F1HV2C/8JvKN48= @@ -1380,6 +1407,7 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/skratchdot/open-golang v0.0.0-20160302144031-75fb7ed4208c/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= @@ -1452,6 +1480,7 @@ github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpP github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog= +github.com/thejerf/suture/v4 v4.0.0 h1:GX3X+1Qaewtj9flL2wgoTBfLA5NcmrCY39TJRpPbUrI= github.com/thejerf/suture/v4 v4.0.0/go.mod h1:g0e8vwskm9tI0jRjxrnA6lSr0q6OfPdWJVX7G5bVWRs= github.com/tidwall/gjson v1.3.2/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls= github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E= @@ -1858,6 +1887,7 @@ golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -2153,8 +2183,12 @@ sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck= sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0= +stash.kopano.io/kc/konnect v0.33.3 h1:2X6iBnCMTsBwcwwVjokuKiOhU4PvaInKVQaYxqDvTrA= stash.kopano.io/kc/konnect v0.33.3/go.mod h1:CUQEd8gy8jpVETGY8V1g5zUq38jha8+qDZhDvSf0A7s= +stash.kopano.io/kgol/kcc-go/v5 v5.0.1 h1:urR9hOR6TnTKjGkzZKac/a9cA8ws1WecWLTgiYubLQw= stash.kopano.io/kgol/kcc-go/v5 v5.0.1/go.mod h1:0ZmjWapy3zp+TAjZI6iCrcfh+BthZbB2WM1VfhDgNB4= stash.kopano.io/kgol/ksurveyclient-go v0.6.0/go.mod h1:LJMDQBROS2oXxBN04eSI6j1KhgWlqMFd8xKjXV4Irtw= +stash.kopano.io/kgol/oidc-go v0.3.1 h1:tIEZV4WMFFlUe2AS06GrG3qrS6uSfJFFGJSkV+jGJP8= stash.kopano.io/kgol/oidc-go v0.3.1/go.mod h1:roVKz8FVmPcdL4pUu+Gzk+GH2kOhz1UvnuMNTkjHyH8= +stash.kopano.io/kgol/rndm v1.1.0 h1:Yyr92qtm3NENoCru56phnGv9z5mgFxiNKxzNZahm0w4= stash.kopano.io/kgol/rndm v1.1.0/go.mod h1:CBvpAHlOwyu/XipxfLGk02UN3K3P6hQ8E2JoTbNWfJU= diff --git a/storage/pkg/command/authbearer.go b/storage/pkg/command/authbearer.go index 2cbf62ff4d9..9a8e4a9aa01 100644 --- a/storage/pkg/command/authbearer.go +++ b/storage/pkg/command/authbearer.go @@ -15,6 +15,7 @@ import ( "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" + "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" ) @@ -31,116 +32,47 @@ func AuthBearer(cfg *config.Config) *cli.Command { }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) - - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - logger.Error(). - Str("type", t). - Msg("Storage only supports the jaeger tracing backend") - - case "jaeger": - logger.Info(). - Str("type", t). - Msg("configuring storage to use the jaeger tracing backend") - - case "zipkin": - logger.Error(). - Str("type", t). - Msg("Storage only supports the jaeger tracing backend") - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - } else { - logger.Debug(). - Msg("Tracing is not enabled") - } - - var ( - gr = run.Group{} - ctx, cancel = context.WithCancel(context.Background()) - //metrics = metrics.New() - ) - + tracing.Configure(cfg, logger) + gr := run.Group{} + ctx, cancel := context.WithCancel(context.Background()) defer cancel() - { - - uuid := uuid.Must(uuid.NewV4()) - pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") - - rcfg := map[string]interface{}{ - "core": map[string]interface{}{ - "max_cpus": cfg.Reva.AuthBearer.MaxCPUs, - "tracing_enabled": cfg.Tracing.Enabled, - "tracing_endpoint": cfg.Tracing.Endpoint, - "tracing_collector": cfg.Tracing.Collector, - "tracing_service_name": c.Command.Name, - }, - "shared": map[string]interface{}{ - "jwt_secret": cfg.Reva.JWTSecret, - }, - "grpc": map[string]interface{}{ - "network": cfg.Reva.AuthBearer.GRPCNetwork, - "address": cfg.Reva.AuthBearer.GRPCAddr, - // TODO build services dynamically - "services": map[string]interface{}{ - "authprovider": map[string]interface{}{ - "auth_manager": "oidc", - "auth_managers": map[string]interface{}{ - "oidc": map[string]interface{}{ - "issuer": cfg.Reva.OIDC.Issuer, - "insecure": cfg.Reva.OIDC.Insecure, - "id_claim": cfg.Reva.OIDC.IDClaim, - "uid_claim": cfg.Reva.OIDC.UIDClaim, - "gid_claim": cfg.Reva.OIDC.GIDClaim, - "gatewaysvc": cfg.Reva.Gateway.Endpoint, - }, - }, - }, - }, - }, - } - - gr.Add(func() error { - runtime.RunWithOptions( - rcfg, - pidFile, - runtime.WithLogger(&logger.Logger), - ) - return nil - }, func(_ error) { - logger.Info(). - Str("server", c.Command.Name). - Msg("Shutting down server") - - cancel() - }) - } + uuid := uuid.Must(uuid.NewV4()) + pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") + rcfg := authBearerConfigFromStruct(c, cfg) - { - server, err := debug.Server( - debug.Name(c.Command.Name+"-debug"), - debug.Addr(cfg.Reva.AuthBearer.DebugAddr), - debug.Logger(logger), - debug.Context(ctx), - debug.Config(cfg), + gr.Add(func() error { + runtime.RunWithOptions( + rcfg, + pidFile, + runtime.WithLogger(&logger.Logger), ) + return nil + }, func(_ error) { + logger.Info(). + Str("server", c.Command.Name). + Msg("Shutting down server") + + cancel() + }) + + debugServer, err := debug.Server( + debug.Name(c.Command.Name+"-debug"), + debug.Addr(cfg.Reva.AuthBearer.DebugAddr), + debug.Logger(logger), + debug.Context(ctx), + debug.Config(cfg), + ) - if err != nil { - logger.Info().Err(err).Str("server", "debug").Msg("Failed to initialize server") - return err - } - - gr.Add(server.ListenAndServe, func(_ error) { - cancel() - }) + if err != nil { + logger.Info().Err(err).Str("server", "debug").Msg("failed to initialize server") + return err } + gr.Add(debugServer.ListenAndServe, func(_ error) { + cancel() + }) + if !cfg.Reva.StorageMetadata.Supervised { sync.Trap(&gr, cancel) } @@ -150,6 +82,42 @@ func AuthBearer(cfg *config.Config) *cli.Command { } } +// authBearerConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service. +func authBearerConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]interface{} { + return map[string]interface{}{ + "core": map[string]interface{}{ + "max_cpus": cfg.Reva.AuthBearer.MaxCPUs, + "tracing_enabled": cfg.Tracing.Enabled, + "tracing_endpoint": cfg.Tracing.Endpoint, + "tracing_collector": cfg.Tracing.Collector, + "tracing_service_name": c.Command.Name, + }, + "shared": map[string]interface{}{ + "jwt_secret": cfg.Reva.JWTSecret, + }, + "grpc": map[string]interface{}{ + "network": cfg.Reva.AuthBearer.GRPCNetwork, + "address": cfg.Reva.AuthBearer.GRPCAddr, + // TODO build services dynamically + "services": map[string]interface{}{ + "authprovider": map[string]interface{}{ + "auth_manager": "oidc", + "auth_managers": map[string]interface{}{ + "oidc": map[string]interface{}{ + "issuer": cfg.Reva.OIDC.Issuer, + "insecure": cfg.Reva.OIDC.Insecure, + "id_claim": cfg.Reva.OIDC.IDClaim, + "uid_claim": cfg.Reva.OIDC.UIDClaim, + "gid_claim": cfg.Reva.OIDC.GIDClaim, + "gatewaysvc": cfg.Reva.Gateway.Endpoint, + }, + }, + }, + }, + }, + } +} + // AuthBearerSutureService allows for the storage-gateway command to be embedded and supervised by a suture supervisor tree. type AuthBearerSutureService struct { cfg *config.Config diff --git a/storage/pkg/command/frontend.go b/storage/pkg/command/frontend.go index bfbd4c48a11..362082c24af 100644 --- a/storage/pkg/command/frontend.go +++ b/storage/pkg/command/frontend.go @@ -72,7 +72,7 @@ func Frontend(cfg *config.Config) *cli.Command { } } - revaCfg := revaConfigFromStruct(c, cfg, filesCfg) + revaCfg := frontendConfigFromStruct(c, cfg, filesCfg) gr.Add(func() error { runtime.RunWithOptions(revaCfg, pidFile, runtime.WithLogger(&logger.Logger)) @@ -114,8 +114,8 @@ func Frontend(cfg *config.Config) *cli.Command { } } -// revaConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service. -func revaConfigFromStruct(c *cli.Context, cfg *config.Config, filesCfg map[string]interface{}) map[string]interface{} { +// frontendConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service. +func frontendConfigFromStruct(c *cli.Context, cfg *config.Config, filesCfg map[string]interface{}) map[string]interface{} { return map[string]interface{}{ "core": map[string]interface{}{ "max_cpus": cfg.Reva.Users.MaxCPUs, From f4076864046fa2cb5d7c1061e3109658f209db9f Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 11:04:12 +0100 Subject: [PATCH 04/24] refactor a authbasic storage tracing config --- storage/pkg/command/authbasic.go | 194 +++++++++++++------------------ 1 file changed, 80 insertions(+), 114 deletions(-) diff --git a/storage/pkg/command/authbasic.go b/storage/pkg/command/authbasic.go index 83466208567..249781c440f 100644 --- a/storage/pkg/command/authbasic.go +++ b/storage/pkg/command/authbasic.go @@ -16,6 +16,7 @@ import ( "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" + "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" ) @@ -32,135 +33,51 @@ func AuthBasic(cfg *config.Config) *cli.Command { }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) - - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - logger.Error(). - Str("type", t). - Msg("Storage only supports the jaeger tracing backend") - - case "jaeger": - logger.Info(). - Str("type", t). - Msg("configuring storage to use the jaeger tracing backend") - - case "zipkin": - logger.Error(). - Str("type", t). - Msg("Storage only supports the jaeger tracing backend") - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - } else { - logger.Debug(). - Msg("Tracing is not enabled") - } - - var ( - gr = run.Group{} - ctx, cancel = context.WithCancel(context.Background()) - //metrics = metrics.New() - ) - + tracing.Configure(cfg, logger) + gr := run.Group{} + ctx, cancel := context.WithCancel(context.Background()) defer cancel() - // precreate folders + // pre-create folders if cfg.Reva.AuthProvider.Driver == "json" && cfg.Reva.AuthProvider.JSON != "" { if err := os.MkdirAll(filepath.Dir(cfg.Reva.AuthProvider.JSON), os.FileMode(0700)); err != nil { return err } } - { + uuid := uuid.Must(uuid.NewV4()) + pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") - uuid := uuid.Must(uuid.NewV4()) - pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") + rcfg := authBasicConfigFromStruct(c, cfg) - rcfg := map[string]interface{}{ - "core": map[string]interface{}{ - "max_cpus": cfg.Reva.AuthBasic.MaxCPUs, - "tracing_enabled": cfg.Tracing.Enabled, - "tracing_endpoint": cfg.Tracing.Endpoint, - "tracing_collector": cfg.Tracing.Collector, - "tracing_service_name": c.Command.Name, - }, - "shared": map[string]interface{}{ - "jwt_secret": cfg.Reva.JWTSecret, - }, - "grpc": map[string]interface{}{ - "network": cfg.Reva.AuthBasic.GRPCNetwork, - "address": cfg.Reva.AuthBasic.GRPCAddr, - // TODO build services dynamically - "services": map[string]interface{}{ - "authprovider": map[string]interface{}{ - "auth_manager": cfg.Reva.AuthProvider.Driver, - "auth_managers": map[string]interface{}{ - "json": map[string]interface{}{ - "users": cfg.Reva.AuthProvider.JSON, - }, - "ldap": map[string]interface{}{ - "hostname": cfg.Reva.LDAP.Hostname, - "port": cfg.Reva.LDAP.Port, - "base_dn": cfg.Reva.LDAP.BaseDN, - "loginfilter": cfg.Reva.LDAP.LoginFilter, - "bind_username": cfg.Reva.LDAP.BindDN, - "bind_password": cfg.Reva.LDAP.BindPassword, - "idp": cfg.Reva.LDAP.IDP, - "gatewaysvc": cfg.Reva.Gateway.Endpoint, - "schema": map[string]interface{}{ - "dn": "dn", - "uid": cfg.Reva.LDAP.UserSchema.UID, - "mail": cfg.Reva.LDAP.UserSchema.Mail, - "displayName": cfg.Reva.LDAP.UserSchema.DisplayName, - "cn": cfg.Reva.LDAP.UserSchema.CN, - }, - }, - }, - }, - }, - }, - } + gr.Add(func() error { + runtime.RunWithOptions(rcfg, pidFile, runtime.WithLogger(&logger.Logger)) + return nil + }, func(_ error) { + logger.Info(). + Str("server", c.Command.Name). + Msg("Shutting down server") - gr.Add(func() error { - runtime.RunWithOptions( - rcfg, - pidFile, - runtime.WithLogger(&logger.Logger), - ) - return nil - }, func(_ error) { - logger.Info(). - Str("server", c.Command.Name). - Msg("Shutting down server") - - cancel() - }) - } + cancel() + }) - { - server, err := debug.Server( - debug.Name(c.Command.Name+"-debug"), - debug.Addr(cfg.Reva.AuthBasic.DebugAddr), - debug.Logger(logger), - debug.Context(ctx), - debug.Config(cfg), - ) - - if err != nil { - logger.Info().Err(err).Str("server", "debug").Msg("Failed to initialize server") - return err - } + debugServer, err := debug.Server( + debug.Name(c.Command.Name+"-debug"), + debug.Addr(cfg.Reva.AuthBasic.DebugAddr), + debug.Logger(logger), + debug.Context(ctx), + debug.Config(cfg), + ) - gr.Add(server.ListenAndServe, func(_ error) { - cancel() - }) + if err != nil { + logger.Info().Err(err).Str("server", "debug").Msg("Failed to initialize server") + return err } + gr.Add(debugServer.ListenAndServe, func(_ error) { + cancel() + }) + if !cfg.Reva.StorageMetadata.Supervised { sync.Trap(&gr, cancel) } @@ -170,6 +87,55 @@ func AuthBasic(cfg *config.Config) *cli.Command { } } +// authBasicConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service. +func authBasicConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]interface{} { + rcfg := map[string]interface{}{ + "core": map[string]interface{}{ + "max_cpus": cfg.Reva.AuthBasic.MaxCPUs, + "tracing_enabled": cfg.Tracing.Enabled, + "tracing_endpoint": cfg.Tracing.Endpoint, + "tracing_collector": cfg.Tracing.Collector, + "tracing_service_name": c.Command.Name, + }, + "shared": map[string]interface{}{ + "jwt_secret": cfg.Reva.JWTSecret, + }, + "grpc": map[string]interface{}{ + "network": cfg.Reva.AuthBasic.GRPCNetwork, + "address": cfg.Reva.AuthBasic.GRPCAddr, + // TODO build services dynamically + "services": map[string]interface{}{ + "authprovider": map[string]interface{}{ + "auth_manager": cfg.Reva.AuthProvider.Driver, + "auth_managers": map[string]interface{}{ + "json": map[string]interface{}{ + "users": cfg.Reva.AuthProvider.JSON, + }, + "ldap": map[string]interface{}{ + "hostname": cfg.Reva.LDAP.Hostname, + "port": cfg.Reva.LDAP.Port, + "base_dn": cfg.Reva.LDAP.BaseDN, + "loginfilter": cfg.Reva.LDAP.LoginFilter, + "bind_username": cfg.Reva.LDAP.BindDN, + "bind_password": cfg.Reva.LDAP.BindPassword, + "idp": cfg.Reva.LDAP.IDP, + "gatewaysvc": cfg.Reva.Gateway.Endpoint, + "schema": map[string]interface{}{ + "dn": "dn", + "uid": cfg.Reva.LDAP.UserSchema.UID, + "mail": cfg.Reva.LDAP.UserSchema.Mail, + "displayName": cfg.Reva.LDAP.UserSchema.DisplayName, + "cn": cfg.Reva.LDAP.UserSchema.CN, + }, + }, + }, + }, + }, + }, + } + return rcfg +} + // AuthBasicSutureService allows for the storage-authbasic command to be embedded and supervised by a suture supervisor tree. type AuthBasicSutureService struct { cfg *config.Config From 44fe360ef587700d3fad3462f2d1b39b58cd7360 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 11:36:54 +0100 Subject: [PATCH 05/24] refactor gateway tracing config --- storage/pkg/command/gateway.go | 260 +++++++++++++++------------------ 1 file changed, 114 insertions(+), 146 deletions(-) diff --git a/storage/pkg/command/gateway.go b/storage/pkg/command/gateway.go index 335fc46d97b..e7b0081e815 100644 --- a/storage/pkg/command/gateway.go +++ b/storage/pkg/command/gateway.go @@ -7,6 +7,8 @@ import ( "path" "strings" + "github.com/owncloud/ocis/storage/pkg/tracing" + "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/cs3org/reva/cmd/revad/runtime" @@ -39,162 +41,58 @@ func Gateway(cfg *config.Config) *cli.Command { }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) - - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - logger.Error(). - Str("type", t). - Msg("Reva only supports the jaeger tracing backend") - - case "jaeger": - logger.Info(). - Str("type", t). - Msg("configuring storage to use the jaeger tracing backend") - - case "zipkin": - logger.Error(). - Str("type", t). - Msg("Reva only supports the jaeger tracing backend") - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - } else { - logger.Debug(). - Msg("Tracing is not enabled") - } - - var ( - gr = run.Group{} - ctx, cancel = context.WithCancel(context.Background()) - //metrics = metrics.New() - ) - + tracing.Configure(cfg, logger) + gr := run.Group{} + ctx, cancel := context.WithCancel(context.Background()) + uuid := uuid.Must(uuid.NewV4()) + pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") + rcfg := gatewayConfigFromStruct(c, cfg) defer cancel() - { - - uuid := uuid.Must(uuid.NewV4()) - pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") - - rcfg := map[string]interface{}{ - "core": map[string]interface{}{ - "max_cpus": cfg.Reva.Users.MaxCPUs, - "tracing_enabled": cfg.Tracing.Enabled, - "tracing_endpoint": cfg.Tracing.Endpoint, - "tracing_collector": cfg.Tracing.Collector, - "tracing_service_name": c.Command.Name, - }, - "shared": map[string]interface{}{ - "jwt_secret": cfg.Reva.JWTSecret, - "gatewaysvc": cfg.Reva.Gateway.Endpoint, - }, - "grpc": map[string]interface{}{ - "network": cfg.Reva.Gateway.GRPCNetwork, - "address": cfg.Reva.Gateway.GRPCAddr, - // TODO build services dynamically - "services": map[string]interface{}{ - "gateway": map[string]interface{}{ - // registries is located on the gateway - "authregistrysvc": cfg.Reva.Gateway.Endpoint, - "storageregistrysvc": cfg.Reva.Gateway.Endpoint, - "appregistrysvc": cfg.Reva.Gateway.Endpoint, - // user metadata is located on the users services - "preferencessvc": cfg.Reva.Users.Endpoint, - "userprovidersvc": cfg.Reva.Users.Endpoint, - "groupprovidersvc": cfg.Reva.Groups.Endpoint, - // sharing is located on the sharing service - "usershareprovidersvc": cfg.Reva.Sharing.Endpoint, - "publicshareprovidersvc": cfg.Reva.Sharing.Endpoint, - "ocmshareprovidersvc": cfg.Reva.Sharing.Endpoint, - "commit_share_to_storage_grant": cfg.Reva.Gateway.CommitShareToStorageGrant, - "commit_share_to_storage_ref": cfg.Reva.Gateway.CommitShareToStorageRef, - "share_folder": cfg.Reva.Gateway.ShareFolder, // ShareFolder is the location where to create shares in the recipient's storage provider. - // other - "disable_home_creation_on_login": cfg.Reva.Gateway.DisableHomeCreationOnLogin, - "datagateway": cfg.Reva.DataGateway.PublicURL, - "transfer_shared_secret": cfg.Reva.TransferSecret, - "transfer_expires": cfg.Reva.TransferExpires, - "home_mapping": cfg.Reva.Gateway.HomeMapping, - "etag_cache_ttl": cfg.Reva.Gateway.EtagCacheTTL, - }, - "authregistry": map[string]interface{}{ - "driver": "static", - "drivers": map[string]interface{}{ - "static": map[string]interface{}{ - "rules": map[string]interface{}{ - "basic": cfg.Reva.AuthBasic.Endpoint, - "bearer": cfg.Reva.AuthBearer.Endpoint, - "publicshares": cfg.Reva.StoragePublicLink.Endpoint, - }, - }, - }, - }, - "storageregistry": map[string]interface{}{ - "driver": cfg.Reva.StorageRegistry.Driver, - "drivers": map[string]interface{}{ - "static": map[string]interface{}{ - "home_provider": cfg.Reva.StorageRegistry.HomeProvider, - "rules": rules(cfg), - }, - }, - }, - }, - }, - } - - gr.Add(func() error { - err := external.RegisterGRPCEndpoint( - ctx, - "com.owncloud.storage", - uuid.String(), - cfg.Reva.Gateway.GRPCAddr, - logger, - ) - - if err != nil { - return err - } - - runtime.RunWithOptions( - rcfg, - pidFile, - runtime.WithLogger(&logger.Logger), - ) - return nil - }, func(_ error) { - logger.Info(). - Str("server", c.Command.Name). - Msg("Shutting down server") - - cancel() - }) - - } - - { - server, err := debug.Server( - debug.Name(c.Command.Name+"-debug"), - debug.Addr(cfg.Reva.Gateway.DebugAddr), - debug.Logger(logger), - debug.Context(ctx), - debug.Config(cfg), + gr.Add(func() error { + err := external.RegisterGRPCEndpoint( + ctx, + "com.owncloud.storage", + uuid.String(), + cfg.Reva.Gateway.GRPCAddr, + logger, ) if err != nil { - logger.Info().Err(err).Str("server", "debug").Msg("Failed to initialize server") return err } - gr.Add(server.ListenAndServe, func(_ error) { - cancel() - }) + runtime.RunWithOptions( + rcfg, + pidFile, + runtime.WithLogger(&logger.Logger), + ) + return nil + }, func(_ error) { + logger.Info(). + Str("server", c.Command.Name). + Msg("Shutting down server") + + cancel() + }) + + debugServer, err := debug.Server( + debug.Name(c.Command.Name+"-debug"), + debug.Addr(cfg.Reva.Gateway.DebugAddr), + debug.Logger(logger), + debug.Context(ctx), + debug.Config(cfg), + ) + + if err != nil { + logger.Info().Err(err).Str("server", "debug").Msg("Failed to initialize server") + return err } + gr.Add(debugServer.ListenAndServe, func(_ error) { + cancel() + }) + if !cfg.Reva.StorageMetadata.Supervised { sync.Trap(&gr, cancel) } @@ -204,6 +102,76 @@ func Gateway(cfg *config.Config) *cli.Command { } } +// gatewayConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service. +func gatewayConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]interface{} { + rcfg := map[string]interface{}{ + "core": map[string]interface{}{ + "max_cpus": cfg.Reva.Users.MaxCPUs, + "tracing_enabled": cfg.Tracing.Enabled, + "tracing_endpoint": cfg.Tracing.Endpoint, + "tracing_collector": cfg.Tracing.Collector, + "tracing_service_name": c.Command.Name, + }, + "shared": map[string]interface{}{ + "jwt_secret": cfg.Reva.JWTSecret, + "gatewaysvc": cfg.Reva.Gateway.Endpoint, + }, + "grpc": map[string]interface{}{ + "network": cfg.Reva.Gateway.GRPCNetwork, + "address": cfg.Reva.Gateway.GRPCAddr, + // TODO build services dynamically + "services": map[string]interface{}{ + "gateway": map[string]interface{}{ + // registries is located on the gateway + "authregistrysvc": cfg.Reva.Gateway.Endpoint, + "storageregistrysvc": cfg.Reva.Gateway.Endpoint, + "appregistrysvc": cfg.Reva.Gateway.Endpoint, + // user metadata is located on the users services + "preferencessvc": cfg.Reva.Users.Endpoint, + "userprovidersvc": cfg.Reva.Users.Endpoint, + "groupprovidersvc": cfg.Reva.Groups.Endpoint, + // sharing is located on the sharing service + "usershareprovidersvc": cfg.Reva.Sharing.Endpoint, + "publicshareprovidersvc": cfg.Reva.Sharing.Endpoint, + "ocmshareprovidersvc": cfg.Reva.Sharing.Endpoint, + "commit_share_to_storage_grant": cfg.Reva.Gateway.CommitShareToStorageGrant, + "commit_share_to_storage_ref": cfg.Reva.Gateway.CommitShareToStorageRef, + "share_folder": cfg.Reva.Gateway.ShareFolder, // ShareFolder is the location where to create shares in the recipient's storage provider. + // other + "disable_home_creation_on_login": cfg.Reva.Gateway.DisableHomeCreationOnLogin, + "datagateway": cfg.Reva.DataGateway.PublicURL, + "transfer_shared_secret": cfg.Reva.TransferSecret, + "transfer_expires": cfg.Reva.TransferExpires, + "home_mapping": cfg.Reva.Gateway.HomeMapping, + "etag_cache_ttl": cfg.Reva.Gateway.EtagCacheTTL, + }, + "authregistry": map[string]interface{}{ + "driver": "static", + "drivers": map[string]interface{}{ + "static": map[string]interface{}{ + "rules": map[string]interface{}{ + "basic": cfg.Reva.AuthBasic.Endpoint, + "bearer": cfg.Reva.AuthBearer.Endpoint, + "publicshares": cfg.Reva.StoragePublicLink.Endpoint, + }, + }, + }, + }, + "storageregistry": map[string]interface{}{ + "driver": cfg.Reva.StorageRegistry.Driver, + "drivers": map[string]interface{}{ + "static": map[string]interface{}{ + "home_provider": cfg.Reva.StorageRegistry.HomeProvider, + "rules": rules(cfg), + }, + }, + }, + }, + }, + } + return rcfg +} + func rules(cfg *config.Config) map[string]interface{} { // if a list of rules is given it overrides the generated rules from below From 604cab3e6381fa714d37ef44cfc175751ba572f7 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 11:38:43 +0100 Subject: [PATCH 06/24] refactor groups tracing config --- storage/pkg/command/groups.go | 231 +++++++++++++++------------------- 1 file changed, 101 insertions(+), 130 deletions(-) diff --git a/storage/pkg/command/groups.go b/storage/pkg/command/groups.go index 7707c06c9ea..fb631674bed 100644 --- a/storage/pkg/command/groups.go +++ b/storage/pkg/command/groups.go @@ -7,6 +7,8 @@ import ( "path" "path/filepath" + "github.com/owncloud/ocis/storage/pkg/tracing" + "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/cs3org/reva/cmd/revad/runtime" @@ -33,149 +35,55 @@ func Groups(cfg *config.Config) *cli.Command { }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) + tracing.Configure(cfg, logger) + gr := run.Group{} + ctx, cancel := context.WithCancel(context.Background()) - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - logger.Error(). - Str("type", t). - Msg("Reva only supports the jaeger tracing backend") - - case "jaeger": - logger.Info(). - Str("type", t). - Msg("configuring storage to use the jaeger tracing backend") - - case "zipkin": - logger.Error(). - Str("type", t). - Msg("Reva only supports the jaeger tracing backend") - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - } else { - logger.Debug(). - Msg("Tracing is not enabled") - } - - var ( - gr = run.Group{} - ctx, cancel = context.WithCancel(context.Background()) - //metrics = metrics.New() - ) - - defer cancel() - - // precreate folders + // pre-create folders if cfg.Reva.Groups.Driver == "json" && cfg.Reva.Groups.JSON != "" { if err := os.MkdirAll(filepath.Dir(cfg.Reva.Groups.JSON), os.FileMode(0700)); err != nil { return err } } - { - uuid := uuid.Must(uuid.NewV4()) - pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") - - rcfg := map[string]interface{}{ - "core": map[string]interface{}{ - "max_cpus": cfg.Reva.Groups.MaxCPUs, - "tracing_enabled": cfg.Tracing.Enabled, - "tracing_endpoint": cfg.Tracing.Endpoint, - "tracing_collector": cfg.Tracing.Collector, - "tracing_service_name": c.Command.Name, - }, - "shared": map[string]interface{}{ - "jwt_secret": cfg.Reva.JWTSecret, - }, - "grpc": map[string]interface{}{ - "network": cfg.Reva.Groups.GRPCNetwork, - "address": cfg.Reva.Groups.GRPCAddr, - // TODO build services dynamically - "services": map[string]interface{}{ - "groupprovider": map[string]interface{}{ - "driver": cfg.Reva.Groups.Driver, - "drivers": map[string]interface{}{ - "json": map[string]interface{}{ - "groups": cfg.Reva.Groups.JSON, - }, - "ldap": map[string]interface{}{ - "hostname": cfg.Reva.LDAP.Hostname, - "port": cfg.Reva.LDAP.Port, - "base_dn": cfg.Reva.LDAP.BaseDN, - "groupfilter": cfg.Reva.LDAP.GroupFilter, - "attributefilter": cfg.Reva.LDAP.GroupAttributeFilter, - "findfilter": cfg.Reva.LDAP.GroupFindFilter, - "memberfilter": cfg.Reva.LDAP.GroupMemberFilter, - "bind_username": cfg.Reva.LDAP.BindDN, - "bind_password": cfg.Reva.LDAP.BindPassword, - "idp": cfg.Reva.LDAP.IDP, - "schema": map[string]interface{}{ - "dn": "dn", - "gid": cfg.Reva.LDAP.GroupSchema.GID, - "mail": cfg.Reva.LDAP.GroupSchema.Mail, - "displayName": cfg.Reva.LDAP.GroupSchema.DisplayName, - "cn": cfg.Reva.LDAP.GroupSchema.CN, - "gidNumber": cfg.Reva.LDAP.GroupSchema.GIDNumber, - }, - }, - "rest": map[string]interface{}{ - "client_id": cfg.Reva.UserGroupRest.ClientID, - "client_secret": cfg.Reva.UserGroupRest.ClientSecret, - "redis_address": cfg.Reva.UserGroupRest.RedisAddress, - "redis_username": cfg.Reva.UserGroupRest.RedisUsername, - "redis_password": cfg.Reva.UserGroupRest.RedisPassword, - "group_members_cache_expiration": cfg.Reva.Groups.GroupMembersCacheExpiration, - "id_provider": cfg.Reva.UserGroupRest.IDProvider, - "api_base_url": cfg.Reva.UserGroupRest.APIBaseURL, - "oidc_token_endpoint": cfg.Reva.UserGroupRest.OIDCTokenEndpoint, - "target_api": cfg.Reva.UserGroupRest.TargetAPI, - }, - }, - }, - }, - }, - } + uuid := uuid.Must(uuid.NewV4()) + pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") + defer cancel() - gr.Add(func() error { - runtime.RunWithOptions( - rcfg, - pidFile, - runtime.WithLogger(&logger.Logger), - ) - return nil - }, func(_ error) { - logger.Info(). - Str("server", c.Command.Name). - Msg("Shutting down server") - - cancel() - }) - } + rcfg := groupsConfigFromStruct(c, cfg) - { - server, err := debug.Server( - debug.Name(c.Command.Name+"-debug"), - debug.Addr(cfg.Reva.Users.DebugAddr), - debug.Logger(logger), - debug.Context(ctx), - debug.Config(cfg), + gr.Add(func() error { + runtime.RunWithOptions( + rcfg, + pidFile, + runtime.WithLogger(&logger.Logger), ) + return nil + }, func(_ error) { + logger.Info(). + Str("server", c.Command.Name). + Msg("Shutting down server") + + cancel() + }) + + debugServer, err := debug.Server( + debug.Name(c.Command.Name+"-debug"), + debug.Addr(cfg.Reva.Users.DebugAddr), + debug.Logger(logger), + debug.Context(ctx), + debug.Config(cfg), + ) - if err != nil { - logger.Info().Err(err).Str("server", c.Command.Name+"-debug").Msg("Failed to initialize server") - return err - } - - gr.Add(server.ListenAndServe, func(_ error) { - cancel() - }) + if err != nil { + logger.Info().Err(err).Str("server", c.Command.Name+"-debug").Msg("Failed to initialize server") + return err } + gr.Add(debugServer.ListenAndServe, func(_ error) { + cancel() + }) + if !cfg.Reva.StorageMetadata.Supervised { sync.Trap(&gr, cancel) } @@ -185,6 +93,69 @@ func Groups(cfg *config.Config) *cli.Command { } } +// groupsConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service. +func groupsConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]interface{} { + return map[string]interface{}{ + "core": map[string]interface{}{ + "max_cpus": cfg.Reva.Groups.MaxCPUs, + "tracing_enabled": cfg.Tracing.Enabled, + "tracing_endpoint": cfg.Tracing.Endpoint, + "tracing_collector": cfg.Tracing.Collector, + "tracing_service_name": c.Command.Name, + }, + "shared": map[string]interface{}{ + "jwt_secret": cfg.Reva.JWTSecret, + }, + "grpc": map[string]interface{}{ + "network": cfg.Reva.Groups.GRPCNetwork, + "address": cfg.Reva.Groups.GRPCAddr, + // TODO build services dynamically + "services": map[string]interface{}{ + "groupprovider": map[string]interface{}{ + "driver": cfg.Reva.Groups.Driver, + "drivers": map[string]interface{}{ + "json": map[string]interface{}{ + "groups": cfg.Reva.Groups.JSON, + }, + "ldap": map[string]interface{}{ + "hostname": cfg.Reva.LDAP.Hostname, + "port": cfg.Reva.LDAP.Port, + "base_dn": cfg.Reva.LDAP.BaseDN, + "groupfilter": cfg.Reva.LDAP.GroupFilter, + "attributefilter": cfg.Reva.LDAP.GroupAttributeFilter, + "findfilter": cfg.Reva.LDAP.GroupFindFilter, + "memberfilter": cfg.Reva.LDAP.GroupMemberFilter, + "bind_username": cfg.Reva.LDAP.BindDN, + "bind_password": cfg.Reva.LDAP.BindPassword, + "idp": cfg.Reva.LDAP.IDP, + "schema": map[string]interface{}{ + "dn": "dn", + "gid": cfg.Reva.LDAP.GroupSchema.GID, + "mail": cfg.Reva.LDAP.GroupSchema.Mail, + "displayName": cfg.Reva.LDAP.GroupSchema.DisplayName, + "cn": cfg.Reva.LDAP.GroupSchema.CN, + "gidNumber": cfg.Reva.LDAP.GroupSchema.GIDNumber, + }, + }, + "rest": map[string]interface{}{ + "client_id": cfg.Reva.UserGroupRest.ClientID, + "client_secret": cfg.Reva.UserGroupRest.ClientSecret, + "redis_address": cfg.Reva.UserGroupRest.RedisAddress, + "redis_username": cfg.Reva.UserGroupRest.RedisUsername, + "redis_password": cfg.Reva.UserGroupRest.RedisPassword, + "group_members_cache_expiration": cfg.Reva.Groups.GroupMembersCacheExpiration, + "id_provider": cfg.Reva.UserGroupRest.IDProvider, + "api_base_url": cfg.Reva.UserGroupRest.APIBaseURL, + "oidc_token_endpoint": cfg.Reva.UserGroupRest.OIDCTokenEndpoint, + "target_api": cfg.Reva.UserGroupRest.TargetAPI, + }, + }, + }, + }, + }, + } +} + // GroupsProvider allows for the storage-groupsprovider command to be embedded and supervised by a suture supervisor tree. type GroupsProvider struct { cfg *config.Config From c8e7a75d54876360095aca68074d2dbb3a9226ec Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 11:43:50 +0100 Subject: [PATCH 07/24] refactor sharing tracing config --- storage/pkg/command/sharing.go | 196 ++++++++++++++------------------- 1 file changed, 83 insertions(+), 113 deletions(-) diff --git a/storage/pkg/command/sharing.go b/storage/pkg/command/sharing.go index d5f7cf5564d..264491a504c 100644 --- a/storage/pkg/command/sharing.go +++ b/storage/pkg/command/sharing.go @@ -7,6 +7,8 @@ import ( "path" "path/filepath" + "github.com/owncloud/ocis/storage/pkg/tracing" + "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/cs3org/reva/cmd/revad/runtime" @@ -34,39 +36,10 @@ func Sharing(cfg *config.Config) *cli.Command { Action: func(c *cli.Context) error { logger := NewLogger(cfg) - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - logger.Error(). - Str("type", t). - Msg("Reva only supports the jaeger tracing backend") - - case "jaeger": - logger.Info(). - Str("type", t). - Msg("configuring storage to use the jaeger tracing backend") - - case "zipkin": - logger.Error(). - Str("type", t). - Msg("Reva only supports the jaeger tracing backend") - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - } else { - logger.Debug(). - Msg("Tracing is not enabled") - } + tracing.Configure(cfg, logger) - var ( - gr = run.Group{} - ctx, cancel = context.WithCancel(context.Background()) - //metrics = metrics.New() - ) + gr := run.Group{} + ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -82,93 +55,43 @@ func Sharing(cfg *config.Config) *cli.Command { } } - { + uuid := uuid.Must(uuid.NewV4()) + pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") - uuid := uuid.Must(uuid.NewV4()) - pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") + rcfg := sharingConfigFromStruct(c, cfg) - rcfg := map[string]interface{}{ - "core": map[string]interface{}{ - "max_cpus": cfg.Reva.Sharing.MaxCPUs, - "tracing_enabled": cfg.Tracing.Enabled, - "tracing_endpoint": cfg.Tracing.Endpoint, - "tracing_collector": cfg.Tracing.Collector, - "tracing_service_name": c.Command.Name, - }, - "shared": map[string]interface{}{ - "jwt_secret": cfg.Reva.JWTSecret, - }, - "grpc": map[string]interface{}{ - "network": cfg.Reva.Sharing.GRPCNetwork, - "address": cfg.Reva.Sharing.GRPCAddr, - // TODO build services dynamically - "services": map[string]interface{}{ - "usershareprovider": map[string]interface{}{ - "driver": cfg.Reva.Sharing.UserDriver, - "drivers": map[string]interface{}{ - "json": map[string]interface{}{ - "file": cfg.Reva.Sharing.UserJSONFile, - }, - "sql": map[string]interface{}{ - "db_username": cfg.Reva.Sharing.UserSQLUsername, - "db_password": cfg.Reva.Sharing.UserSQLPassword, - "db_host": cfg.Reva.Sharing.UserSQLHost, - "db_port": cfg.Reva.Sharing.UserSQLPort, - "db_name": cfg.Reva.Sharing.UserSQLName, - }, - }, - }, - "publicshareprovider": map[string]interface{}{ - "driver": cfg.Reva.Sharing.PublicDriver, - "drivers": map[string]interface{}{ - "json": map[string]interface{}{ - "file": cfg.Reva.Sharing.PublicJSONFile, - }, - }, - }, - }, - }, - } - - gr.Add(func() error { - runtime.RunWithOptions( - rcfg, - pidFile, - runtime.WithLogger(&logger.Logger), - ) - return nil - }, func(_ error) { - logger.Info(). - Str("server", c.Command.Name). - Msg("Shutting down server") - - cancel() - }) - } - - { - server, err := debug.Server( - debug.Name(c.Command.Name+"-debug"), - debug.Addr(cfg.Reva.Sharing.DebugAddr), - debug.Logger(logger), - debug.Context(ctx), - debug.Config(cfg), + gr.Add(func() error { + runtime.RunWithOptions( + rcfg, + pidFile, + runtime.WithLogger(&logger.Logger), ) + return nil + }, func(_ error) { + logger.Info(). + Str("server", c.Command.Name). + Msg("Shutting down server") + + cancel() + }) + + debug, err := debug.Server( + debug.Name(c.Command.Name+"-debug"), + debug.Addr(cfg.Reva.Sharing.DebugAddr), + debug.Logger(logger), + debug.Context(ctx), + debug.Config(cfg), + ) - if err != nil { - logger.Info(). - Err(err). - Str("server", c.Command.Name+"-debug"). - Msg("Failed to initialize server") - - return err - } - - gr.Add(server.ListenAndServe, func(_ error) { - cancel() - }) + if err != nil { + logger.Info().Err(err).Str("server", c.Command.Name+"-debug").Msg("Failed to initialize server") + return err } + gr.Add(debug.ListenAndServe, func(_ error) { + cancel() + }) + if !cfg.Reva.StorageMetadata.Supervised { sync.Trap(&gr, cancel) } @@ -178,6 +101,53 @@ func Sharing(cfg *config.Config) *cli.Command { } } +// sharingConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service. +func sharingConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]interface{} { + rcfg := map[string]interface{}{ + "core": map[string]interface{}{ + "max_cpus": cfg.Reva.Sharing.MaxCPUs, + "tracing_enabled": cfg.Tracing.Enabled, + "tracing_endpoint": cfg.Tracing.Endpoint, + "tracing_collector": cfg.Tracing.Collector, + "tracing_service_name": c.Command.Name, + }, + "shared": map[string]interface{}{ + "jwt_secret": cfg.Reva.JWTSecret, + }, + "grpc": map[string]interface{}{ + "network": cfg.Reva.Sharing.GRPCNetwork, + "address": cfg.Reva.Sharing.GRPCAddr, + // TODO build services dynamically + "services": map[string]interface{}{ + "usershareprovider": map[string]interface{}{ + "driver": cfg.Reva.Sharing.UserDriver, + "drivers": map[string]interface{}{ + "json": map[string]interface{}{ + "file": cfg.Reva.Sharing.UserJSONFile, + }, + "sql": map[string]interface{}{ + "db_username": cfg.Reva.Sharing.UserSQLUsername, + "db_password": cfg.Reva.Sharing.UserSQLPassword, + "db_host": cfg.Reva.Sharing.UserSQLHost, + "db_port": cfg.Reva.Sharing.UserSQLPort, + "db_name": cfg.Reva.Sharing.UserSQLName, + }, + }, + }, + "publicshareprovider": map[string]interface{}{ + "driver": cfg.Reva.Sharing.PublicDriver, + "drivers": map[string]interface{}{ + "json": map[string]interface{}{ + "file": cfg.Reva.Sharing.PublicJSONFile, + }, + }, + }, + }, + }, + } + return rcfg +} + // SharingSutureService allows for the storage-sharing command to be embedded and supervised by a suture supervisor tree. type SharingSutureService struct { cfg *config.Config From 0e3b97ac03677e56f76b7e75c28af7330018e5b1 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 11:45:23 +0100 Subject: [PATCH 08/24] refactor storage-home tracing config --- storage/pkg/command/storagehome.go | 211 +++++++++++++---------------- 1 file changed, 92 insertions(+), 119 deletions(-) diff --git a/storage/pkg/command/storagehome.go b/storage/pkg/command/storagehome.go index 4e956c091a4..69da0b3090c 100644 --- a/storage/pkg/command/storagehome.go +++ b/storage/pkg/command/storagehome.go @@ -16,6 +16,7 @@ import ( "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" + "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" ) @@ -33,134 +34,57 @@ func StorageHome(cfg *config.Config) *cli.Command { Action: func(c *cli.Context) error { logger := NewLogger(cfg) - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - logger.Error(). - Str("type", t). - Msg("Storage only supports the jaeger tracing backend") - - case "jaeger": - logger.Info(). - Str("type", t). - Msg("configuring storage to use the jaeger tracing backend") - - case "zipkin": - logger.Error(). - Str("type", t). - Msg("Storage only supports the jaeger tracing backend") - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - } else { - logger.Debug(). - Msg("Tracing is not enabled") - } - - var ( - gr = run.Group{} - ctx, cancel = context.WithCancel(context.Background()) - //metrics = metrics.New() - ) + tracing.Configure(cfg, logger) + gr := run.Group{} + ctx, cancel := context.WithCancel(context.Background()) defer cancel() - { - uuid := uuid.Must(uuid.NewV4()) - pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") - - // override driver enable home option with home config - if cfg.Reva.Storages.Home.EnableHome { - cfg.Reva.Storages.Common.EnableHome = true - cfg.Reva.Storages.EOS.EnableHome = true - cfg.Reva.Storages.Local.EnableHome = true - cfg.Reva.Storages.OwnCloud.EnableHome = true - cfg.Reva.Storages.S3.EnableHome = true - } - rcfg := map[string]interface{}{ - "core": map[string]interface{}{ - "max_cpus": cfg.Reva.StorageHome.MaxCPUs, - "tracing_enabled": cfg.Tracing.Enabled, - "tracing_endpoint": cfg.Tracing.Endpoint, - "tracing_collector": cfg.Tracing.Collector, - "tracing_service_name": c.Command.Name, - }, - "shared": map[string]interface{}{ - "jwt_secret": cfg.Reva.JWTSecret, - "gatewaysvc": cfg.Reva.Gateway.Endpoint, - }, - "grpc": map[string]interface{}{ - "network": cfg.Reva.StorageHome.GRPCNetwork, - "address": cfg.Reva.StorageHome.GRPCAddr, - // TODO build services dynamically - "services": map[string]interface{}{ - "storageprovider": map[string]interface{}{ - "driver": cfg.Reva.StorageHome.Driver, - "drivers": drivers(cfg), - "mount_path": cfg.Reva.StorageHome.MountPath, - "mount_id": cfg.Reva.StorageHome.MountID, - "expose_data_server": cfg.Reva.StorageHome.ExposeDataServer, - "data_server_url": cfg.Reva.StorageHome.DataServerURL, - "tmp_folder": cfg.Reva.StorageHome.TempFolder, - }, - }, - }, - "http": map[string]interface{}{ - "network": cfg.Reva.StorageHome.HTTPNetwork, - "address": cfg.Reva.StorageHome.HTTPAddr, - // TODO build services dynamically - "services": map[string]interface{}{ - "dataprovider": map[string]interface{}{ - "prefix": cfg.Reva.StorageHome.HTTPPrefix, - "driver": cfg.Reva.StorageHome.Driver, - "drivers": drivers(cfg), - "timeout": 86400, - "insecure": true, - "disable_tus": false, - }, - }, - }, - } - - gr.Add(func() error { - runtime.RunWithOptions( - rcfg, - pidFile, - runtime.WithLogger(&logger.Logger), - ) - return nil - }, func(_ error) { - logger.Info(). - Str("server", c.Command.Name). - Msg("Shutting down server") - - cancel() - }) + uuid := uuid.Must(uuid.NewV4()) + pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") + + // override driver enable home option with home config + if cfg.Reva.Storages.Home.EnableHome { + cfg.Reva.Storages.Common.EnableHome = true + cfg.Reva.Storages.EOS.EnableHome = true + cfg.Reva.Storages.Local.EnableHome = true + cfg.Reva.Storages.OwnCloud.EnableHome = true + cfg.Reva.Storages.S3.EnableHome = true } + rcfg := storageHomeConfigFromStruct(c, cfg) - { - server, err := debug.Server( - debug.Name(c.Command.Name+"-debug"), - debug.Addr(cfg.Reva.StorageHome.DebugAddr), - debug.Logger(logger), - debug.Context(ctx), - debug.Config(cfg), + gr.Add(func() error { + runtime.RunWithOptions( + rcfg, + pidFile, + runtime.WithLogger(&logger.Logger), ) + return nil + }, func(_ error) { + logger.Info(). + Str("server", c.Command.Name). + Msg("Shutting down server") + + cancel() + }) + + debugServer, err := debug.Server( + debug.Name(c.Command.Name+"-debug"), + debug.Addr(cfg.Reva.StorageHome.DebugAddr), + debug.Logger(logger), + debug.Context(ctx), + debug.Config(cfg), + ) - if err != nil { - logger.Info().Err(err).Str("server", c.Command.Name+"-debug").Msg("Failed to initialize server") - return err - } - - gr.Add(server.ListenAndServe, func(_ error) { - cancel() - }) + if err != nil { + logger.Info().Err(err).Str("server", c.Command.Name+"-debug").Msg("Failed to initialize server") + return err } + gr.Add(debugServer.ListenAndServe, func(_ error) { + cancel() + }) + if !cfg.Reva.StorageMetadata.Supervised { sync.Trap(&gr, cancel) } @@ -170,6 +94,55 @@ func StorageHome(cfg *config.Config) *cli.Command { } } +// storageHomeConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service. +func storageHomeConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]interface{} { + rcfg := map[string]interface{}{ + "core": map[string]interface{}{ + "max_cpus": cfg.Reva.StorageHome.MaxCPUs, + "tracing_enabled": cfg.Tracing.Enabled, + "tracing_endpoint": cfg.Tracing.Endpoint, + "tracing_collector": cfg.Tracing.Collector, + "tracing_service_name": c.Command.Name, + }, + "shared": map[string]interface{}{ + "jwt_secret": cfg.Reva.JWTSecret, + "gatewaysvc": cfg.Reva.Gateway.Endpoint, + }, + "grpc": map[string]interface{}{ + "network": cfg.Reva.StorageHome.GRPCNetwork, + "address": cfg.Reva.StorageHome.GRPCAddr, + // TODO build services dynamically + "services": map[string]interface{}{ + "storageprovider": map[string]interface{}{ + "driver": cfg.Reva.StorageHome.Driver, + "drivers": drivers(cfg), + "mount_path": cfg.Reva.StorageHome.MountPath, + "mount_id": cfg.Reva.StorageHome.MountID, + "expose_data_server": cfg.Reva.StorageHome.ExposeDataServer, + "data_server_url": cfg.Reva.StorageHome.DataServerURL, + "tmp_folder": cfg.Reva.StorageHome.TempFolder, + }, + }, + }, + "http": map[string]interface{}{ + "network": cfg.Reva.StorageHome.HTTPNetwork, + "address": cfg.Reva.StorageHome.HTTPAddr, + // TODO build services dynamically + "services": map[string]interface{}{ + "dataprovider": map[string]interface{}{ + "prefix": cfg.Reva.StorageHome.HTTPPrefix, + "driver": cfg.Reva.StorageHome.Driver, + "drivers": drivers(cfg), + "timeout": 86400, + "insecure": true, + "disable_tus": false, + }, + }, + }, + } + return rcfg +} + // StorageHomeSutureService allows for the storage-home command to be embedded and supervised by a suture supervisor tree. type StorageHomeSutureService struct { cfg *config.Config From 07ecf3199c48637dcdda6457a16cb25091615101 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 11:47:51 +0100 Subject: [PATCH 09/24] refactor storage-metadata tracing config --- storage/pkg/command/storagemetadata.go | 232 +++++++++++-------------- 1 file changed, 103 insertions(+), 129 deletions(-) diff --git a/storage/pkg/command/storagemetadata.go b/storage/pkg/command/storagemetadata.go index 7669155579a..1d1e620f0f5 100644 --- a/storage/pkg/command/storagemetadata.go +++ b/storage/pkg/command/storagemetadata.go @@ -17,6 +17,7 @@ import ( "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/service/external" + "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" ) @@ -43,146 +44,70 @@ func StorageMetadata(cfg *config.Config) *cli.Command { }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - logger.Error(). - Str("type", t). - Msg("Reva only supports the jaeger tracing backend") - - case "jaeger": - logger.Info(). - Str("type", t). - Msg("configuring storage to use the jaeger tracing backend") - - case "zipkin": - logger.Error(). - Str("type", t). - Msg("Reva only supports the jaeger tracing backend") - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - } else { - logger.Debug(). - Msg("Tracing is not enabled") - } + tracing.Configure(cfg, logger) - var ( - gr = run.Group{} - ctx, cancel = func() (context.Context, context.CancelFunc) { - if cfg.Reva.StorageMetadata.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Reva.StorageMetadata.Context) - }() - ) + gr := run.Group{} + ctx, cancel := func() (context.Context, context.CancelFunc) { + if cfg.Reva.StorageMetadata.Context == nil { + return context.WithCancel(context.Background()) + } + return context.WithCancel(cfg.Reva.StorageMetadata.Context) + }() defer cancel() - { - uuid := uuid.Must(uuid.NewV4()) - pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") - - // Disable home because the metadata is stored independently - // of the user. This also means that a valid-token without any user-id - // is allowed to write to the metadata-storage. - cfg.Reva.Storages.Common.EnableHome = false - cfg.Reva.Storages.EOS.EnableHome = false - cfg.Reva.Storages.Local.EnableHome = false - cfg.Reva.Storages.OwnCloud.EnableHome = false - cfg.Reva.Storages.S3.EnableHome = false - - rcfg := map[string]interface{}{ - "core": map[string]interface{}{ - "max_cpus": cfg.Reva.StorageMetadata.MaxCPUs, - "tracing_enabled": cfg.Tracing.Enabled, - "tracing_endpoint": cfg.Tracing.Endpoint, - "tracing_collector": cfg.Tracing.Collector, - "tracing_service_name": c.Command.Name, - }, - "shared": map[string]interface{}{ - "jwt_secret": cfg.Reva.JWTSecret, - "gatewaysvc": cfg.Reva.Gateway.Endpoint, - }, - "grpc": map[string]interface{}{ - "network": cfg.Reva.StorageMetadata.GRPCNetwork, - "address": cfg.Reva.StorageMetadata.GRPCAddr, - "interceptors": map[string]interface{}{ - "log": map[string]interface{}{}, - }, - "services": map[string]interface{}{ - "storageprovider": map[string]interface{}{ - "mount_path": "/meta", - "driver": cfg.Reva.StorageMetadata.Driver, - "drivers": drivers(cfg), - "data_server_url": cfg.Reva.StorageMetadata.DataServerURL, - "tmp_folder": cfg.Reva.StorageMetadata.TempFolder, - }, - }, - }, - "http": map[string]interface{}{ - "network": cfg.Reva.StorageMetadata.HTTPNetwork, - "address": cfg.Reva.StorageMetadata.HTTPAddr, - // TODO build services dynamically - "services": map[string]interface{}{ - "dataprovider": map[string]interface{}{ - "prefix": "data", - "driver": cfg.Reva.StorageMetadata.Driver, - "drivers": drivers(cfg), - "timeout": 86400, - "insecure": true, - "disable_tus": true, - }, - }, - }, - } + pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") - gr.Add(func() error { - runtime.RunWithOptions( - rcfg, - pidFile, - runtime.WithLogger(&logger.Logger), - ) - return nil - }, func(_ error) { - logger.Info(). - Str("server", c.Command.Name). - Msg("Shutting down server") - - cancel() - }) - } + // Disable home because the metadata is stored independently + // of the user. This also means that a valid-token without any user-id + // is allowed to write to the metadata-storage. + cfg.Reva.Storages.Common.EnableHome = false + cfg.Reva.Storages.EOS.EnableHome = false + cfg.Reva.Storages.Local.EnableHome = false + cfg.Reva.Storages.OwnCloud.EnableHome = false + cfg.Reva.Storages.S3.EnableHome = false + + rcfg := storageMetadataFromStruct(c, cfg) - { - server, err := debug.Server( - debug.Name(c.Command.Name+"-debug"), - debug.Addr(cfg.Reva.StorageMetadata.DebugAddr), - debug.Logger(logger), - debug.Context(ctx), - debug.Config(cfg), + gr.Add(func() error { + runtime.RunWithOptions( + rcfg, + pidFile, + runtime.WithLogger(&logger.Logger), ) + return nil + }, func(_ error) { + logger.Info(). + Str("server", c.Command.Name). + Msg("Shutting down server") + + cancel() + }) + + debugServer, err := debug.Server( + debug.Name(c.Command.Name+"-debug"), + debug.Addr(cfg.Reva.StorageMetadata.DebugAddr), + debug.Logger(logger), + debug.Context(ctx), + debug.Config(cfg), + ) - if err != nil { - logger.Info(). - Err(err). - Str("server", c.Command.Name+"-debug"). - Msg("Failed to initialize server") + if err != nil { + logger.Info(). + Err(err). + Str("server", c.Command.Name+"-debug"). + Msg("Failed to initialize server") - return err - } - - gr.Add(func() error { - return server.ListenAndServe() - }, func(_ error) { - _ = server.Shutdown(ctx) - cancel() - }) + return err } + gr.Add(func() error { + return debugServer.ListenAndServe() + }, func(_ error) { + _ = debugServer.Shutdown(ctx) + cancel() + }) + if !cfg.Reva.StorageMetadata.Supervised { sync.Trap(&gr, cancel) } @@ -202,6 +127,55 @@ func StorageMetadata(cfg *config.Config) *cli.Command { } } +// storageMetadataFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service. +func storageMetadataFromStruct(c *cli.Context, cfg *config.Config) map[string]interface{} { + rcfg := map[string]interface{}{ + "core": map[string]interface{}{ + "max_cpus": cfg.Reva.StorageMetadata.MaxCPUs, + "tracing_enabled": cfg.Tracing.Enabled, + "tracing_endpoint": cfg.Tracing.Endpoint, + "tracing_collector": cfg.Tracing.Collector, + "tracing_service_name": c.Command.Name, + }, + "shared": map[string]interface{}{ + "jwt_secret": cfg.Reva.JWTSecret, + "gatewaysvc": cfg.Reva.Gateway.Endpoint, + }, + "grpc": map[string]interface{}{ + "network": cfg.Reva.StorageMetadata.GRPCNetwork, + "address": cfg.Reva.StorageMetadata.GRPCAddr, + "interceptors": map[string]interface{}{ + "log": map[string]interface{}{}, + }, + "services": map[string]interface{}{ + "storageprovider": map[string]interface{}{ + "mount_path": "/meta", + "driver": cfg.Reva.StorageMetadata.Driver, + "drivers": drivers(cfg), + "data_server_url": cfg.Reva.StorageMetadata.DataServerURL, + "tmp_folder": cfg.Reva.StorageMetadata.TempFolder, + }, + }, + }, + "http": map[string]interface{}{ + "network": cfg.Reva.StorageMetadata.HTTPNetwork, + "address": cfg.Reva.StorageMetadata.HTTPAddr, + // TODO build services dynamically + "services": map[string]interface{}{ + "dataprovider": map[string]interface{}{ + "prefix": "data", + "driver": cfg.Reva.StorageMetadata.Driver, + "drivers": drivers(cfg), + "timeout": 86400, + "insecure": true, + "disable_tus": true, + }, + }, + }, + } + return rcfg +} + // SutureService allows for the storage-metadata command to be embedded and supervised by a suture supervisor tree. type SutureService struct { cfg *config.Config From 938f6e8d73eb67607cbd5aa41c7c85f6841278a0 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 11:49:09 +0100 Subject: [PATCH 10/24] refactor storage-public-link tracing config --- storage/pkg/command/storagepubliclink.go | 177 ++++++++++------------- 1 file changed, 73 insertions(+), 104 deletions(-) diff --git a/storage/pkg/command/storagepubliclink.go b/storage/pkg/command/storagepubliclink.go index 5dbe9b965db..75922f5900d 100644 --- a/storage/pkg/command/storagepubliclink.go +++ b/storage/pkg/command/storagepubliclink.go @@ -15,6 +15,7 @@ import ( "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" + "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" ) @@ -27,117 +28,46 @@ func StoragePublicLink(cfg *config.Config) *cli.Command { Category: "Extensions", Action: func(c *cli.Context) error { logger := NewLogger(cfg) - - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - logger.Error(). - Str("type", t). - Msg("Reva only supports the jaeger tracing backend") - - case "jaeger": - logger.Info(). - Str("type", t). - Msg("configuring storage to use the jaeger tracing backend") - - case "zipkin": - logger.Error(). - Str("type", t). - Msg("Reva only supports the jaeger tracing backend") - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - } else { - logger.Debug(). - Msg("Tracing is not enabled") - } - - var ( - gr = run.Group{} - ctx, cancel = context.WithCancel(context.Background()) - //metrics = metrics.New() - ) - + tracing.Configure(cfg, logger) + gr := run.Group{} + ctx, cancel := context.WithCancel(context.Background()) defer cancel() - { - uuid := uuid.Must(uuid.NewV4()) - pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") - - rcfg := map[string]interface{}{ - "core": map[string]interface{}{ - "max_cpus": cfg.Reva.StoragePublicLink.MaxCPUs, - "tracing_enabled": cfg.Tracing.Enabled, - "tracing_endpoint": cfg.Tracing.Endpoint, - "tracing_collector": cfg.Tracing.Collector, - "tracing_service_name": c.Command.Name, - }, - "shared": map[string]interface{}{ - "jwt_secret": cfg.Reva.JWTSecret, - "gatewaysvc": cfg.Reva.Gateway.Endpoint, - }, - "grpc": map[string]interface{}{ - "network": cfg.Reva.StoragePublicLink.GRPCNetwork, - "address": cfg.Reva.StoragePublicLink.GRPCAddr, - "interceptors": map[string]interface{}{ - "log": map[string]interface{}{}, - }, - "services": map[string]interface{}{ - "publicstorageprovider": map[string]interface{}{ - "mount_path": cfg.Reva.StoragePublicLink.MountPath, - "gateway_addr": cfg.Reva.Gateway.Endpoint, - }, - "authprovider": map[string]interface{}{ - "auth_manager": "publicshares", - "auth_managers": map[string]interface{}{ - "publicshares": map[string]interface{}{ - "gateway_addr": cfg.Reva.Gateway.Endpoint, - }, - }, - }, - }, - }, - } - - gr.Add(func() error { - runtime.RunWithOptions( - rcfg, - pidFile, - runtime.WithLogger(&logger.Logger), - ) - return nil - }, func(_ error) { - logger.Info(). - Str("server", c.Command.Name). - Msg("Shutting down server") - - cancel() - }) - } + pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") + rcfg := storagePublicLinkConfigFromStruct(c, cfg) - { - server, err := debug.Server( - debug.Name(c.Command.Name+"-debug"), - debug.Addr(cfg.Reva.StoragePublicLink.DebugAddr), - debug.Logger(logger), - debug.Context(ctx), - debug.Config(cfg), + gr.Add(func() error { + runtime.RunWithOptions( + rcfg, + pidFile, + runtime.WithLogger(&logger.Logger), ) + return nil + }, func(_ error) { + logger.Info(). + Str("server", c.Command.Name). + Msg("Shutting down server") + + cancel() + }) + + debugServer, err := debug.Server( + debug.Name(c.Command.Name+"-debug"), + debug.Addr(cfg.Reva.StoragePublicLink.DebugAddr), + debug.Logger(logger), + debug.Context(ctx), + debug.Config(cfg), + ) - if err != nil { - logger.Info().Err(err).Str("server", c.Command.Name+"-debug").Msg("Failed to initialize server") - return err - } - - gr.Add(server.ListenAndServe, func(_ error) { - cancel() - }) + if err != nil { + logger.Info().Err(err).Str("server", c.Command.Name+"-debug").Msg("Failed to initialize server") + return err } + gr.Add(debugServer.ListenAndServe, func(_ error) { + cancel() + }) + if !cfg.Reva.StorageMetadata.Supervised { sync.Trap(&gr, cancel) } @@ -147,6 +77,45 @@ func StoragePublicLink(cfg *config.Config) *cli.Command { } } +// storagePublicLinkConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service. +func storagePublicLinkConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]interface{} { + rcfg := map[string]interface{}{ + "core": map[string]interface{}{ + "max_cpus": cfg.Reva.StoragePublicLink.MaxCPUs, + "tracing_enabled": cfg.Tracing.Enabled, + "tracing_endpoint": cfg.Tracing.Endpoint, + "tracing_collector": cfg.Tracing.Collector, + "tracing_service_name": c.Command.Name, + }, + "shared": map[string]interface{}{ + "jwt_secret": cfg.Reva.JWTSecret, + "gatewaysvc": cfg.Reva.Gateway.Endpoint, + }, + "grpc": map[string]interface{}{ + "network": cfg.Reva.StoragePublicLink.GRPCNetwork, + "address": cfg.Reva.StoragePublicLink.GRPCAddr, + "interceptors": map[string]interface{}{ + "log": map[string]interface{}{}, + }, + "services": map[string]interface{}{ + "publicstorageprovider": map[string]interface{}{ + "mount_path": cfg.Reva.StoragePublicLink.MountPath, + "gateway_addr": cfg.Reva.Gateway.Endpoint, + }, + "authprovider": map[string]interface{}{ + "auth_manager": "publicshares", + "auth_managers": map[string]interface{}{ + "publicshares": map[string]interface{}{ + "gateway_addr": cfg.Reva.Gateway.Endpoint, + }, + }, + }, + }, + }, + } + return rcfg +} + // StoragePublicLinkSutureService allows for the storage-public-link command to be embedded and supervised by a suture supervisor tree. type StoragePublicLinkSutureService struct { cfg *config.Config From 43675c4f14d15dd42fd131ebcb954f3d40a1375a Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 11:50:16 +0100 Subject: [PATCH 11/24] refactor storage-users tracing config --- storage/pkg/command/storageusers.go | 210 ++++++++++++---------------- 1 file changed, 92 insertions(+), 118 deletions(-) diff --git a/storage/pkg/command/storageusers.go b/storage/pkg/command/storageusers.go index e288fa7a995..6740b7c8e48 100644 --- a/storage/pkg/command/storageusers.go +++ b/storage/pkg/command/storageusers.go @@ -15,6 +15,7 @@ import ( "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" + "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" ) @@ -32,134 +33,58 @@ func StorageUsers(cfg *config.Config) *cli.Command { Action: func(c *cli.Context) error { logger := NewLogger(cfg) - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - logger.Error(). - Str("type", t). - Msg("Storage only supports the jaeger tracing backend") - - case "jaeger": - logger.Info(). - Str("type", t). - Msg("configuring storage to use the jaeger tracing backend") - - case "zipkin": - logger.Error(). - Str("type", t). - Msg("Storage only supports the jaeger tracing backend") - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - } else { - logger.Debug(). - Msg("Tracing is not enabled") - } + tracing.Configure(cfg, logger) - var ( - gr = run.Group{} - ctx, cancel = context.WithCancel(context.Background()) - //metrics = metrics.New() - ) + gr := run.Group{} + ctx, cancel := context.WithCancel(context.Background()) defer cancel() - { - uuid := uuid.Must(uuid.NewV4()) - pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") - - // override driver enable home option with home config - if cfg.Reva.Storages.Home.EnableHome { - cfg.Reva.Storages.Common.EnableHome = true - cfg.Reva.Storages.EOS.EnableHome = true - cfg.Reva.Storages.Local.EnableHome = true - cfg.Reva.Storages.OwnCloud.EnableHome = true - cfg.Reva.Storages.S3.EnableHome = true - } - rcfg := map[string]interface{}{ - "core": map[string]interface{}{ - "max_cpus": cfg.Reva.StorageUsers.MaxCPUs, - "tracing_enabled": cfg.Tracing.Enabled, - "tracing_endpoint": cfg.Tracing.Endpoint, - "tracing_collector": cfg.Tracing.Collector, - "tracing_service_name": c.Command.Name, - }, - "shared": map[string]interface{}{ - "jwt_secret": cfg.Reva.JWTSecret, - "gatewaysvc": cfg.Reva.Gateway.Endpoint, - }, - "grpc": map[string]interface{}{ - "network": cfg.Reva.StorageUsers.GRPCNetwork, - "address": cfg.Reva.StorageUsers.GRPCAddr, - // TODO build services dynamically - "services": map[string]interface{}{ - "storageprovider": map[string]interface{}{ - "driver": cfg.Reva.StorageUsers.Driver, - "drivers": drivers(cfg), - "mount_path": cfg.Reva.StorageUsers.MountPath, - "mount_id": cfg.Reva.StorageUsers.MountID, - "expose_data_server": cfg.Reva.StorageUsers.ExposeDataServer, - "data_server_url": cfg.Reva.StorageUsers.DataServerURL, - "tmp_folder": cfg.Reva.StorageUsers.TempFolder, - }, - }, - }, - "http": map[string]interface{}{ - "network": cfg.Reva.StorageUsers.HTTPNetwork, - "address": cfg.Reva.StorageUsers.HTTPAddr, - // TODO build services dynamically - "services": map[string]interface{}{ - "dataprovider": map[string]interface{}{ - "prefix": cfg.Reva.StorageUsers.HTTPPrefix, - "driver": cfg.Reva.StorageUsers.Driver, - "drivers": drivers(cfg), - "timeout": 86400, - "insecure": true, - "disable_tus": false, - }, - }, - }, - } - - gr.Add(func() error { - runtime.RunWithOptions( - rcfg, - pidFile, - runtime.WithLogger(&logger.Logger), - ) - return nil - }, func(_ error) { - logger.Info(). - Str("server", c.Command.Name). - Msg("Shutting down server") - - cancel() - }) + uuid := uuid.Must(uuid.NewV4()) + pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") + + // override driver enable home option with home config + if cfg.Reva.Storages.Home.EnableHome { + cfg.Reva.Storages.Common.EnableHome = true + cfg.Reva.Storages.EOS.EnableHome = true + cfg.Reva.Storages.Local.EnableHome = true + cfg.Reva.Storages.OwnCloud.EnableHome = true + cfg.Reva.Storages.S3.EnableHome = true } + rcfg := storageUsersConfigFromStruct(c, cfg) - { - server, err := debug.Server( - debug.Name(c.Command.Name+"-debug"), - debug.Addr(cfg.Reva.StorageUsers.DebugAddr), - debug.Logger(logger), - debug.Context(ctx), - debug.Config(cfg), + gr.Add(func() error { + runtime.RunWithOptions( + rcfg, + pidFile, + runtime.WithLogger(&logger.Logger), ) + return nil + }, func(_ error) { + logger.Info(). + Str("server", c.Command.Name). + Msg("Shutting down server") + + cancel() + }) + + debugServer, err := debug.Server( + debug.Name(c.Command.Name+"-debug"), + debug.Addr(cfg.Reva.StorageUsers.DebugAddr), + debug.Logger(logger), + debug.Context(ctx), + debug.Config(cfg), + ) - if err != nil { - logger.Info().Err(err).Str("server", c.Command.Name+"-debug").Msg("Failed to initialize server") - return err - } - - gr.Add(server.ListenAndServe, func(_ error) { - cancel() - }) + if err != nil { + logger.Info().Err(err).Str("server", c.Command.Name+"-debug").Msg("Failed to initialize server") + return err } + gr.Add(debugServer.ListenAndServe, func(_ error) { + cancel() + }) + if !cfg.Reva.StorageMetadata.Supervised { sync.Trap(&gr, cancel) } @@ -169,6 +94,55 @@ func StorageUsers(cfg *config.Config) *cli.Command { } } +// storageUsersConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service. +func storageUsersConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]interface{} { + rcfg := map[string]interface{}{ + "core": map[string]interface{}{ + "max_cpus": cfg.Reva.StorageUsers.MaxCPUs, + "tracing_enabled": cfg.Tracing.Enabled, + "tracing_endpoint": cfg.Tracing.Endpoint, + "tracing_collector": cfg.Tracing.Collector, + "tracing_service_name": c.Command.Name, + }, + "shared": map[string]interface{}{ + "jwt_secret": cfg.Reva.JWTSecret, + "gatewaysvc": cfg.Reva.Gateway.Endpoint, + }, + "grpc": map[string]interface{}{ + "network": cfg.Reva.StorageUsers.GRPCNetwork, + "address": cfg.Reva.StorageUsers.GRPCAddr, + // TODO build services dynamically + "services": map[string]interface{}{ + "storageprovider": map[string]interface{}{ + "driver": cfg.Reva.StorageUsers.Driver, + "drivers": drivers(cfg), + "mount_path": cfg.Reva.StorageUsers.MountPath, + "mount_id": cfg.Reva.StorageUsers.MountID, + "expose_data_server": cfg.Reva.StorageUsers.ExposeDataServer, + "data_server_url": cfg.Reva.StorageUsers.DataServerURL, + "tmp_folder": cfg.Reva.StorageUsers.TempFolder, + }, + }, + }, + "http": map[string]interface{}{ + "network": cfg.Reva.StorageUsers.HTTPNetwork, + "address": cfg.Reva.StorageUsers.HTTPAddr, + // TODO build services dynamically + "services": map[string]interface{}{ + "dataprovider": map[string]interface{}{ + "prefix": cfg.Reva.StorageUsers.HTTPPrefix, + "driver": cfg.Reva.StorageUsers.Driver, + "drivers": drivers(cfg), + "timeout": 86400, + "insecure": true, + "disable_tus": false, + }, + }, + }, + } + return rcfg +} + // StorageUsersSutureService allows for the storage-home command to be embedded and supervised by a suture supervisor tree. type StorageUsersSutureService struct { cfg *config.Config From f53d00b4ffc463448151034952d6262f1322a760 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 11:51:07 +0100 Subject: [PATCH 12/24] refactor users tracing config --- storage/pkg/command/users.go | 226 ++++++++++++++++------------------- 1 file changed, 100 insertions(+), 126 deletions(-) diff --git a/storage/pkg/command/users.go b/storage/pkg/command/users.go index d820db5a0a8..e264c5782ab 100644 --- a/storage/pkg/command/users.go +++ b/storage/pkg/command/users.go @@ -16,6 +16,7 @@ import ( "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" + "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" ) @@ -33,39 +34,10 @@ func Users(cfg *config.Config) *cli.Command { Action: func(c *cli.Context) error { logger := NewLogger(cfg) - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - logger.Error(). - Str("type", t). - Msg("Reva only supports the jaeger tracing backend") - - case "jaeger": - logger.Info(). - Str("type", t). - Msg("configuring storage to use the jaeger tracing backend") - - case "zipkin": - logger.Error(). - Str("type", t). - Msg("Reva only supports the jaeger tracing backend") - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - } else { - logger.Debug(). - Msg("Tracing is not enabled") - } + tracing.Configure(cfg, logger) - var ( - gr = run.Group{} - ctx, cancel = context.WithCancel(context.Background()) - //metrics = metrics.New() - ) + gr := run.Group{} + ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -76,106 +48,43 @@ func Users(cfg *config.Config) *cli.Command { } } - { - uuid := uuid.Must(uuid.NewV4()) - pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") - - rcfg := map[string]interface{}{ - "core": map[string]interface{}{ - "max_cpus": cfg.Reva.Users.MaxCPUs, - "tracing_enabled": cfg.Tracing.Enabled, - "tracing_endpoint": cfg.Tracing.Endpoint, - "tracing_collector": cfg.Tracing.Collector, - "tracing_service_name": c.Command.Name, - }, - "shared": map[string]interface{}{ - "jwt_secret": cfg.Reva.JWTSecret, - }, - "grpc": map[string]interface{}{ - "network": cfg.Reva.Users.GRPCNetwork, - "address": cfg.Reva.Users.GRPCAddr, - // TODO build services dynamically - "services": map[string]interface{}{ - "userprovider": map[string]interface{}{ - "driver": cfg.Reva.Users.Driver, - "drivers": map[string]interface{}{ - "json": map[string]interface{}{ - "users": cfg.Reva.Users.JSON, - }, - "ldap": map[string]interface{}{ - "hostname": cfg.Reva.LDAP.Hostname, - "port": cfg.Reva.LDAP.Port, - "base_dn": cfg.Reva.LDAP.BaseDN, - "userfilter": cfg.Reva.LDAP.UserFilter, - "attributefilter": cfg.Reva.LDAP.UserAttributeFilter, - "findfilter": cfg.Reva.LDAP.UserFindFilter, - "groupfilter": cfg.Reva.LDAP.UserGroupFilter, - "bind_username": cfg.Reva.LDAP.BindDN, - "bind_password": cfg.Reva.LDAP.BindPassword, - "idp": cfg.Reva.LDAP.IDP, - "schema": map[string]interface{}{ - "dn": "dn", - "uid": cfg.Reva.LDAP.UserSchema.UID, - "mail": cfg.Reva.LDAP.UserSchema.Mail, - "displayName": cfg.Reva.LDAP.UserSchema.DisplayName, - "cn": cfg.Reva.LDAP.UserSchema.CN, - "uidNumber": cfg.Reva.LDAP.UserSchema.UIDNumber, - "gidNumber": cfg.Reva.LDAP.UserSchema.GIDNumber, - }, - }, - "rest": map[string]interface{}{ - "client_id": cfg.Reva.UserGroupRest.ClientID, - "client_secret": cfg.Reva.UserGroupRest.ClientSecret, - "redis_address": cfg.Reva.UserGroupRest.RedisAddress, - "redis_username": cfg.Reva.UserGroupRest.RedisUsername, - "redis_password": cfg.Reva.UserGroupRest.RedisPassword, - "user_groups_cache_expiration": cfg.Reva.Users.UserGroupsCacheExpiration, - "id_provider": cfg.Reva.UserGroupRest.IDProvider, - "api_base_url": cfg.Reva.UserGroupRest.APIBaseURL, - "oidc_token_endpoint": cfg.Reva.UserGroupRest.OIDCTokenEndpoint, - "target_api": cfg.Reva.UserGroupRest.TargetAPI, - }, - }, - }, - }, - }, - } + uuid := uuid.Must(uuid.NewV4()) + pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid") - gr.Add(func() error { - runtime.RunWithOptions( - rcfg, - pidFile, - runtime.WithLogger(&logger.Logger), - ) - return nil - }, func(_ error) { - logger.Info(). - Str("server", c.Command.Name). - Msg("Shutting down server") - - cancel() - }) - } + rcfg := usersConfigFromStruct(c, cfg) - { - server, err := debug.Server( - debug.Name(c.Command.Name+"-debug"), - debug.Addr(cfg.Reva.Users.DebugAddr), - debug.Logger(logger), - debug.Context(ctx), - debug.Config(cfg), + gr.Add(func() error { + runtime.RunWithOptions( + rcfg, + pidFile, + runtime.WithLogger(&logger.Logger), ) + return nil + }, func(_ error) { + logger.Info(). + Str("server", c.Command.Name). + Msg("Shutting down server") + + cancel() + }) + + debugServer, err := debug.Server( + debug.Name(c.Command.Name+"-debug"), + debug.Addr(cfg.Reva.Users.DebugAddr), + debug.Logger(logger), + debug.Context(ctx), + debug.Config(cfg), + ) - if err != nil { - logger.Info().Err(err).Str("server", c.Command.Name+"-debug").Msg("Failed to initialize server") - return err - } - - gr.Add(server.ListenAndServe, func(_ error) { - cancel() - }) + if err != nil { + logger.Info().Err(err).Str("server", c.Command.Name+"-debug").Msg("Failed to initialize server") + return err } + gr.Add(debugServer.ListenAndServe, func(_ error) { + cancel() + }) + if !cfg.Reva.StorageMetadata.Supervised { sync.Trap(&gr, cancel) } @@ -185,6 +94,71 @@ func Users(cfg *config.Config) *cli.Command { } } +// usersConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service. +func usersConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]interface{} { + rcfg := map[string]interface{}{ + "core": map[string]interface{}{ + "max_cpus": cfg.Reva.Users.MaxCPUs, + "tracing_enabled": cfg.Tracing.Enabled, + "tracing_endpoint": cfg.Tracing.Endpoint, + "tracing_collector": cfg.Tracing.Collector, + "tracing_service_name": c.Command.Name, + }, + "shared": map[string]interface{}{ + "jwt_secret": cfg.Reva.JWTSecret, + }, + "grpc": map[string]interface{}{ + "network": cfg.Reva.Users.GRPCNetwork, + "address": cfg.Reva.Users.GRPCAddr, + // TODO build services dynamically + "services": map[string]interface{}{ + "userprovider": map[string]interface{}{ + "driver": cfg.Reva.Users.Driver, + "drivers": map[string]interface{}{ + "json": map[string]interface{}{ + "users": cfg.Reva.Users.JSON, + }, + "ldap": map[string]interface{}{ + "hostname": cfg.Reva.LDAP.Hostname, + "port": cfg.Reva.LDAP.Port, + "base_dn": cfg.Reva.LDAP.BaseDN, + "userfilter": cfg.Reva.LDAP.UserFilter, + "attributefilter": cfg.Reva.LDAP.UserAttributeFilter, + "findfilter": cfg.Reva.LDAP.UserFindFilter, + "groupfilter": cfg.Reva.LDAP.UserGroupFilter, + "bind_username": cfg.Reva.LDAP.BindDN, + "bind_password": cfg.Reva.LDAP.BindPassword, + "idp": cfg.Reva.LDAP.IDP, + "schema": map[string]interface{}{ + "dn": "dn", + "uid": cfg.Reva.LDAP.UserSchema.UID, + "mail": cfg.Reva.LDAP.UserSchema.Mail, + "displayName": cfg.Reva.LDAP.UserSchema.DisplayName, + "cn": cfg.Reva.LDAP.UserSchema.CN, + "uidNumber": cfg.Reva.LDAP.UserSchema.UIDNumber, + "gidNumber": cfg.Reva.LDAP.UserSchema.GIDNumber, + }, + }, + "rest": map[string]interface{}{ + "client_id": cfg.Reva.UserGroupRest.ClientID, + "client_secret": cfg.Reva.UserGroupRest.ClientSecret, + "redis_address": cfg.Reva.UserGroupRest.RedisAddress, + "redis_username": cfg.Reva.UserGroupRest.RedisUsername, + "redis_password": cfg.Reva.UserGroupRest.RedisPassword, + "user_groups_cache_expiration": cfg.Reva.Users.UserGroupsCacheExpiration, + "id_provider": cfg.Reva.UserGroupRest.IDProvider, + "api_base_url": cfg.Reva.UserGroupRest.APIBaseURL, + "oidc_token_endpoint": cfg.Reva.UserGroupRest.OIDCTokenEndpoint, + "target_api": cfg.Reva.UserGroupRest.TargetAPI, + }, + }, + }, + }, + }, + } + return rcfg +} + // UsersProviderService allows for the storage-userprovider command to be embedded and supervised by a suture supervisor tree. type UsersProviderService struct { cfg *config.Config From 9a53c41552ed96cc4f5b07ef3a884d7aeba7944d Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 12:05:08 +0100 Subject: [PATCH 13/24] refactor glauth tracing config --- glauth/pkg/command/server.go | 124 ++++------------------------------ glauth/pkg/tracing/tracing.go | 90 ++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 111 deletions(-) create mode 100644 glauth/pkg/tracing/tracing.go diff --git a/glauth/pkg/command/server.go b/glauth/pkg/command/server.go index 9a0cf021dea..182fef9938e 100644 --- a/glauth/pkg/command/server.go +++ b/glauth/pkg/command/server.go @@ -3,32 +3,20 @@ package command import ( "context" "strings" - "time" - "github.com/owncloud/ocis/ocis-pkg/sync" - - "github.com/owncloud/ocis/ocis-pkg/service/grpc" - - "github.com/owncloud/ocis/glauth/pkg/metrics" - - "github.com/owncloud/ocis/glauth/pkg/crypto" - - "contrib.go.opencensus.io/exporter/jaeger" - "contrib.go.opencensus.io/exporter/ocagent" - "contrib.go.opencensus.io/exporter/zipkin" glauthcfg "github.com/glauth/glauth/pkg/config" - "github.com/micro/cli/v2" "github.com/oklog/run" - openzipkin "github.com/openzipkin/zipkin-go" - zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" accounts "github.com/owncloud/ocis/accounts/pkg/proto/v0" "github.com/owncloud/ocis/glauth/pkg/config" + "github.com/owncloud/ocis/glauth/pkg/crypto" "github.com/owncloud/ocis/glauth/pkg/flagset" + "github.com/owncloud/ocis/glauth/pkg/metrics" "github.com/owncloud/ocis/glauth/pkg/server/debug" "github.com/owncloud/ocis/glauth/pkg/server/glauth" - "go.opencensus.io/stats/view" - "go.opencensus.io/trace" + "github.com/owncloud/ocis/glauth/pkg/tracing" + "github.com/owncloud/ocis/ocis-pkg/service/grpc" + "github.com/owncloud/ocis/ocis-pkg/sync" ) // Server is the entrypoint for the server command. @@ -53,102 +41,16 @@ func Server(cfg *config.Config) *cli.Command { Action: func(c *cli.Context) error { logger := NewLogger(cfg) - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - exporter, err := ocagent.NewExporter( - ocagent.WithReconnectionPeriod(5*time.Second), - ocagent.WithAddress(cfg.Tracing.Endpoint), - ocagent.WithServiceName(cfg.Tracing.Service), - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create agent tracing") - - return err - } - - trace.RegisterExporter(exporter) - view.RegisterExporter(exporter) + tracing.Configure(cfg, logger) - case "jaeger": - exporter, err := jaeger.NewExporter( - jaeger.Options{ - AgentEndpoint: cfg.Tracing.Endpoint, - CollectorEndpoint: cfg.Tracing.Collector, - Process: jaeger.Process{ - ServiceName: cfg.Tracing.Service, - }, - }, - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create jaeger tracing") - - return err - } - - trace.RegisterExporter(exporter) - - case "zipkin": - endpoint, err := openzipkin.NewEndpoint( - cfg.Tracing.Service, - cfg.Tracing.Endpoint, - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create zipkin tracing") - - return err - } - - exporter := zipkin.NewExporter( - zipkinhttp.NewReporter( - cfg.Tracing.Collector, - ), - endpoint, - ) - - trace.RegisterExporter(exporter) - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") + gr := run.Group{} + ctx, cancel := func() (context.Context, context.CancelFunc) { + if cfg.Context == nil { + return context.WithCancel(context.Background()) } - - trace.ApplyConfig( - trace.Config{ - DefaultSampler: trace.AlwaysSample(), - }, - ) - } else { - logger.Debug(). - Msg("Tracing is not enabled") - } - - var ( - gr = run.Group{} - ctx, cancel = func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() - metrics = metrics.New() - ) + return context.WithCancel(cfg.Context) + }() + metrics := metrics.New() defer cancel() diff --git a/glauth/pkg/tracing/tracing.go b/glauth/pkg/tracing/tracing.go new file mode 100644 index 00000000000..74034fb6162 --- /dev/null +++ b/glauth/pkg/tracing/tracing.go @@ -0,0 +1,90 @@ +package tracing + +import ( + "time" + + "contrib.go.opencensus.io/exporter/jaeger" + "contrib.go.opencensus.io/exporter/ocagent" + "contrib.go.opencensus.io/exporter/zipkin" + openzipkin "github.com/openzipkin/zipkin-go" + zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" + "github.com/owncloud/ocis/glauth/pkg/config" + "github.com/owncloud/ocis/ocis-pkg/log" + "go.opencensus.io/stats/view" + "go.opencensus.io/trace" +) + +func Configure(cfg *config.Config, logger log.Logger) error { + if cfg.Tracing.Enabled { + switch t := cfg.Tracing.Type; t { + case "agent": + exporter, err := ocagent.NewExporter( + ocagent.WithReconnectionPeriod(5*time.Second), + ocagent.WithAddress(cfg.Tracing.Endpoint), + ocagent.WithServiceName(cfg.Tracing.Service), + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create agent tracing") + return err + } + trace.RegisterExporter(exporter) + view.RegisterExporter(exporter) + case "jaeger": + exporter, err := jaeger.NewExporter( + jaeger.Options{ + AgentEndpoint: cfg.Tracing.Endpoint, + CollectorEndpoint: cfg.Tracing.Collector, + Process: jaeger.Process{ + ServiceName: cfg.Tracing.Service, + }, + }, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create jaeger tracing") + return err + } + trace.RegisterExporter(exporter) + case "zipkin": + endpoint, err := openzipkin.NewEndpoint( + cfg.Tracing.Service, + cfg.Tracing.Endpoint, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create zipkin tracing") + return err + } + exporter := zipkin.NewExporter( + zipkinhttp.NewReporter( + cfg.Tracing.Collector, + ), + endpoint, + ) + trace.RegisterExporter(exporter) + default: + logger.Warn(). + Str("type", t). + Msg("Unknown tracing backend") + } + trace.ApplyConfig( + trace.Config{ + DefaultSampler: trace.AlwaysSample(), + }, + ) + } else { + logger.Debug(). + Msg("Tracing is not enabled") + } + return nil +} From 1d49a267f2f5ee13303cc14c81cf71a053318fa4 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 12:09:00 +0100 Subject: [PATCH 14/24] handle error + refactor graph tracing config --- glauth/pkg/command/server.go | 4 +- graph/pkg/command/server.go | 111 ++++------------------------------- graph/pkg/tracing/tracing.go | 90 ++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 101 deletions(-) create mode 100644 graph/pkg/tracing/tracing.go diff --git a/glauth/pkg/command/server.go b/glauth/pkg/command/server.go index 182fef9938e..3fa6d6db502 100644 --- a/glauth/pkg/command/server.go +++ b/glauth/pkg/command/server.go @@ -41,7 +41,9 @@ func Server(cfg *config.Config) *cli.Command { Action: func(c *cli.Context) error { logger := NewLogger(cfg) - tracing.Configure(cfg, logger) + if err := tracing.Configure(cfg, logger); err != nil { + return err + } gr := run.Group{} ctx, cancel := func() (context.Context, context.CancelFunc) { diff --git a/graph/pkg/command/server.go b/graph/pkg/command/server.go index bb184c8e17c..e186c23eb5c 100644 --- a/graph/pkg/command/server.go +++ b/graph/pkg/command/server.go @@ -3,23 +3,16 @@ package command import ( "context" "strings" - "time" - "contrib.go.opencensus.io/exporter/jaeger" - "contrib.go.opencensus.io/exporter/ocagent" - "contrib.go.opencensus.io/exporter/zipkin" "github.com/micro/cli/v2" "github.com/oklog/run" - openzipkin "github.com/openzipkin/zipkin-go" - zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" "github.com/owncloud/ocis/graph/pkg/config" "github.com/owncloud/ocis/graph/pkg/flagset" "github.com/owncloud/ocis/graph/pkg/metrics" "github.com/owncloud/ocis/graph/pkg/server/debug" "github.com/owncloud/ocis/graph/pkg/server/http" + "github.com/owncloud/ocis/graph/pkg/tracing" "github.com/owncloud/ocis/ocis-pkg/sync" - "go.opencensus.io/stats/view" - "go.opencensus.io/trace" ) // Server is the entrypoint for the server command. @@ -45,100 +38,18 @@ func Server(cfg *config.Config) *cli.Command { Action: func(c *cli.Context) error { logger := NewLogger(cfg) - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - exporter, err := ocagent.NewExporter( - ocagent.WithReconnectionPeriod(5*time.Second), - ocagent.WithAddress(cfg.Tracing.Endpoint), - ocagent.WithServiceName(cfg.Tracing.Service), - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create agent tracing") - - return err - } - - trace.RegisterExporter(exporter) - view.RegisterExporter(exporter) - - case "jaeger": - exporter, err := jaeger.NewExporter( - jaeger.Options{ - AgentEndpoint: cfg.Tracing.Endpoint, - CollectorEndpoint: cfg.Tracing.Collector, - ServiceName: cfg.Tracing.Service, - }, - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create jaeger tracing") - - return err - } - - trace.RegisterExporter(exporter) - - case "zipkin": - endpoint, err := openzipkin.NewEndpoint( - cfg.Tracing.Service, - cfg.Tracing.Endpoint, - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create zipkin tracing") - - return err - } - - exporter := zipkin.NewExporter( - zipkinhttp.NewReporter( - cfg.Tracing.Collector, - ), - endpoint, - ) - - trace.RegisterExporter(exporter) - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - trace.ApplyConfig( - trace.Config{ - DefaultSampler: trace.AlwaysSample(), - }, - ) - } else { - logger.Debug(). - Msg("Tracing is not enabled") + if err := tracing.Configure(cfg, logger); err != nil { + return err } - var ( - gr = run.Group{} - ctx, cancel = func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() - mtrcs = metrics.New() - ) + gr := run.Group{} + ctx, cancel := func() (context.Context, context.CancelFunc) { + if cfg.Context == nil { + return context.WithCancel(context.Background()) + } + return context.WithCancel(cfg.Context) + }() + mtrcs := metrics.New() defer cancel() diff --git a/graph/pkg/tracing/tracing.go b/graph/pkg/tracing/tracing.go new file mode 100644 index 00000000000..124d9238bd6 --- /dev/null +++ b/graph/pkg/tracing/tracing.go @@ -0,0 +1,90 @@ +package tracing + +import ( + "time" + + "contrib.go.opencensus.io/exporter/jaeger" + "contrib.go.opencensus.io/exporter/ocagent" + "contrib.go.opencensus.io/exporter/zipkin" + openzipkin "github.com/openzipkin/zipkin-go" + zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" + "github.com/owncloud/ocis/graph/pkg/config" + "github.com/owncloud/ocis/ocis-pkg/log" + "go.opencensus.io/stats/view" + "go.opencensus.io/trace" +) + +func Configure(cfg *config.Config, logger log.Logger) error { + if cfg.Tracing.Enabled { + switch t := cfg.Tracing.Type; t { + case "agent": + exporter, err := ocagent.NewExporter( + ocagent.WithReconnectionPeriod(5*time.Second), + ocagent.WithAddress(cfg.Tracing.Endpoint), + ocagent.WithServiceName(cfg.Tracing.Service), + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create agent tracing") + return err + } + trace.RegisterExporter(exporter) + view.RegisterExporter(exporter) + case "jaeger": + exporter, err := jaeger.NewExporter( + jaeger.Options{ + AgentEndpoint: cfg.Tracing.Endpoint, + CollectorEndpoint: cfg.Tracing.Collector, + Process: jaeger.Process{ + ServiceName: cfg.Tracing.Service, + }, + }, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create jaeger tracing") + return err + } + trace.RegisterExporter(exporter) + case "zipkin": + endpoint, err := openzipkin.NewEndpoint( + cfg.Tracing.Service, + cfg.Tracing.Endpoint, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create zipkin tracing") + return err + } + exporter := zipkin.NewExporter( + zipkinhttp.NewReporter( + cfg.Tracing.Collector, + ), + endpoint, + ) + trace.RegisterExporter(exporter) + default: + logger.Warn(). + Str("type", t). + Msg("Unknown tracing backend") + } + trace.ApplyConfig( + trace.Config{ + DefaultSampler: trace.AlwaysSample(), + }, + ) + } else { + logger.Debug(). + Msg("Tracing is not enabled") + } + return nil +} From cd41f1c8dc3ee2112533d4d8c330c4d6989f745c Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 12:10:36 +0100 Subject: [PATCH 15/24] refactor graph-explorer tracing config --- graph-explorer/pkg/command/server.go | 93 +-------------------------- graph-explorer/pkg/tracing/tracing.go | 90 ++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 91 deletions(-) create mode 100644 graph-explorer/pkg/tracing/tracing.go diff --git a/graph-explorer/pkg/command/server.go b/graph-explorer/pkg/command/server.go index 4a273578654..9c3e4266983 100644 --- a/graph-explorer/pkg/command/server.go +++ b/graph-explorer/pkg/command/server.go @@ -3,23 +3,16 @@ package command import ( "context" "strings" - "time" - "contrib.go.opencensus.io/exporter/jaeger" - "contrib.go.opencensus.io/exporter/ocagent" - "contrib.go.opencensus.io/exporter/zipkin" "github.com/micro/cli/v2" "github.com/oklog/run" - openzipkin "github.com/openzipkin/zipkin-go" - zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" "github.com/owncloud/ocis/graph-explorer/pkg/config" "github.com/owncloud/ocis/graph-explorer/pkg/flagset" "github.com/owncloud/ocis/graph-explorer/pkg/metrics" "github.com/owncloud/ocis/graph-explorer/pkg/server/debug" "github.com/owncloud/ocis/graph-explorer/pkg/server/http" + "github.com/owncloud/ocis/graph-explorer/pkg/tracing" "github.com/owncloud/ocis/ocis-pkg/sync" - "go.opencensus.io/stats/view" - "go.opencensus.io/trace" ) // Server is the entrypoint for the server command. @@ -45,89 +38,7 @@ func Server(cfg *config.Config) *cli.Command { Action: func(c *cli.Context) error { logger := NewLogger(cfg) - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - exporter, err := ocagent.NewExporter( - ocagent.WithReconnectionPeriod(5*time.Second), - ocagent.WithAddress(cfg.Tracing.Endpoint), - ocagent.WithServiceName(cfg.Tracing.Service), - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create agent tracing") - - return err - } - - trace.RegisterExporter(exporter) - view.RegisterExporter(exporter) - - case "jaeger": - exporter, err := jaeger.NewExporter( - jaeger.Options{ - AgentEndpoint: cfg.Tracing.Endpoint, - CollectorEndpoint: cfg.Tracing.Collector, - ServiceName: cfg.Tracing.Service, - }, - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create jaeger tracing") - - return err - } - - trace.RegisterExporter(exporter) - - case "zipkin": - endpoint, err := openzipkin.NewEndpoint( - cfg.Tracing.Service, - cfg.Tracing.Endpoint, - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create zipkin tracing") - - return err - } - - exporter := zipkin.NewExporter( - zipkinhttp.NewReporter( - cfg.Tracing.Collector, - ), - endpoint, - ) - - trace.RegisterExporter(exporter) - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - trace.ApplyConfig( - trace.Config{ - DefaultSampler: trace.AlwaysSample(), - }, - ) - } else { - logger.Debug(). - Msg("Tracing is not enabled") - } + tracing.Configure(cfg, logger) var ( gr = run.Group{} diff --git a/graph-explorer/pkg/tracing/tracing.go b/graph-explorer/pkg/tracing/tracing.go new file mode 100644 index 00000000000..3ee186c1834 --- /dev/null +++ b/graph-explorer/pkg/tracing/tracing.go @@ -0,0 +1,90 @@ +package tracing + +import ( + "time" + + "contrib.go.opencensus.io/exporter/jaeger" + "contrib.go.opencensus.io/exporter/ocagent" + "contrib.go.opencensus.io/exporter/zipkin" + openzipkin "github.com/openzipkin/zipkin-go" + zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" + "github.com/owncloud/ocis/graph-explorer/pkg/config" + "github.com/owncloud/ocis/ocis-pkg/log" + "go.opencensus.io/stats/view" + "go.opencensus.io/trace" +) + +func Configure(cfg *config.Config, logger log.Logger) error { + if cfg.Tracing.Enabled { + switch t := cfg.Tracing.Type; t { + case "agent": + exporter, err := ocagent.NewExporter( + ocagent.WithReconnectionPeriod(5*time.Second), + ocagent.WithAddress(cfg.Tracing.Endpoint), + ocagent.WithServiceName(cfg.Tracing.Service), + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create agent tracing") + return err + } + trace.RegisterExporter(exporter) + view.RegisterExporter(exporter) + case "jaeger": + exporter, err := jaeger.NewExporter( + jaeger.Options{ + AgentEndpoint: cfg.Tracing.Endpoint, + CollectorEndpoint: cfg.Tracing.Collector, + Process: jaeger.Process{ + ServiceName: cfg.Tracing.Service, + }, + }, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create jaeger tracing") + return err + } + trace.RegisterExporter(exporter) + case "zipkin": + endpoint, err := openzipkin.NewEndpoint( + cfg.Tracing.Service, + cfg.Tracing.Endpoint, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create zipkin tracing") + return err + } + exporter := zipkin.NewExporter( + zipkinhttp.NewReporter( + cfg.Tracing.Collector, + ), + endpoint, + ) + trace.RegisterExporter(exporter) + default: + logger.Warn(). + Str("type", t). + Msg("Unknown tracing backend") + } + trace.ApplyConfig( + trace.Config{ + DefaultSampler: trace.AlwaysSample(), + }, + ) + } else { + logger.Debug(). + Msg("Tracing is not enabled") + } + return nil +} From 3872cb07ed5fe1d9906e0ad6bd1c78f5e641fd9c Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 12:11:52 +0100 Subject: [PATCH 16/24] refactor idp tracing config --- idp/pkg/command/server.go | 102 ++----------------------------------- idp/pkg/tracing/tracing.go | 90 ++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 99 deletions(-) create mode 100644 idp/pkg/tracing/tracing.go diff --git a/idp/pkg/command/server.go b/idp/pkg/command/server.go index 0c3dbfdf258..ba9fde6686b 100644 --- a/idp/pkg/command/server.go +++ b/idp/pkg/command/server.go @@ -3,24 +3,16 @@ package command import ( "context" "strings" - "time" - "github.com/owncloud/ocis/ocis-pkg/sync" - - "contrib.go.opencensus.io/exporter/jaeger" - "contrib.go.opencensus.io/exporter/ocagent" - "contrib.go.opencensus.io/exporter/zipkin" "github.com/micro/cli/v2" "github.com/oklog/run" - openzipkin "github.com/openzipkin/zipkin-go" - zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" "github.com/owncloud/ocis/idp/pkg/config" "github.com/owncloud/ocis/idp/pkg/flagset" "github.com/owncloud/ocis/idp/pkg/metrics" "github.com/owncloud/ocis/idp/pkg/server/debug" "github.com/owncloud/ocis/idp/pkg/server/http" - "go.opencensus.io/stats/view" - "go.opencensus.io/trace" + "github.com/owncloud/ocis/idp/pkg/tracing" + "github.com/owncloud/ocis/ocis-pkg/sync" ) // Server is the entrypoint for the server command. @@ -58,95 +50,7 @@ func Server(cfg *config.Config) *cli.Command { Action: func(c *cli.Context) error { logger := NewLogger(cfg) - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - exporter, err := ocagent.NewExporter( - ocagent.WithReconnectionPeriod(5*time.Second), - ocagent.WithAddress(cfg.Tracing.Endpoint), - ocagent.WithServiceName(cfg.Tracing.Service), - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create agent tracing") - - return err - } - - trace.RegisterExporter(exporter) - view.RegisterExporter(exporter) - - case "jaeger": - exporter, err := jaeger.NewExporter( - jaeger.Options{ - AgentEndpoint: cfg.Tracing.Endpoint, - CollectorEndpoint: cfg.Tracing.Collector, - Process: jaeger.Process{ - ServiceName: cfg.Tracing.Service, - }, - }, - ) - - logger.Info(). - Str("collector", cfg.Tracing.Collector). - Msg("Trace collector added") - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create jaeger tracing") - - return err - } - - trace.RegisterExporter(exporter) - - case "zipkin": - endpoint, err := openzipkin.NewEndpoint( - cfg.Tracing.Service, - cfg.Tracing.Endpoint, - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create zipkin tracing") - - return err - } - - exporter := zipkin.NewExporter( - zipkinhttp.NewReporter( - cfg.Tracing.Collector, - ), - endpoint, - ) - - trace.RegisterExporter(exporter) - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - trace.ApplyConfig( - trace.Config{ - DefaultSampler: trace.AlwaysSample(), - }, - ) - } else { - logger.Debug(). - Msg("Tracing is not enabled") - } + tracing.Configure(cfg, logger) var ( gr = run.Group{} diff --git a/idp/pkg/tracing/tracing.go b/idp/pkg/tracing/tracing.go new file mode 100644 index 00000000000..cfda141a4f6 --- /dev/null +++ b/idp/pkg/tracing/tracing.go @@ -0,0 +1,90 @@ +package tracing + +import ( + "time" + + "contrib.go.opencensus.io/exporter/jaeger" + "contrib.go.opencensus.io/exporter/ocagent" + "contrib.go.opencensus.io/exporter/zipkin" + openzipkin "github.com/openzipkin/zipkin-go" + zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" + "github.com/owncloud/ocis/idp/pkg/config" + "github.com/owncloud/ocis/ocis-pkg/log" + "go.opencensus.io/stats/view" + "go.opencensus.io/trace" +) + +func Configure(cfg *config.Config, logger log.Logger) error { + if cfg.Tracing.Enabled { + switch t := cfg.Tracing.Type; t { + case "agent": + exporter, err := ocagent.NewExporter( + ocagent.WithReconnectionPeriod(5*time.Second), + ocagent.WithAddress(cfg.Tracing.Endpoint), + ocagent.WithServiceName(cfg.Tracing.Service), + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create agent tracing") + return err + } + trace.RegisterExporter(exporter) + view.RegisterExporter(exporter) + case "jaeger": + exporter, err := jaeger.NewExporter( + jaeger.Options{ + AgentEndpoint: cfg.Tracing.Endpoint, + CollectorEndpoint: cfg.Tracing.Collector, + Process: jaeger.Process{ + ServiceName: cfg.Tracing.Service, + }, + }, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create jaeger tracing") + return err + } + trace.RegisterExporter(exporter) + case "zipkin": + endpoint, err := openzipkin.NewEndpoint( + cfg.Tracing.Service, + cfg.Tracing.Endpoint, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create zipkin tracing") + return err + } + exporter := zipkin.NewExporter( + zipkinhttp.NewReporter( + cfg.Tracing.Collector, + ), + endpoint, + ) + trace.RegisterExporter(exporter) + default: + logger.Warn(). + Str("type", t). + Msg("Unknown tracing backend") + } + trace.ApplyConfig( + trace.Config{ + DefaultSampler: trace.AlwaysSample(), + }, + ) + } else { + logger.Debug(). + Msg("Tracing is not enabled") + } + return nil +} From 8b48a3223fcd54dd656a51ff2728336f755e1eb6 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 12:23:07 +0100 Subject: [PATCH 17/24] refactor ocs tracing config --- ocs/pkg/command/server.go | 100 ++----------------------------------- ocs/pkg/tracing/tracing.go | 90 +++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 96 deletions(-) create mode 100644 ocs/pkg/tracing/tracing.go diff --git a/ocs/pkg/command/server.go b/ocs/pkg/command/server.go index 07e31fa5b3b..c88a242948d 100644 --- a/ocs/pkg/command/server.go +++ b/ocs/pkg/command/server.go @@ -3,24 +3,18 @@ package command import ( "context" "strings" - "time" + + "github.com/owncloud/ocis/ocs/pkg/tracing" "github.com/owncloud/ocis/ocis-pkg/sync" - "contrib.go.opencensus.io/exporter/jaeger" - "contrib.go.opencensus.io/exporter/ocagent" - "contrib.go.opencensus.io/exporter/zipkin" "github.com/micro/cli/v2" "github.com/oklog/run" - openzipkin "github.com/openzipkin/zipkin-go" - zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" "github.com/owncloud/ocis/ocs/pkg/config" "github.com/owncloud/ocis/ocs/pkg/flagset" "github.com/owncloud/ocis/ocs/pkg/metrics" "github.com/owncloud/ocis/ocs/pkg/server/debug" "github.com/owncloud/ocis/ocs/pkg/server/http" - "go.opencensus.io/stats/view" - "go.opencensus.io/trace" ) // Server is the entrypoint for the server command. @@ -44,94 +38,8 @@ func Server(cfg *config.Config) *cli.Command { Action: func(c *cli.Context) error { logger := NewLogger(cfg) - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - exporter, err := ocagent.NewExporter( - ocagent.WithReconnectionPeriod(5*time.Second), - ocagent.WithAddress(cfg.Tracing.Endpoint), - ocagent.WithServiceName(cfg.Tracing.Service), - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create agent tracing") - - return err - } - - trace.RegisterExporter(exporter) - view.RegisterExporter(exporter) - - case "jaeger": - exporter, err := jaeger.NewExporter( - jaeger.Options{ - AgentEndpoint: cfg.Tracing.Endpoint, - CollectorEndpoint: cfg.Tracing.Collector, - Process: jaeger.Process{ - ServiceName: cfg.Tracing.Service, - }, - }, - ) - - logger.Info(). - Str("collector", cfg.Tracing.Collector). - Msg("Trace collector added") - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create jaeger tracing") - - return err - } - - trace.RegisterExporter(exporter) - - case "zipkin": - endpoint, err := openzipkin.NewEndpoint( - cfg.Tracing.Service, - cfg.Tracing.Endpoint, - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create zipkin tracing") - - return err - } - - exporter := zipkin.NewExporter( - zipkinhttp.NewReporter( - cfg.Tracing.Collector, - ), - endpoint, - ) - - trace.RegisterExporter(exporter) - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - trace.ApplyConfig( - trace.Config{ - DefaultSampler: trace.AlwaysSample(), - }, - ) - } else { - logger.Debug(). - Msg("Tracing is not enabled") + if err := tracing.Configure(cfg, logger); err != nil { + return err } var ( diff --git a/ocs/pkg/tracing/tracing.go b/ocs/pkg/tracing/tracing.go new file mode 100644 index 00000000000..b79bb7e61c0 --- /dev/null +++ b/ocs/pkg/tracing/tracing.go @@ -0,0 +1,90 @@ +package tracing + +import ( + "time" + + "contrib.go.opencensus.io/exporter/jaeger" + "contrib.go.opencensus.io/exporter/ocagent" + "contrib.go.opencensus.io/exporter/zipkin" + openzipkin "github.com/openzipkin/zipkin-go" + zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" + "github.com/owncloud/ocis/ocis-pkg/log" + "github.com/owncloud/ocis/ocs/pkg/config" + "go.opencensus.io/stats/view" + "go.opencensus.io/trace" +) + +func Configure(cfg *config.Config, logger log.Logger) error { + if cfg.Tracing.Enabled { + switch t := cfg.Tracing.Type; t { + case "agent": + exporter, err := ocagent.NewExporter( + ocagent.WithReconnectionPeriod(5*time.Second), + ocagent.WithAddress(cfg.Tracing.Endpoint), + ocagent.WithServiceName(cfg.Tracing.Service), + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create agent tracing") + return err + } + trace.RegisterExporter(exporter) + view.RegisterExporter(exporter) + case "jaeger": + exporter, err := jaeger.NewExporter( + jaeger.Options{ + AgentEndpoint: cfg.Tracing.Endpoint, + CollectorEndpoint: cfg.Tracing.Collector, + Process: jaeger.Process{ + ServiceName: cfg.Tracing.Service, + }, + }, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create jaeger tracing") + return err + } + trace.RegisterExporter(exporter) + case "zipkin": + endpoint, err := openzipkin.NewEndpoint( + cfg.Tracing.Service, + cfg.Tracing.Endpoint, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create zipkin tracing") + return err + } + exporter := zipkin.NewExporter( + zipkinhttp.NewReporter( + cfg.Tracing.Collector, + ), + endpoint, + ) + trace.RegisterExporter(exporter) + default: + logger.Warn(). + Str("type", t). + Msg("Unknown tracing backend") + } + trace.ApplyConfig( + trace.Config{ + DefaultSampler: trace.AlwaysSample(), + }, + ) + } else { + logger.Debug(). + Msg("Tracing is not enabled") + } + return nil +} From 192e3fbd009093d5c72b50e88df526f5a8728b9c Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 12:24:07 +0100 Subject: [PATCH 18/24] refactor onlyoffice tracing config --- onlyoffice/pkg/command/server.go | 94 ++----------------------------- onlyoffice/pkg/tracing/tracing.go | 90 +++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 90 deletions(-) create mode 100644 onlyoffice/pkg/tracing/tracing.go diff --git a/onlyoffice/pkg/command/server.go b/onlyoffice/pkg/command/server.go index 27290d36ae9..1558d61dc13 100644 --- a/onlyoffice/pkg/command/server.go +++ b/onlyoffice/pkg/command/server.go @@ -3,24 +3,18 @@ package command import ( "context" "strings" - "time" + + "github.com/owncloud/ocis/onlyoffice/pkg/tracing" "github.com/owncloud/ocis/ocis-pkg/sync" - "contrib.go.opencensus.io/exporter/jaeger" - "contrib.go.opencensus.io/exporter/ocagent" - "contrib.go.opencensus.io/exporter/zipkin" "github.com/micro/cli/v2" "github.com/oklog/run" - openzipkin "github.com/openzipkin/zipkin-go" - zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" "github.com/owncloud/ocis/onlyoffice/pkg/config" "github.com/owncloud/ocis/onlyoffice/pkg/flagset" "github.com/owncloud/ocis/onlyoffice/pkg/metrics" "github.com/owncloud/ocis/onlyoffice/pkg/server/debug" "github.com/owncloud/ocis/onlyoffice/pkg/server/http" - "go.opencensus.io/stats/view" - "go.opencensus.io/trace" ) // Server is the entrypoint for the server command. @@ -44,88 +38,8 @@ func Server(cfg *config.Config) *cli.Command { Action: func(c *cli.Context) error { logger := NewLogger(cfg) - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - exporter, err := ocagent.NewExporter( - ocagent.WithReconnectionPeriod(5*time.Second), - ocagent.WithAddress(cfg.Tracing.Endpoint), - ocagent.WithServiceName(cfg.Tracing.Service), - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create agent tracing") - - return err - } - - trace.RegisterExporter(exporter) - view.RegisterExporter(exporter) - - case "jaeger": - exporter, err := jaeger.NewExporter( - jaeger.Options{ - AgentEndpoint: cfg.Tracing.Endpoint, - CollectorEndpoint: cfg.Tracing.Collector, - ServiceName: cfg.Tracing.Service, - }, - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create jaeger tracing") - - return err - } - - trace.RegisterExporter(exporter) - - case "zipkin": - endpoint, err := openzipkin.NewEndpoint( - cfg.Tracing.Service, - cfg.Tracing.Endpoint, - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create zipkin tracing") - - return err - } - - exporter := zipkin.NewExporter( - zipkinhttp.NewReporter( - cfg.Tracing.Collector, - ), - endpoint, - ) - - trace.RegisterExporter(exporter) - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - trace.ApplyConfig( - trace.Config{ - DefaultSampler: trace.AlwaysSample(), - }, - ) - } else { - logger.Debug(). - Msg("Tracing is not enabled") + if err := tracing.Configure(cfg, logger); err != nil { + return err } var ( diff --git a/onlyoffice/pkg/tracing/tracing.go b/onlyoffice/pkg/tracing/tracing.go new file mode 100644 index 00000000000..5310e395133 --- /dev/null +++ b/onlyoffice/pkg/tracing/tracing.go @@ -0,0 +1,90 @@ +package tracing + +import ( + "time" + + "contrib.go.opencensus.io/exporter/jaeger" + "contrib.go.opencensus.io/exporter/ocagent" + "contrib.go.opencensus.io/exporter/zipkin" + openzipkin "github.com/openzipkin/zipkin-go" + zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" + "github.com/owncloud/ocis/ocis-pkg/log" + "github.com/owncloud/ocis/onlyoffice/pkg/config" + "go.opencensus.io/stats/view" + "go.opencensus.io/trace" +) + +func Configure(cfg *config.Config, logger log.Logger) error { + if cfg.Tracing.Enabled { + switch t := cfg.Tracing.Type; t { + case "agent": + exporter, err := ocagent.NewExporter( + ocagent.WithReconnectionPeriod(5*time.Second), + ocagent.WithAddress(cfg.Tracing.Endpoint), + ocagent.WithServiceName(cfg.Tracing.Service), + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create agent tracing") + return err + } + trace.RegisterExporter(exporter) + view.RegisterExporter(exporter) + case "jaeger": + exporter, err := jaeger.NewExporter( + jaeger.Options{ + AgentEndpoint: cfg.Tracing.Endpoint, + CollectorEndpoint: cfg.Tracing.Collector, + Process: jaeger.Process{ + ServiceName: cfg.Tracing.Service, + }, + }, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create jaeger tracing") + return err + } + trace.RegisterExporter(exporter) + case "zipkin": + endpoint, err := openzipkin.NewEndpoint( + cfg.Tracing.Service, + cfg.Tracing.Endpoint, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create zipkin tracing") + return err + } + exporter := zipkin.NewExporter( + zipkinhttp.NewReporter( + cfg.Tracing.Collector, + ), + endpoint, + ) + trace.RegisterExporter(exporter) + default: + logger.Warn(). + Str("type", t). + Msg("Unknown tracing backend") + } + trace.ApplyConfig( + trace.Config{ + DefaultSampler: trace.AlwaysSample(), + }, + ) + } else { + logger.Debug(). + Msg("Tracing is not enabled") + } + return nil +} From 02bfa9509bb3c008f4936ea5f107ec5336654043 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 12:25:23 +0100 Subject: [PATCH 19/24] refactor proxy tracing config --- proxy/pkg/command/server.go | 100 ++--------------------------------- proxy/pkg/tracing/tracing.go | 90 +++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 95 deletions(-) create mode 100644 proxy/pkg/tracing/tracing.go diff --git a/proxy/pkg/command/server.go b/proxy/pkg/command/server.go index fd20784736c..1b9b2319576 100644 --- a/proxy/pkg/command/server.go +++ b/proxy/pkg/command/server.go @@ -8,23 +8,15 @@ import ( "strings" "time" - "github.com/owncloud/ocis/ocis-pkg/sync" - - "github.com/owncloud/ocis/proxy/pkg/user/backend" - - "contrib.go.opencensus.io/exporter/jaeger" - "contrib.go.opencensus.io/exporter/ocagent" - "contrib.go.opencensus.io/exporter/zipkin" "github.com/coreos/go-oidc" "github.com/justinas/alice" "github.com/micro/cli/v2" "github.com/oklog/run" - openzipkin "github.com/openzipkin/zipkin-go" - zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" acc "github.com/owncloud/ocis/accounts/pkg/proto/v0" "github.com/owncloud/ocis/ocis-pkg/conversions" "github.com/owncloud/ocis/ocis-pkg/log" "github.com/owncloud/ocis/ocis-pkg/service/grpc" + "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/proxy/pkg/config" "github.com/owncloud/ocis/proxy/pkg/cs3" "github.com/owncloud/ocis/proxy/pkg/flagset" @@ -33,10 +25,10 @@ import ( "github.com/owncloud/ocis/proxy/pkg/proxy" "github.com/owncloud/ocis/proxy/pkg/server/debug" proxyHTTP "github.com/owncloud/ocis/proxy/pkg/server/http" + "github.com/owncloud/ocis/proxy/pkg/tracing" + "github.com/owncloud/ocis/proxy/pkg/user/backend" settings "github.com/owncloud/ocis/settings/pkg/proto/v0" storepb "github.com/owncloud/ocis/store/pkg/proto/v0" - "go.opencensus.io/stats/view" - "go.opencensus.io/trace" "golang.org/x/oauth2" ) @@ -66,90 +58,8 @@ func Server(cfg *config.Config) *cli.Command { Action: func(c *cli.Context) error { logger := NewLogger(cfg) - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - exporter, err := ocagent.NewExporter( - ocagent.WithReconnectionPeriod(5*time.Second), - ocagent.WithAddress(cfg.Tracing.Endpoint), - ocagent.WithServiceName(cfg.Tracing.Service), - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create agent tracing") - - return err - } - - trace.RegisterExporter(exporter) - view.RegisterExporter(exporter) - - case "jaeger": - exporter, err := jaeger.NewExporter( - jaeger.Options{ - AgentEndpoint: cfg.Tracing.Endpoint, - CollectorEndpoint: cfg.Tracing.Collector, - Process: jaeger.Process{ - ServiceName: cfg.Tracing.Service, - }, - }, - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create jaeger tracing") - - return err - } - - trace.RegisterExporter(exporter) - - case "zipkin": - endpoint, err := openzipkin.NewEndpoint( - cfg.Tracing.Service, - cfg.Tracing.Endpoint, - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create zipkin tracing") - - return err - } - - exporter := zipkin.NewExporter( - zipkinhttp.NewReporter( - cfg.Tracing.Collector, - ), - endpoint, - ) - - trace.RegisterExporter(exporter) - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - trace.ApplyConfig( - trace.Config{ - DefaultSampler: trace.AlwaysSample(), - }, - ) - } else { - logger.Debug(). - Msg("Tracing is not enabled") + if err := tracing.Configure(cfg, logger); err != nil { + return err } var ( diff --git a/proxy/pkg/tracing/tracing.go b/proxy/pkg/tracing/tracing.go new file mode 100644 index 00000000000..c39ce48e10f --- /dev/null +++ b/proxy/pkg/tracing/tracing.go @@ -0,0 +1,90 @@ +package tracing + +import ( + "time" + + "contrib.go.opencensus.io/exporter/jaeger" + "contrib.go.opencensus.io/exporter/ocagent" + "contrib.go.opencensus.io/exporter/zipkin" + openzipkin "github.com/openzipkin/zipkin-go" + zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" + "github.com/owncloud/ocis/ocis-pkg/log" + "github.com/owncloud/ocis/proxy/pkg/config" + "go.opencensus.io/stats/view" + "go.opencensus.io/trace" +) + +func Configure(cfg *config.Config, logger log.Logger) error { + if cfg.Tracing.Enabled { + switch t := cfg.Tracing.Type; t { + case "agent": + exporter, err := ocagent.NewExporter( + ocagent.WithReconnectionPeriod(5*time.Second), + ocagent.WithAddress(cfg.Tracing.Endpoint), + ocagent.WithServiceName(cfg.Tracing.Service), + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create agent tracing") + return err + } + trace.RegisterExporter(exporter) + view.RegisterExporter(exporter) + case "jaeger": + exporter, err := jaeger.NewExporter( + jaeger.Options{ + AgentEndpoint: cfg.Tracing.Endpoint, + CollectorEndpoint: cfg.Tracing.Collector, + Process: jaeger.Process{ + ServiceName: cfg.Tracing.Service, + }, + }, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create jaeger tracing") + return err + } + trace.RegisterExporter(exporter) + case "zipkin": + endpoint, err := openzipkin.NewEndpoint( + cfg.Tracing.Service, + cfg.Tracing.Endpoint, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create zipkin tracing") + return err + } + exporter := zipkin.NewExporter( + zipkinhttp.NewReporter( + cfg.Tracing.Collector, + ), + endpoint, + ) + trace.RegisterExporter(exporter) + default: + logger.Warn(). + Str("type", t). + Msg("Unknown tracing backend") + } + trace.ApplyConfig( + trace.Config{ + DefaultSampler: trace.AlwaysSample(), + }, + ) + } else { + logger.Debug(). + Msg("Tracing is not enabled") + } + return nil +} From 338c8c6942efbbcc15567c0fef49323cb5f64142 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 12:26:49 +0100 Subject: [PATCH 20/24] refactor store tracing config --- store/pkg/command/server.go | 97 ++---------------------------------- store/pkg/tracing/tracing.go | 90 +++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 93 deletions(-) create mode 100644 store/pkg/tracing/tracing.go diff --git a/store/pkg/command/server.go b/store/pkg/command/server.go index 1ce36160524..68c1e749f5a 100644 --- a/store/pkg/command/server.go +++ b/store/pkg/command/server.go @@ -2,25 +2,18 @@ package command import ( "context" - "time" + + "github.com/owncloud/ocis/store/pkg/tracing" "github.com/owncloud/ocis/ocis-pkg/sync" - "contrib.go.opencensus.io/exporter/jaeger" - "contrib.go.opencensus.io/exporter/ocagent" - "contrib.go.opencensus.io/exporter/zipkin" "github.com/micro/cli/v2" "github.com/oklog/run" - openzipkin "github.com/openzipkin/zipkin-go" - zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" "github.com/owncloud/ocis/store/pkg/config" "github.com/owncloud/ocis/store/pkg/flagset" "github.com/owncloud/ocis/store/pkg/metrics" "github.com/owncloud/ocis/store/pkg/server/debug" "github.com/owncloud/ocis/store/pkg/server/grpc" - - "go.opencensus.io/stats/view" - "go.opencensus.io/trace" ) // Server is the entrypoint for the server command. @@ -42,90 +35,8 @@ func Server(cfg *config.Config) *cli.Command { Action: func(c *cli.Context) error { logger := NewLogger(cfg) - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - exporter, err := ocagent.NewExporter( - ocagent.WithReconnectionPeriod(5*time.Second), - ocagent.WithAddress(cfg.Tracing.Endpoint), - ocagent.WithServiceName(cfg.Tracing.Service), - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create agent tracing") - - return err - } - - trace.RegisterExporter(exporter) - view.RegisterExporter(exporter) - - case "jaeger": - exporter, err := jaeger.NewExporter( - jaeger.Options{ - AgentEndpoint: cfg.Tracing.Endpoint, - CollectorEndpoint: cfg.Tracing.Collector, - Process: jaeger.Process{ - ServiceName: cfg.Tracing.Service, - }, - }, - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create jaeger tracing") - - return err - } - - trace.RegisterExporter(exporter) - - case "zipkin": - endpoint, err := openzipkin.NewEndpoint( - cfg.Tracing.Service, - cfg.Tracing.Endpoint, - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create zipkin tracing") - - return err - } - - exporter := zipkin.NewExporter( - zipkinhttp.NewReporter( - cfg.Tracing.Collector, - ), - endpoint, - ) - - trace.RegisterExporter(exporter) - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - trace.ApplyConfig( - trace.Config{ - DefaultSampler: trace.AlwaysSample(), - }, - ) - } else { - logger.Debug(). - Msg("Tracing is not enabled") + if err := tracing.Configure(cfg, logger); err != nil { + return err } var ( diff --git a/store/pkg/tracing/tracing.go b/store/pkg/tracing/tracing.go new file mode 100644 index 00000000000..e9b045687e3 --- /dev/null +++ b/store/pkg/tracing/tracing.go @@ -0,0 +1,90 @@ +package tracing + +import ( + "time" + + "contrib.go.opencensus.io/exporter/jaeger" + "contrib.go.opencensus.io/exporter/ocagent" + "contrib.go.opencensus.io/exporter/zipkin" + openzipkin "github.com/openzipkin/zipkin-go" + zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" + "github.com/owncloud/ocis/ocis-pkg/log" + "github.com/owncloud/ocis/store/pkg/config" + "go.opencensus.io/stats/view" + "go.opencensus.io/trace" +) + +func Configure(cfg *config.Config, logger log.Logger) error { + if cfg.Tracing.Enabled { + switch t := cfg.Tracing.Type; t { + case "agent": + exporter, err := ocagent.NewExporter( + ocagent.WithReconnectionPeriod(5*time.Second), + ocagent.WithAddress(cfg.Tracing.Endpoint), + ocagent.WithServiceName(cfg.Tracing.Service), + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create agent tracing") + return err + } + trace.RegisterExporter(exporter) + view.RegisterExporter(exporter) + case "jaeger": + exporter, err := jaeger.NewExporter( + jaeger.Options{ + AgentEndpoint: cfg.Tracing.Endpoint, + CollectorEndpoint: cfg.Tracing.Collector, + Process: jaeger.Process{ + ServiceName: cfg.Tracing.Service, + }, + }, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create jaeger tracing") + return err + } + trace.RegisterExporter(exporter) + case "zipkin": + endpoint, err := openzipkin.NewEndpoint( + cfg.Tracing.Service, + cfg.Tracing.Endpoint, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create zipkin tracing") + return err + } + exporter := zipkin.NewExporter( + zipkinhttp.NewReporter( + cfg.Tracing.Collector, + ), + endpoint, + ) + trace.RegisterExporter(exporter) + default: + logger.Warn(). + Str("type", t). + Msg("Unknown tracing backend") + } + trace.ApplyConfig( + trace.Config{ + DefaultSampler: trace.AlwaysSample(), + }, + ) + } else { + logger.Debug(). + Msg("Tracing is not enabled") + } + return nil +} From 6af43cc150ea42d4b00fc20df9a5a0888a9105e1 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 12:28:01 +0100 Subject: [PATCH 21/24] refactor thumbnails tracing config --- thumbnails/pkg/command/server.go | 98 ++----------------------------- thumbnails/pkg/tracing/tracing.go | 90 ++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 94 deletions(-) create mode 100644 thumbnails/pkg/tracing/tracing.go diff --git a/thumbnails/pkg/command/server.go b/thumbnails/pkg/command/server.go index 3818c9ab435..9825b229ba3 100644 --- a/thumbnails/pkg/command/server.go +++ b/thumbnails/pkg/command/server.go @@ -3,24 +3,16 @@ package command import ( "context" "fmt" - "time" - "github.com/owncloud/ocis/ocis-pkg/sync" - - "contrib.go.opencensus.io/exporter/jaeger" - "contrib.go.opencensus.io/exporter/ocagent" - "contrib.go.opencensus.io/exporter/zipkin" "github.com/micro/cli/v2" "github.com/oklog/run" - openzipkin "github.com/openzipkin/zipkin-go" - zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" + "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/thumbnails/pkg/config" "github.com/owncloud/ocis/thumbnails/pkg/flagset" "github.com/owncloud/ocis/thumbnails/pkg/metrics" "github.com/owncloud/ocis/thumbnails/pkg/server/debug" "github.com/owncloud/ocis/thumbnails/pkg/server/grpc" - "go.opencensus.io/stats/view" - "go.opencensus.io/trace" + "github.com/owncloud/ocis/thumbnails/pkg/tracing" ) // Server is the entrypoint for the server command. @@ -41,90 +33,8 @@ func Server(cfg *config.Config) *cli.Command { }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - exporter, err := ocagent.NewExporter( - ocagent.WithReconnectionPeriod(5*time.Second), - ocagent.WithAddress(cfg.Tracing.Endpoint), - ocagent.WithServiceName(cfg.Tracing.Service), - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create agent tracing") - - return err - } - - trace.RegisterExporter(exporter) - view.RegisterExporter(exporter) - - case "jaeger": - exporter, err := jaeger.NewExporter( - jaeger.Options{ - AgentEndpoint: cfg.Tracing.Endpoint, - CollectorEndpoint: cfg.Tracing.Collector, - Process: jaeger.Process{ - ServiceName: cfg.Tracing.Service, - }, - }, - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create jaeger tracing") - - return err - } - - trace.RegisterExporter(exporter) - - case "zipkin": - endpoint, err := openzipkin.NewEndpoint( - cfg.Tracing.Service, - cfg.Tracing.Endpoint, - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create zipkin tracing") - - return err - } - - exporter := zipkin.NewExporter( - zipkinhttp.NewReporter( - cfg.Tracing.Collector, - ), - endpoint, - ) - - trace.RegisterExporter(exporter) - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - trace.ApplyConfig( - trace.Config{ - DefaultSampler: trace.AlwaysSample(), - }, - ) - } else { - logger.Debug(). - Msg("Tracing is not enabled") + if err := tracing.Configure(cfg, logger); err != nil { + return err } var ( diff --git a/thumbnails/pkg/tracing/tracing.go b/thumbnails/pkg/tracing/tracing.go new file mode 100644 index 00000000000..ca225606666 --- /dev/null +++ b/thumbnails/pkg/tracing/tracing.go @@ -0,0 +1,90 @@ +package tracing + +import ( + "time" + + "contrib.go.opencensus.io/exporter/jaeger" + "contrib.go.opencensus.io/exporter/ocagent" + "contrib.go.opencensus.io/exporter/zipkin" + openzipkin "github.com/openzipkin/zipkin-go" + zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" + "github.com/owncloud/ocis/ocis-pkg/log" + "github.com/owncloud/ocis/thumbnails/pkg/config" + "go.opencensus.io/stats/view" + "go.opencensus.io/trace" +) + +func Configure(cfg *config.Config, logger log.Logger) error { + if cfg.Tracing.Enabled { + switch t := cfg.Tracing.Type; t { + case "agent": + exporter, err := ocagent.NewExporter( + ocagent.WithReconnectionPeriod(5*time.Second), + ocagent.WithAddress(cfg.Tracing.Endpoint), + ocagent.WithServiceName(cfg.Tracing.Service), + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create agent tracing") + return err + } + trace.RegisterExporter(exporter) + view.RegisterExporter(exporter) + case "jaeger": + exporter, err := jaeger.NewExporter( + jaeger.Options{ + AgentEndpoint: cfg.Tracing.Endpoint, + CollectorEndpoint: cfg.Tracing.Collector, + Process: jaeger.Process{ + ServiceName: cfg.Tracing.Service, + }, + }, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create jaeger tracing") + return err + } + trace.RegisterExporter(exporter) + case "zipkin": + endpoint, err := openzipkin.NewEndpoint( + cfg.Tracing.Service, + cfg.Tracing.Endpoint, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create zipkin tracing") + return err + } + exporter := zipkin.NewExporter( + zipkinhttp.NewReporter( + cfg.Tracing.Collector, + ), + endpoint, + ) + trace.RegisterExporter(exporter) + default: + logger.Warn(). + Str("type", t). + Msg("Unknown tracing backend") + } + trace.ApplyConfig( + trace.Config{ + DefaultSampler: trace.AlwaysSample(), + }, + ) + } else { + logger.Debug(). + Msg("Tracing is not enabled") + } + return nil +} From 3ec71d0da28a8360205080115202a0a17a375222 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 12:29:06 +0100 Subject: [PATCH 22/24] refactor web tracing config --- web/pkg/command/server.go | 98 ++------------------------------------ web/pkg/tracing/tracing.go | 90 ++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 94 deletions(-) create mode 100644 web/pkg/tracing/tracing.go diff --git a/web/pkg/command/server.go b/web/pkg/command/server.go index 794056eaa5f..2d518000bd6 100644 --- a/web/pkg/command/server.go +++ b/web/pkg/command/server.go @@ -5,24 +5,16 @@ import ( "encoding/json" "io/ioutil" "strings" - "time" - "github.com/owncloud/ocis/ocis-pkg/sync" - - "contrib.go.opencensus.io/exporter/jaeger" - "contrib.go.opencensus.io/exporter/ocagent" - "contrib.go.opencensus.io/exporter/zipkin" "github.com/micro/cli/v2" "github.com/oklog/run" - openzipkin "github.com/openzipkin/zipkin-go" - zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" + "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/web/pkg/config" "github.com/owncloud/ocis/web/pkg/flagset" "github.com/owncloud/ocis/web/pkg/metrics" "github.com/owncloud/ocis/web/pkg/server/debug" "github.com/owncloud/ocis/web/pkg/server/http" - "go.opencensus.io/stats/view" - "go.opencensus.io/trace" + "github.com/owncloud/ocis/web/pkg/tracing" ) // Server is the entrypoint for the server command. @@ -55,90 +47,8 @@ func Server(cfg *config.Config) *cli.Command { Action: func(c *cli.Context) error { logger := NewLogger(cfg) - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - exporter, err := ocagent.NewExporter( - ocagent.WithReconnectionPeriod(5*time.Second), - ocagent.WithAddress(cfg.Tracing.Endpoint), - ocagent.WithServiceName(cfg.Tracing.Service), - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create agent tracing") - - return err - } - - trace.RegisterExporter(exporter) - view.RegisterExporter(exporter) - - case "jaeger": - exporter, err := jaeger.NewExporter( - jaeger.Options{ - AgentEndpoint: cfg.Tracing.Endpoint, - CollectorEndpoint: cfg.Tracing.Collector, - Process: jaeger.Process{ - ServiceName: cfg.Tracing.Service, - }, - }, - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create jaeger tracing") - - return err - } - - trace.RegisterExporter(exporter) - - case "zipkin": - endpoint, err := openzipkin.NewEndpoint( - cfg.Tracing.Service, - cfg.Tracing.Endpoint, - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create zipkin tracing") - - return err - } - - exporter := zipkin.NewExporter( - zipkinhttp.NewReporter( - cfg.Tracing.Collector, - ), - endpoint, - ) - - trace.RegisterExporter(exporter) - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - trace.ApplyConfig( - trace.Config{ - DefaultSampler: trace.AlwaysSample(), - }, - ) - } else { - logger.Debug(). - Msg("Tracing is not enabled") + if err := tracing.Configure(cfg, logger); err != nil { + return err } // actually read the contents of the config file and override defaults diff --git a/web/pkg/tracing/tracing.go b/web/pkg/tracing/tracing.go new file mode 100644 index 00000000000..3a8f64d0473 --- /dev/null +++ b/web/pkg/tracing/tracing.go @@ -0,0 +1,90 @@ +package tracing + +import ( + "time" + + "contrib.go.opencensus.io/exporter/jaeger" + "contrib.go.opencensus.io/exporter/ocagent" + "contrib.go.opencensus.io/exporter/zipkin" + openzipkin "github.com/openzipkin/zipkin-go" + zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" + "github.com/owncloud/ocis/ocis-pkg/log" + "github.com/owncloud/ocis/web/pkg/config" + "go.opencensus.io/stats/view" + "go.opencensus.io/trace" +) + +func Configure(cfg *config.Config, logger log.Logger) error { + if cfg.Tracing.Enabled { + switch t := cfg.Tracing.Type; t { + case "agent": + exporter, err := ocagent.NewExporter( + ocagent.WithReconnectionPeriod(5*time.Second), + ocagent.WithAddress(cfg.Tracing.Endpoint), + ocagent.WithServiceName(cfg.Tracing.Service), + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create agent tracing") + return err + } + trace.RegisterExporter(exporter) + view.RegisterExporter(exporter) + case "jaeger": + exporter, err := jaeger.NewExporter( + jaeger.Options{ + AgentEndpoint: cfg.Tracing.Endpoint, + CollectorEndpoint: cfg.Tracing.Collector, + Process: jaeger.Process{ + ServiceName: cfg.Tracing.Service, + }, + }, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create jaeger tracing") + return err + } + trace.RegisterExporter(exporter) + case "zipkin": + endpoint, err := openzipkin.NewEndpoint( + cfg.Tracing.Service, + cfg.Tracing.Endpoint, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create zipkin tracing") + return err + } + exporter := zipkin.NewExporter( + zipkinhttp.NewReporter( + cfg.Tracing.Collector, + ), + endpoint, + ) + trace.RegisterExporter(exporter) + default: + logger.Warn(). + Str("type", t). + Msg("Unknown tracing backend") + } + trace.ApplyConfig( + trace.Config{ + DefaultSampler: trace.AlwaysSample(), + }, + ) + } else { + logger.Debug(). + Msg("Tracing is not enabled") + } + return nil +} From 61bd6be0ad045cedd5489cebb708e59786b77ffb Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 18 Mar 2021 12:30:02 +0100 Subject: [PATCH 23/24] refactor webdav tracing config --- webdav/pkg/command/server.go | 98 ++--------------------------------- webdav/pkg/tracing/tracing.go | 90 ++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 94 deletions(-) create mode 100644 webdav/pkg/tracing/tracing.go diff --git a/webdav/pkg/command/server.go b/webdav/pkg/command/server.go index 75a43f57006..dbe411e0207 100644 --- a/webdav/pkg/command/server.go +++ b/webdav/pkg/command/server.go @@ -3,24 +3,16 @@ package command import ( "context" "strings" - "time" - "github.com/owncloud/ocis/ocis-pkg/sync" - - "contrib.go.opencensus.io/exporter/jaeger" - "contrib.go.opencensus.io/exporter/ocagent" - "contrib.go.opencensus.io/exporter/zipkin" "github.com/micro/cli/v2" "github.com/oklog/run" - openzipkin "github.com/openzipkin/zipkin-go" - zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" + "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/webdav/pkg/config" "github.com/owncloud/ocis/webdav/pkg/flagset" "github.com/owncloud/ocis/webdav/pkg/metrics" "github.com/owncloud/ocis/webdav/pkg/server/debug" "github.com/owncloud/ocis/webdav/pkg/server/http" - "go.opencensus.io/stats/view" - "go.opencensus.io/trace" + "github.com/owncloud/ocis/webdav/pkg/tracing" ) // Server is the entrypoint for the server command. @@ -44,90 +36,8 @@ func Server(cfg *config.Config) *cli.Command { Action: func(c *cli.Context) error { logger := NewLogger(cfg) - if cfg.Tracing.Enabled { - switch t := cfg.Tracing.Type; t { - case "agent": - exporter, err := ocagent.NewExporter( - ocagent.WithReconnectionPeriod(5*time.Second), - ocagent.WithAddress(cfg.Tracing.Endpoint), - ocagent.WithServiceName(cfg.Tracing.Service), - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create agent tracing") - - return err - } - - trace.RegisterExporter(exporter) - view.RegisterExporter(exporter) - - case "jaeger": - exporter, err := jaeger.NewExporter( - jaeger.Options{ - AgentEndpoint: cfg.Tracing.Endpoint, - CollectorEndpoint: cfg.Tracing.Collector, - Process: jaeger.Process{ - ServiceName: cfg.Tracing.Service, - }, - }, - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create jaeger tracing") - - return err - } - - trace.RegisterExporter(exporter) - - case "zipkin": - endpoint, err := openzipkin.NewEndpoint( - cfg.Tracing.Service, - cfg.Tracing.Endpoint, - ) - - if err != nil { - logger.Error(). - Err(err). - Str("endpoint", cfg.Tracing.Endpoint). - Str("collector", cfg.Tracing.Collector). - Msg("Failed to create zipkin tracing") - - return err - } - - exporter := zipkin.NewExporter( - zipkinhttp.NewReporter( - cfg.Tracing.Collector, - ), - endpoint, - ) - - trace.RegisterExporter(exporter) - - default: - logger.Warn(). - Str("type", t). - Msg("Unknown tracing backend") - } - - trace.ApplyConfig( - trace.Config{ - DefaultSampler: trace.AlwaysSample(), - }, - ) - } else { - logger.Debug(). - Msg("Tracing is not enabled") + if err := tracing.Configure(cfg, logger); err != nil { + return err } var ( diff --git a/webdav/pkg/tracing/tracing.go b/webdav/pkg/tracing/tracing.go new file mode 100644 index 00000000000..ab66129f6b1 --- /dev/null +++ b/webdav/pkg/tracing/tracing.go @@ -0,0 +1,90 @@ +package tracing + +import ( + "time" + + "contrib.go.opencensus.io/exporter/jaeger" + "contrib.go.opencensus.io/exporter/ocagent" + "contrib.go.opencensus.io/exporter/zipkin" + openzipkin "github.com/openzipkin/zipkin-go" + zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" + "github.com/owncloud/ocis/ocis-pkg/log" + "github.com/owncloud/ocis/webdav/pkg/config" + "go.opencensus.io/stats/view" + "go.opencensus.io/trace" +) + +func Configure(cfg *config.Config, logger log.Logger) error { + if cfg.Tracing.Enabled { + switch t := cfg.Tracing.Type; t { + case "agent": + exporter, err := ocagent.NewExporter( + ocagent.WithReconnectionPeriod(5*time.Second), + ocagent.WithAddress(cfg.Tracing.Endpoint), + ocagent.WithServiceName(cfg.Tracing.Service), + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create agent tracing") + return err + } + trace.RegisterExporter(exporter) + view.RegisterExporter(exporter) + case "jaeger": + exporter, err := jaeger.NewExporter( + jaeger.Options{ + AgentEndpoint: cfg.Tracing.Endpoint, + CollectorEndpoint: cfg.Tracing.Collector, + Process: jaeger.Process{ + ServiceName: cfg.Tracing.Service, + }, + }, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create jaeger tracing") + return err + } + trace.RegisterExporter(exporter) + case "zipkin": + endpoint, err := openzipkin.NewEndpoint( + cfg.Tracing.Service, + cfg.Tracing.Endpoint, + ) + if err != nil { + logger.Error(). + Err(err). + Str("endpoint", cfg.Tracing.Endpoint). + Str("collector", cfg.Tracing.Collector). + Msg("Failed to create zipkin tracing") + return err + } + exporter := zipkin.NewExporter( + zipkinhttp.NewReporter( + cfg.Tracing.Collector, + ), + endpoint, + ) + trace.RegisterExporter(exporter) + default: + logger.Warn(). + Str("type", t). + Msg("Unknown tracing backend") + } + trace.ApplyConfig( + trace.Config{ + DefaultSampler: trace.AlwaysSample(), + }, + ) + } else { + logger.Debug(). + Msg("Tracing is not enabled") + } + return nil +} From c5bef3609baf6bda5852d5f5df4c7786d75e65d2 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Fri, 26 Mar 2021 11:44:36 +0100 Subject: [PATCH 24/24] add changelog --- changelog/unreleased/tracing-refactor.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelog/unreleased/tracing-refactor.md diff --git a/changelog/unreleased/tracing-refactor.md b/changelog/unreleased/tracing-refactor.md new file mode 100644 index 00000000000..9a3fc9af135 --- /dev/null +++ b/changelog/unreleased/tracing-refactor.md @@ -0,0 +1,5 @@ +Enhancement: Tracing Refactor + +Centralize tracing handling per extension. + +https://github.com/owncloud/ocis/pull/1819