mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-02-23 05:59:28 -06:00
Merge pull request #1819 from owncloud/refactor-extensions
This commit is contained in:
@@ -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)
|
||||
}()
|
||||
}
|
||||
|
||||
90
accounts/pkg/tracing/tracing.go
Normal file
90
accounts/pkg/tracing/tracing.go
Normal file
@@ -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
|
||||
}
|
||||
5
changelog/unreleased/tracing-refactor.md
Normal file
5
changelog/unreleased/tracing-refactor.md
Normal file
@@ -0,0 +1,5 @@
|
||||
Enhancement: Tracing Refactor
|
||||
|
||||
Centralize tracing handling per extension.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/1819
|
||||
@@ -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,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,
|
||||
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 (
|
||||
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()
|
||||
)
|
||||
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()
|
||||
|
||||
defer cancel()
|
||||
|
||||
|
||||
90
glauth/pkg/tracing/tracing.go
Normal file
90
glauth/pkg/tracing/tracing.go
Normal file
@@ -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
|
||||
}
|
||||
@@ -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{}
|
||||
|
||||
90
graph-explorer/pkg/tracing/tracing.go
Normal file
90
graph-explorer/pkg/tracing/tracing.go
Normal file
@@ -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
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
|
||||
90
graph/pkg/tracing/tracing.go
Normal file
90
graph/pkg/tracing/tracing.go
Normal file
@@ -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
|
||||
}
|
||||
@@ -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{}
|
||||
|
||||
90
idp/pkg/tracing/tracing.go
Normal file
90
idp/pkg/tracing/tracing.go
Normal file
@@ -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
|
||||
}
|
||||
@@ -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 (
|
||||
|
||||
90
ocs/pkg/tracing/tracing.go
Normal file
90
ocs/pkg/tracing/tracing.go
Normal file
@@ -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
|
||||
}
|
||||
@@ -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 (
|
||||
|
||||
90
onlyoffice/pkg/tracing/tracing.go
Normal file
90
onlyoffice/pkg/tracing/tracing.go
Normal file
@@ -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
|
||||
}
|
||||
@@ -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 (
|
||||
|
||||
90
proxy/pkg/tracing/tracing.go
Normal file
90
proxy/pkg/tracing/tracing.go
Normal file
@@ -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
|
||||
}
|
||||
@@ -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,134 +33,50 @@ 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()
|
||||
})
|
||||
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),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
logger.Info().Err(err).Str("server", "debug").Msg("Failed to initialize server")
|
||||
return err
|
||||
}
|
||||
|
||||
{
|
||||
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
|
||||
}
|
||||
|
||||
gr.Add(server.ListenAndServe, func(_ error) {
|
||||
cancel()
|
||||
})
|
||||
}
|
||||
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
|
||||
|
||||
@@ -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 := authBearerConfigFromStruct(c, cfg)
|
||||
|
||||
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()
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
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")
|
||||
|
||||
if err != nil {
|
||||
logger.Info().Err(err).Str("server", "debug").Msg("Failed to initialize server")
|
||||
return err
|
||||
}
|
||||
cancel()
|
||||
})
|
||||
|
||||
gr.Add(server.ListenAndServe, func(_ error) {
|
||||
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(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
|
||||
|
||||
@@ -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,216 +36,52 @@ 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")
|
||||
tracing.Configure(cfg, logger)
|
||||
|
||||
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()
|
||||
)
|
||||
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")
|
||||
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))
|
||||
}
|
||||
|
||||
filesCfg := map[string]interface{}{
|
||||
"private_links": false,
|
||||
"bigfilechunking": false,
|
||||
"blacklisted_files": []string{},
|
||||
"undelete": true,
|
||||
"versioning": true,
|
||||
}
|
||||
|
||||
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),
|
||||
}
|
||||
}
|
||||
|
||||
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",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
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()
|
||||
})
|
||||
// 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))
|
||||
}
|
||||
|
||||
filesCfg := map[string]interface{}{
|
||||
"private_links": false,
|
||||
"bigfilechunking": false,
|
||||
"blacklisted_files": []string{},
|
||||
"undelete": true,
|
||||
"versioning": true,
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
revaCfg := frontendConfigFromStruct(c, cfg, filesCfg)
|
||||
|
||||
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(
|
||||
debug.Name(c.Command.Name+"-debug"),
|
||||
@@ -278,6 +114,138 @@ func Frontend(cfg *config.Config) *cli.Command {
|
||||
}
|
||||
}
|
||||
|
||||
// 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,
|
||||
"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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
uuid := uuid.Must(uuid.NewV4())
|
||||
pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid")
|
||||
defer cancel()
|
||||
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
rcfg := groupsConfigFromStruct(c, 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()
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
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")
|
||||
|
||||
if err != nil {
|
||||
logger.Info().Err(err).Str("server", c.Command.Name+"-debug").Msg("Failed to initialize server")
|
||||
return err
|
||||
}
|
||||
cancel()
|
||||
})
|
||||
|
||||
gr.Add(server.ListenAndServe, func(_ error) {
|
||||
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(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
|
||||
|
||||
@@ -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")
|
||||
tracing.Configure(cfg, logger)
|
||||
|
||||
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()
|
||||
)
|
||||
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")
|
||||
|
||||
if err != nil {
|
||||
logger.Info().
|
||||
Err(err).
|
||||
Str("server", c.Command.Name+"-debug").
|
||||
Msg("Failed to initialize server")
|
||||
cancel()
|
||||
})
|
||||
|
||||
return err
|
||||
}
|
||||
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),
|
||||
)
|
||||
|
||||
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
|
||||
|
||||
@@ -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")
|
||||
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()
|
||||
})
|
||||
// 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")
|
||||
|
||||
if err != nil {
|
||||
logger.Info().Err(err).Str("server", c.Command.Name+"-debug").Msg("Failed to initialize server")
|
||||
return err
|
||||
}
|
||||
cancel()
|
||||
})
|
||||
|
||||
gr.Add(server.ListenAndServe, func(_ error) {
|
||||
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(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
|
||||
|
||||
@@ -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")
|
||||
tracing.Configure(cfg, logger)
|
||||
|
||||
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")
|
||||
gr := run.Group{}
|
||||
ctx, cancel := func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Reva.StorageMetadata.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
|
||||
} else {
|
||||
logger.Debug().
|
||||
Msg("Tracing is not enabled")
|
||||
}
|
||||
|
||||
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)
|
||||
}()
|
||||
)
|
||||
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")
|
||||
pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.Must(uuid.NewV4()).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
|
||||
// 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,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
rcfg := storageMetadataFromStruct(c, 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()
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
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")
|
||||
|
||||
if err != nil {
|
||||
logger.Info().
|
||||
Err(err).
|
||||
Str("server", c.Command.Name+"-debug").
|
||||
Msg("Failed to initialize server")
|
||||
cancel()
|
||||
})
|
||||
|
||||
return err
|
||||
}
|
||||
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),
|
||||
)
|
||||
|
||||
gr.Add(func() error {
|
||||
return server.ListenAndServe()
|
||||
}, func(_ error) {
|
||||
_ = server.Shutdown(ctx)
|
||||
cancel()
|
||||
})
|
||||
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 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
|
||||
|
||||
@@ -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")
|
||||
pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid")
|
||||
rcfg := storagePublicLinkConfigFromStruct(c, cfg)
|
||||
|
||||
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()
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
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")
|
||||
|
||||
if err != nil {
|
||||
logger.Info().Err(err).Str("server", c.Command.Name+"-debug").Msg("Failed to initialize server")
|
||||
return err
|
||||
}
|
||||
cancel()
|
||||
})
|
||||
|
||||
gr.Add(server.ListenAndServe, func(_ error) {
|
||||
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(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
|
||||
|
||||
@@ -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")
|
||||
tracing.Configure(cfg, logger)
|
||||
|
||||
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()
|
||||
)
|
||||
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")
|
||||
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()
|
||||
})
|
||||
// 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")
|
||||
|
||||
if err != nil {
|
||||
logger.Info().Err(err).Str("server", c.Command.Name+"-debug").Msg("Failed to initialize server")
|
||||
return err
|
||||
}
|
||||
cancel()
|
||||
})
|
||||
|
||||
gr.Add(server.ListenAndServe, func(_ error) {
|
||||
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(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
|
||||
|
||||
@@ -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")
|
||||
tracing.Configure(cfg, logger)
|
||||
|
||||
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()
|
||||
)
|
||||
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")
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
rcfg := usersConfigFromStruct(c, 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()
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
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")
|
||||
|
||||
if err != nil {
|
||||
logger.Info().Err(err).Str("server", c.Command.Name+"-debug").Msg("Failed to initialize server")
|
||||
return err
|
||||
}
|
||||
cancel()
|
||||
})
|
||||
|
||||
gr.Add(server.ListenAndServe, func(_ error) {
|
||||
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(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
|
||||
|
||||
38
storage/pkg/tracing/tracing.go
Normal file
38
storage/pkg/tracing/tracing.go
Normal file
@@ -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")
|
||||
}
|
||||
}
|
||||
@@ -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 (
|
||||
|
||||
90
store/pkg/tracing/tracing.go
Normal file
90
store/pkg/tracing/tracing.go
Normal file
@@ -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
|
||||
}
|
||||
@@ -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 (
|
||||
|
||||
90
thumbnails/pkg/tracing/tracing.go
Normal file
90
thumbnails/pkg/tracing/tracing.go
Normal file
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
|
||||
90
web/pkg/tracing/tracing.go
Normal file
90
web/pkg/tracing/tracing.go
Normal file
@@ -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
|
||||
}
|
||||
@@ -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 (
|
||||
|
||||
90
webdav/pkg/tracing/tracing.go
Normal file
90
webdav/pkg/tracing/tracing.go
Normal file
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user