Use embeddable ocdav go micro service (#3397)
* allow proxy to route to micro service Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * use go micre ocdav service instead of reva frontend Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * add missing gateway default config Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * update reva branch for testing Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * add changelog Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * add missing comands Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * bump reva version Signed-off-by: jkoberg <jkoberg@owncloud.com> * tidy Signed-off-by: jkoberg <jkoberg@owncloud.com> * bump reva again Signed-off-by: jkoberg <jkoberg@owncloud.com> * a blind mans config change Signed-off-by: jkoberg <jkoberg@owncloud.com> * add ocdav to must start extensions Signed-off-by: jkoberg <jkoberg@owncloud.com> * fail when neither backend nor service is set Signed-off-by: jkoberg <jkoberg@owncloud.com> Co-authored-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
committed by
Christian Richter
co-authored by
jkoberg
parent
ae4c72d1c7
commit
40a4c5070a
@@ -186,14 +186,6 @@ func frontendConfigFromStruct(c *cli.Context, cfg *config.Config, filesCfg map[s
|
||||
"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": cfg.Reva.Frontend.OCDavInsecure,
|
||||
"public_url": cfg.Reva.Frontend.PublicURL,
|
||||
},
|
||||
"ocs": map[string]interface{}{
|
||||
"storage_registry_svc": cfg.Reva.Gateway.Endpoint,
|
||||
"share_prefix": cfg.Reva.Frontend.OCSSharePrefix,
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
|
||||
"github.com/cs3org/reva/v2/pkg/micro/ocdav"
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/config"
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/tracing"
|
||||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
"github.com/thejerf/suture/v4"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// OCDav is the entrypoint for the ocdav command.
|
||||
// TODO move ocdav cmd to a separate service
|
||||
func OCDav(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "ocdav",
|
||||
Usage: "start ocdav service",
|
||||
Before: func(c *cli.Context) error {
|
||||
if err := loadUserAgent(c, cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
return ParseConfig(c, cfg, "ocdav")
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
logger := NewLogger(cfg)
|
||||
|
||||
tracing.Configure(cfg, logger)
|
||||
|
||||
gr := run.Group{}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
//metrics = metrics.New()
|
||||
|
||||
defer cancel()
|
||||
|
||||
gr.Add(func() error {
|
||||
s, err := ocdav.Service(
|
||||
ocdav.Context(ctx),
|
||||
ocdav.Logger(logger.Logger),
|
||||
ocdav.Address(cfg.OCDav.Addr),
|
||||
ocdav.FilesNamespace(cfg.OCDav.FilesNamespace),
|
||||
ocdav.WebdavNamespace(cfg.OCDav.WebdavNamespace),
|
||||
ocdav.SharesNamespace(cfg.OCDav.SharesNamespace),
|
||||
ocdav.Timeout(cfg.OCDav.Timeout),
|
||||
ocdav.Insecure(cfg.OCDav.Insecure),
|
||||
ocdav.PublicURL(cfg.OCDav.PublicURL),
|
||||
ocdav.Prefix(cfg.OCDav.Prefix),
|
||||
ocdav.GatewaySvc(cfg.OCDav.GatewaySVC),
|
||||
ocdav.JWTSecret(cfg.OCDav.JWTSecret),
|
||||
// ocdav.FavoriteManager() // FIXME needs a proper persistence implementation
|
||||
// ocdav.LockSystem(), // will default to the CS3 lock system
|
||||
// ocdav.TLSConfig() // tls config for the http server
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.Run()
|
||||
}, func(err error) {
|
||||
logger.Info().Err(err).Str("server", c.Command.Name).Msg("Shutting down server")
|
||||
cancel()
|
||||
})
|
||||
|
||||
{
|
||||
server, err := debug.Server(
|
||||
debug.Name(c.Command.Name+"-debug"),
|
||||
debug.Addr(cfg.OCDav.DebugAddr),
|
||||
debug.Logger(logger),
|
||||
debug.Context(ctx),
|
||||
debug.Config(cfg),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
logger.Info().
|
||||
Err(err).
|
||||
Str("server", "debug").
|
||||
Msg("Failed to initialize server")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
gr.Add(server.ListenAndServe, func(_ error) {
|
||||
cancel()
|
||||
})
|
||||
}
|
||||
|
||||
if !cfg.Reva.Frontend.Supervised {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
return gr.Run()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// OCDavSutureService allows for the ocdav command to be embedded and supervised by a suture supervisor tree.
|
||||
type OCDavSutureService struct {
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
// NewOCDav creates a new ocdav.OCDavSutureService
|
||||
func NewOCDav(cfg *ociscfg.Config) suture.Service {
|
||||
cfg.Storage.Commons = cfg.Commons
|
||||
return OCDavSutureService{
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
}
|
||||
|
||||
func (s OCDavSutureService) Serve(ctx context.Context) error {
|
||||
s.cfg.Reva.Frontend.Context = ctx
|
||||
f := &flag.FlagSet{}
|
||||
cmdFlags := OCDav(s.cfg).Flags
|
||||
for k := range cmdFlags {
|
||||
if err := cmdFlags[k].Apply(f); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
cliCtx := cli.NewContext(nil, f, nil)
|
||||
if OCDav(s.cfg).Before != nil {
|
||||
if err := OCDav(s.cfg).Before(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := OCDav(s.cfg).Action(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// Users is the entrypoint for the sharing command.
|
||||
// Users is the entrypoint for the users command.
|
||||
func Users(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "users",
|
||||
|
||||
@@ -165,8 +165,6 @@ type FrontendPort struct {
|
||||
DatagatewayPrefix string `yaml:"data_gateway_prefix"`
|
||||
Favorites bool `yaml:"favorites"`
|
||||
ProjectSpaces bool `yaml:"project_spaces"`
|
||||
OCDavInsecure bool `yaml:"ocdav_insecure"`
|
||||
OCDavPrefix string `yaml:"ocdav_prefix"`
|
||||
OCSPrefix string `yaml:"ocs_prefix"`
|
||||
OCSSharePrefix string `yaml:"ocs_share_prefix"`
|
||||
OCSHomeNamespace string `yaml:"ocs_home_namespace"`
|
||||
@@ -433,8 +431,26 @@ type LDAPGroupSchema struct {
|
||||
|
||||
// OCDav defines the available ocdav configuration.
|
||||
type OCDav struct {
|
||||
WebdavNamespace string `yaml:"webdav_namespace"`
|
||||
DavFilesNamespace string `yaml:"dav_files_namespace"`
|
||||
// Addr to listen to with the http server for the ocdav service
|
||||
Addr string `yaml:"addr"`
|
||||
Prefix string `yaml:"prefix"`
|
||||
WebdavNamespace string `yaml:"webdav_namespace"`
|
||||
FilesNamespace string `yaml:"files_namespace"`
|
||||
SharesNamespace string `yaml:"shares_namespace"`
|
||||
// PublicURL used to redirect /s/{token} URLs to
|
||||
PublicURL string `yaml:"public_url"`
|
||||
|
||||
// Addr to listen to with the debug http server
|
||||
DebugAddr string `yaml:"debug_addr"`
|
||||
|
||||
// GatewaySVC to forward CS3 requests to TODO use registry
|
||||
GatewaySVC string `yaml:"gateway_svc"`
|
||||
// JWTSecret used to verify reva access token
|
||||
JWTSecret string `yaml:"jwt_secret"`
|
||||
// Insecure certificates allowed when making requests to the gateway
|
||||
Insecure bool `yaml:"insecure"`
|
||||
// Timeout in seconds when making requests to the gateway
|
||||
Timeout int64 `yaml:"timeout"`
|
||||
}
|
||||
|
||||
// Archiver defines the available archiver configuration.
|
||||
@@ -455,7 +471,6 @@ type Reva struct {
|
||||
LDAP LDAP `yaml:"ldap"`
|
||||
UserGroupRest UserGroupRest `yaml:"user_group_rest"`
|
||||
UserOwnCloudSQL UserOwnCloudSQL `yaml:"user_owncloud_sql"`
|
||||
OCDav OCDav `yaml:"ocdav"`
|
||||
Archiver Archiver `yaml:"archiver"`
|
||||
UserStorage StorageConfig `yaml:"user_storage"`
|
||||
MetadataStorage StorageConfig `yaml:"metadata_storage"`
|
||||
@@ -483,7 +498,7 @@ type Reva struct {
|
||||
// Services and Ports will be ignored if this is used
|
||||
Configs map[string]interface{} `yaml:"configs"`
|
||||
// chunking and resumable upload config (TUS)
|
||||
UploadMaxChunkSize int `yaml:"uppload_max_chunk_size"`
|
||||
UploadMaxChunkSize int `yaml:"upload_max_chunk_size"`
|
||||
UploadHTTPMethodOverride string `yaml:"upload_http_method_override"`
|
||||
// checksumming capabilities
|
||||
ChecksumSupportedTypes []string `yaml:"checksum_supported_types"`
|
||||
@@ -512,6 +527,7 @@ type Config struct {
|
||||
File string `yaml:"file"`
|
||||
Log *shared.Log `yaml:"log"`
|
||||
Debug Debug `yaml:"debug"`
|
||||
OCDav OCDav `yaml:"ocdav"`
|
||||
Reva Reva `yaml:"reva"`
|
||||
Tracing Tracing `yaml:"tracing"`
|
||||
Asset Asset `yaml:"asset"`
|
||||
@@ -567,10 +583,6 @@ func structMappings(cfg *Config) []shared.EnvBinding {
|
||||
EnvVars: []string{"OCIS_INSECURE", "STORAGE_FRONTEND_ARCHIVER_INSECURE"},
|
||||
Destination: &cfg.Reva.Frontend.ArchiverInsecure,
|
||||
},
|
||||
{
|
||||
EnvVars: []string{"OCIS_INSECURE", "STORAGE_FRONTEND_OCDAV_INSECURE"},
|
||||
Destination: &cfg.Reva.Frontend.OCDavInsecure,
|
||||
},
|
||||
{
|
||||
EnvVars: []string{"OCIS_INSECURE", "STORAGE_OIDC_INSECURE"},
|
||||
Destination: &cfg.Reva.OIDC.Insecure,
|
||||
@@ -773,18 +785,6 @@ func structMappings(cfg *Config) []shared.EnvBinding {
|
||||
EnvVars: []string{"STORAGE_TRANSFER_SECRET"},
|
||||
Destination: &cfg.Reva.TransferSecret,
|
||||
},
|
||||
{
|
||||
EnvVars: []string{"STORAGE_CHUNK_FOLDER"},
|
||||
Destination: &cfg.Reva.OCDav.WebdavNamespace,
|
||||
},
|
||||
{
|
||||
EnvVars: []string{"STORAGE_WEBDAV_NAMESPACE"},
|
||||
Destination: &cfg.Reva.OCDav.WebdavNamespace,
|
||||
},
|
||||
{
|
||||
EnvVars: []string{"STORAGE_DAV_FILES_NAMESPACE"},
|
||||
Destination: &cfg.Reva.OCDav.DavFilesNamespace,
|
||||
},
|
||||
{
|
||||
EnvVars: []string{"STORAGE_ARCHIVER_MAX_NUM_FILES"},
|
||||
Destination: &cfg.Reva.Archiver.MaxNumFiles,
|
||||
@@ -821,10 +821,6 @@ func structMappings(cfg *Config) []shared.EnvBinding {
|
||||
EnvVars: []string{"STORAGE_FRONTEND_PROJECT_SPACES"},
|
||||
Destination: &cfg.Reva.Frontend.ProjectSpaces,
|
||||
},
|
||||
{
|
||||
EnvVars: []string{"STORAGE_FRONTEND_OCDAV_PREFIX"},
|
||||
Destination: &cfg.Reva.Frontend.OCDavPrefix,
|
||||
},
|
||||
{
|
||||
EnvVars: []string{"STORAGE_FRONTEND_OCS_PREFIX"},
|
||||
Destination: &cfg.Reva.Frontend.OCSPrefix,
|
||||
@@ -1810,5 +1806,43 @@ func structMappings(cfg *Config) []shared.EnvBinding {
|
||||
EnvVars: []string{"STORAGE_PERMISSIONS_ENDPOINT"},
|
||||
Destination: &cfg.Reva.Permissions.Endpoint,
|
||||
},
|
||||
|
||||
// ocdav
|
||||
{
|
||||
EnvVars: []string{"OCDAV_ADDR"},
|
||||
Destination: &cfg.OCDav.Addr,
|
||||
},
|
||||
{
|
||||
EnvVars: []string{"OCDAV_DEBUG_ADDR"},
|
||||
Destination: &cfg.OCDav.DebugAddr,
|
||||
},
|
||||
{
|
||||
EnvVars: []string{"OCDAV_PREFIX"},
|
||||
Destination: &cfg.OCDav.Prefix,
|
||||
},
|
||||
{
|
||||
EnvVars: []string{"OCDAV_WEBDAV_NAMESPACE"},
|
||||
Destination: &cfg.OCDav.WebdavNamespace,
|
||||
},
|
||||
{
|
||||
EnvVars: []string{"OCDAV_FILES_NAMESPACE"},
|
||||
Destination: &cfg.OCDav.FilesNamespace,
|
||||
},
|
||||
{
|
||||
EnvVars: []string{"OCDAV_SHARES_NAMESPACE"},
|
||||
Destination: &cfg.OCDav.SharesNamespace,
|
||||
},
|
||||
{
|
||||
EnvVars: []string{"OCIS_URL", "OCDAV_PUBLIC_URL"},
|
||||
Destination: &cfg.OCDav.PublicURL,
|
||||
},
|
||||
{
|
||||
EnvVars: []string{"OCIS_INSECURE", "OCDAV_INSECURE"},
|
||||
Destination: &cfg.OCDav.Insecure,
|
||||
},
|
||||
{
|
||||
EnvVars: []string{"OCIS_JWT_SECRET", "OCDAV_JWT_SECRET"},
|
||||
Destination: &cfg.OCDav.JWTSecret,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,10 +91,6 @@ func DefaultConfig() *config.Config {
|
||||
JoinOwnCloudUUID: false,
|
||||
EnableMedialSearch: false,
|
||||
},
|
||||
OCDav: config.OCDav{
|
||||
WebdavNamespace: defaultStorageNamespace,
|
||||
DavFilesNamespace: defaultStorageNamespace,
|
||||
},
|
||||
Archiver: config.Archiver{
|
||||
MaxNumFiles: 10000,
|
||||
MaxSize: 1073741824,
|
||||
@@ -235,7 +231,7 @@ func DefaultConfig() *config.Config {
|
||||
Protocol: "",
|
||||
Endpoint: "",
|
||||
DebugAddr: "127.0.0.1:9141",
|
||||
Services: []string{"datagateway", "ocdav", "ocs", "appprovider"},
|
||||
Services: []string{"datagateway", "ocs", "appprovider"},
|
||||
Config: nil,
|
||||
Context: nil,
|
||||
Supervised: false,
|
||||
@@ -247,8 +243,6 @@ func DefaultConfig() *config.Config {
|
||||
DatagatewayPrefix: "data",
|
||||
Favorites: false,
|
||||
ProjectSpaces: true,
|
||||
OCDavInsecure: false, // true?
|
||||
OCDavPrefix: "",
|
||||
OCSPrefix: "ocs",
|
||||
OCSSharePrefix: defaultShareFolder,
|
||||
OCSHomeNamespace: defaultStorageNamespace,
|
||||
@@ -445,6 +439,20 @@ func DefaultConfig() *config.Config {
|
||||
ChecksumPreferredUploadType: "",
|
||||
DefaultUploadProtocol: "tus",
|
||||
},
|
||||
// TODO move ocdav config to a separate service
|
||||
OCDav: config.OCDav{
|
||||
Addr: "127.0.0.1:0", // :0 to pick any local free port
|
||||
DebugAddr: "127.0.0.1:9163",
|
||||
WebdavNamespace: defaultStorageNamespace,
|
||||
FilesNamespace: defaultStorageNamespace,
|
||||
SharesNamespace: defaultShareFolder,
|
||||
PublicURL: defaultPublicURL,
|
||||
Prefix: "",
|
||||
GatewaySVC: defaultGatewayAddr,
|
||||
Insecure: false, // true?
|
||||
Timeout: 84300,
|
||||
JWTSecret: "Pive-Fumkiu4",
|
||||
},
|
||||
Tracing: config.Tracing{
|
||||
Service: "storage",
|
||||
Type: "jaeger",
|
||||
|
||||
Reference in New Issue
Block a user