Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Extract storage layer + cs3impl #623

Merged
merged 29 commits into from
Oct 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f6732fd
Extract storage layer + cs3impl
IljaN Sep 28, 2020
901ada3
Basic implementation of CS3 [WIP]
IljaN Sep 29, 2020
4428b77
- Implemented delete + some test
IljaN Sep 29, 2020
5f37acb
Add config for repo implementations
kulmann Sep 29, 2020
d108f00
Comment tests for now
kulmann Sep 29, 2020
4c17d56
Fix config
kulmann Sep 29, 2020
60efd63
Fix DeleteGroup implementation and staticchecks
kulmann Sep 29, 2020
b1b1ecf
Fix copy/paste typo in log message
kulmann Sep 29, 2020
355c042
load default accounts / groups using the service repository
refs Sep 29, 2020
5168f8e
Create data subfolders on disk repo start
kulmann Sep 29, 2020
2ffff93
Add changelog
kulmann Sep 30, 2020
a02579b
Start reva storage metadata by default in ocis
kulmann Sep 30, 2020
b01fc62
Fix order of extensions on startup
kulmann Sep 30, 2020
d316aca
Reuse persisted bleve index
kulmann Sep 30, 2020
f5a51cd
Fix runtime startup order issues
kulmann Sep 30, 2020
e674b5c
Move micro-framework error handling out of storage
IljaN Sep 30, 2020
403ccc6
Remove commented code
IljaN Sep 30, 2020
9c64f6a
Create data-provider client
IljaN Sep 30, 2020
60a3f3c
Fix config variable naming
kulmann Oct 1, 2020
673d7cf
Hardcoded service user for auth requests
kulmann Oct 1, 2020
862329c
Fix service user usage for eos
kulmann Oct 1, 2020
14bd4c8
Get rid of unused serviceID and redundant log lines
kulmann Oct 5, 2020
675906c
Get rid of named return and obsolete build tag
kulmann Oct 5, 2020
b759691
Build paths with path.Join
kulmann Oct 5, 2020
05e314e
Replace ioutil.ReadAll with a buffered decoder
kulmann Oct 5, 2020
e145c3b
Handle error on response.Body.Close()
kulmann Oct 5, 2020
b49126e
Revert "Replace ioutil.ReadAll with a buffered decoder"
kulmann Oct 5, 2020
3081dd1
Fix OCS test infrastructure
kulmann Oct 5, 2020
ff4c802
Merge branch 'master' into extract_storage_layer
kulmann Oct 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions accounts/changelog/unreleased/configurable-storage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Change: Choose disk or cs3 storage for accounts and groups

The accounts service now has an abstraction layer for the storage. In addition to the local disk implementation
we implemented a cs3 storage, which is the new default for the accounts service.

https://github.com/owncloud/ocis/pull/623

3 changes: 3 additions & 0 deletions accounts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ go 1.13
require (
github.com/CiscoM31/godata v0.0.0-20191007193734-c2c4ebb1b415
github.com/blevesearch/bleve v1.0.9
github.com/cs3org/go-cs3apis v0.0.0-20200730121022-c4f3d4f7ddfd
github.com/cs3org/reva v1.1.0
github.com/cznic/b v0.0.0-20181122101859-a26611c4d92d // indirect
github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548 // indirect
github.com/cznic/strutil v0.0.0-20181122101858-275e90344537 // indirect
Expand Down Expand Up @@ -32,6 +34,7 @@ require (
github.com/tredoe/osutil v1.0.5
golang.org/x/net v0.0.0-20200822124328-c89045814202
google.golang.org/genproto v0.0.0-20200624020401-64a14ca9d1ad
google.golang.org/grpc v1.31.0
google.golang.org/protobuf v1.25.0
)

Expand Down
28 changes: 28 additions & 0 deletions accounts/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,32 @@ type Log struct {
Color bool
}

// Repo defines which storage implementation is to be used.
type Repo struct {
Disk Disk
CS3 CS3
}

// Disk is the local disk implementation of the storage.
type Disk struct {
Path string
}

// CS3 is the cs3 implementation of the storage.
type CS3 struct {
ProviderAddr string
DataURL string
DataPrefix string
}

// ServiceUser defines the user required for EOS
type ServiceUser struct {
UUID string
Username string
UID int64
GID int64
}

// Config merges all Account config parameters.
type Config struct {
LDAP LDAP
Expand All @@ -70,6 +96,8 @@ type Config struct {
Asset Asset
Log Log
TokenManager TokenManager
Repo Repo
ServiceUser ServiceUser
}

// New returns a new config.
Expand Down
56 changes: 56 additions & 0 deletions accounts/pkg/flagset/flagset.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,62 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"ACCOUNTS_JWT_SECRET"},
Destination: &cfg.TokenManager.JWTSecret,
},
&cli.StringFlag{
Name: "storage-disk-path",
Value: "",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have a default value?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. ;-) We have default values for the CS3 Repo implementation, since it's supposed to be the default. When any other storage is configured (we only have the disk implementation as "other storage") we switch over to that.

TL;DR: Setting a default here would switch back to using the local disk for persisting accounts. We want to use CS3 as default, so we can't have a default disk path.

Usage: "Path on the local disk, e.g. /var/tmp/ocis-accounts",
EnvVars: []string{"ACCOUNTS_STORAGE_DISK_PATH"},
Destination: &cfg.Repo.Disk.Path,
},
&cli.StringFlag{
Name: "storage-cs3-provider-addr",
Value: "localhost:9215",
Usage: "bind address for the metadata storage provider",
EnvVars: []string{"ACCOUNTS_STORAGE_CS3_PROVIDER_ADDR"},
Destination: &cfg.Repo.CS3.ProviderAddr,
},
&cli.StringFlag{
Name: "storage-cs3-data-url",
Value: "http://localhost:9216",
Usage: "http endpoint of the metadata storage",
EnvVars: []string{"ACCOUNTS_STORAGE_CS3_DATA_URL"},
Destination: &cfg.Repo.CS3.DataURL,
},
&cli.StringFlag{
Name: "storage-cs3-data-prefix",
Value: "data",
Usage: "path prefix for the http endpoint of the metadata storage, without leading slash",
EnvVars: []string{"ACCOUNTS_STORAGE_CS3_DATA_PREFIX"},
Destination: &cfg.Repo.CS3.DataPrefix,
},
&cli.StringFlag{
Name: "service-user-uuid",
Value: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad",
Usage: "uuid of the internal service user (required on EOS)",
EnvVars: []string{"ACCOUNTS_SERVICE_USER_UUID"},
Destination: &cfg.ServiceUser.UUID,
},
&cli.StringFlag{
Name: "service-user-username",
Value: "",
Usage: "username of the internal service user (required on EOS)",
EnvVars: []string{"ACCOUNTS_SERVICE_USER_USERNAME"},
Destination: &cfg.ServiceUser.Username,
},
&cli.Int64Flag{
Name: "service-user-uid",
Value: 0,
Usage: "uid of the internal service user (required on EOS)",
EnvVars: []string{"ACCOUNTS_SERVICE_USER_UID"},
Destination: &cfg.ServiceUser.UID,
},
&cli.Int64Flag{
Name: "service-user-gid",
Value: 0,
Usage: "gid of the internal service user (required on EOS)",
EnvVars: []string{"ACCOUNTS_SERVICE_USER_GID"},
Destination: &cfg.ServiceUser.GID,
},
}
}

Expand Down
30 changes: 3 additions & 27 deletions accounts/pkg/proto/v0/accounts.pb.micro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func init() {

cfg := config.New()
cfg.Server.AccountsDataPath = dataPath
cfg.Repo.Disk.Path = dataPath
var hdlr *svc.Service
var err error

Expand Down Expand Up @@ -754,7 +755,6 @@ func TestGetGroupInvalidID(t *testing.T) {
assert.IsType(t, &proto.Group{}, resp)
assert.Empty(t, resp)
assert.Error(t, err)
assert.Equal(t, "{\"id\":\".\",\"code\":404,\"detail\":\"could not read group: open accounts-store/groups/42: no such file or directory\",\"status\":\"Not Found\"}", err.Error())
cleanUp(t)
}

Expand Down Expand Up @@ -804,11 +804,6 @@ func TestDeleteGroupNotExisting(t *testing.T) {
assert.IsType(t, &empty.Empty{}, res)
assert.Empty(t, res)
assert.Error(t, err)
assert.Equal(
t,
fmt.Sprintf("{\"id\":\".\",\"code\":404,\"detail\":\"could not read group: open accounts-store/groups/%v: no such file or directory\",\"status\":\"Not Found\"}", id),
err.Error(),
)
}
cleanUp(t)
}
Expand All @@ -826,17 +821,12 @@ func TestDeleteGroupInvalidId(t *testing.T) {
client := service.Client()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)

for id, val := range invalidIds {
for id := range invalidIds {
req := &proto.DeleteGroupRequest{Id: id}
res, err := cl.DeleteGroup(context.Background(), req)
assert.IsType(t, &empty.Empty{}, res)
assert.Empty(t, res)
assert.Error(t, err)
assert.Equal(
t,
fmt.Sprintf("{\"id\":\".\",\"code\":500,\"detail\":\"could not clean up group id: invalid id %v\",\"status\":\"Internal Server Error\"}", val),
err.Error(),
)
}
cleanUp(t)
}
Expand All @@ -859,11 +849,7 @@ func TestUpdateGroup(t *testing.T) {
assert.IsType(t, &proto.Group{}, res)
assert.Empty(t, res)
assert.Error(t, err)
assert.Equal(
t,
"{\"id\":\".\",\"code\":500,\"detail\":\"not implemented\",\"status\":\"Internal Server Error\"}",
err.Error(),
)

cleanUp(t)
}

Expand Down Expand Up @@ -953,11 +939,6 @@ func TestAddMemberNonExisting(t *testing.T) {
assert.IsType(t, &proto.Group{}, res)
assert.Empty(t, res)
assert.Error(t, err)
assert.Equal(
t,
fmt.Sprintf("{\"id\":\".\",\"code\":404,\"detail\":\"could not read account: open accounts-store/accounts/%v: no such file or directory\",\"status\":\"Not Found\"}", id),
err.Error(),
)
}

// Check group is not changed
Expand Down Expand Up @@ -1029,11 +1010,6 @@ func TestRemoveMemberNonExistingUser(t *testing.T) {
assert.IsType(t, &proto.Group{}, res)
assert.Empty(t, res)
assert.Error(t, err)
assert.Equal(
t,
fmt.Sprintf("{\"id\":\".\",\"code\":404,\"detail\":\"could not read account: open accounts-store/accounts/%v: no such file or directory\",\"status\":\"Not Found\"}", id),
err.Error(),
)
}

// Check group is not changed
Expand Down
Loading