Merge pull request #6022 from kobergj/ConfigureGRPCInOCS

Fix Panic in OCS service
This commit is contained in:
kobergj
2023-04-06 12:05:46 +02:00
committed by GitHub
4 changed files with 18 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
Enhancement: Configure GRPC in ocs
Fixes a panic in ocs when running not in single binary
https://github.com/owncloud/ocis/pull/6022

View File

@@ -11,6 +11,7 @@ import (
"github.com/owncloud/ocis/v2/services/ocs/pkg/tracing"
"github.com/oklog/run"
ogrpc "github.com/owncloud/ocis/v2/ocis-pkg/service/grpc"
"github.com/owncloud/ocis/v2/services/ocs/pkg/config"
"github.com/owncloud/ocis/v2/services/ocs/pkg/metrics"
"github.com/owncloud/ocis/v2/services/ocs/pkg/server/debug"
@@ -34,6 +35,11 @@ func Server(cfg *config.Config) *cli.Command {
return err
}
err = ogrpc.Configure(ogrpc.GetClientOptions(cfg.GRPCClientTLS)...)
if err != nil {
return err
}
var (
gr = run.Group{}
ctx, cancel = func() (context.Context, context.CancelFunc) {

View File

@@ -19,6 +19,8 @@ type Config struct {
HTTP HTTP `yaml:"http"`
GRPCClientTLS *shared.GRPCClientTLS `yaml:"grpc_client_tls"`
TokenManager *TokenManager `yaml:"token_manager"`
Context context.Context `yaml:"-"`

View File

@@ -3,6 +3,7 @@ package defaults
import (
"strings"
"github.com/owncloud/ocis/v2/ocis-pkg/structs"
"github.com/owncloud/ocis/v2/services/ocs/pkg/config"
)
@@ -86,6 +87,10 @@ func EnsureDefaults(cfg *config.Config) {
if cfg.Commons != nil {
cfg.HTTP.TLS = cfg.Commons.HTTPServiceTLS
}
if cfg.GRPCClientTLS == nil && cfg.Commons != nil {
cfg.GRPCClientTLS = structs.CopyOrZeroValue(cfg.Commons.GRPCClientTLS)
}
}
// Sanitize sanitizes the configuration