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

Spaces registry #2234

Merged
merged 268 commits into from
Dec 6, 2021
Merged

Spaces registry #2234

merged 268 commits into from
Dec 6, 2021

Conversation

butonic
Copy link
Contributor

@butonic butonic commented Nov 4, 2021

We are prototyping a spaces registry that uses spaceids instead of storageids to route requests. This should clarify the concepts we are pursuing with #2023 and #2016

cc @dragotin @kobergj

@butonic butonic force-pushed the spaces-registry-and-provider branch from a7d370e to 6380dc1 Compare November 4, 2021 16:25
butonic and others added 5 commits November 4, 2021 16:33
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
@lgtm-com
Copy link

lgtm-com bot commented Nov 5, 2021

This pull request introduces 3 alerts when merging 965bf36 into c35c530 - view on LGTM.com

new alerts:

  • 3 for Unreachable statement

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
@lgtm-com
Copy link

lgtm-com bot commented Nov 8, 2021

This pull request introduces 4 alerts when merging 4704592 into bb40f54 - view on LGTM.com

new alerts:

  • 3 for Missing error check
  • 1 for Uncontrolled data used in path expression

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
@lgtm-com
Copy link

lgtm-com bot commented Nov 8, 2021

This pull request introduces 1 alert when merging 70e7123 into bb40f54 - view on LGTM.com

new alerts:

  • 1 for Uncontrolled data used in path expression

@lgtm-com
Copy link

lgtm-com bot commented Dec 6, 2021

This pull request introduces 2 alerts when merging cbe1a2c into 147c0c2 - view on LGTM.com

new alerts:

  • 2 for Uncontrolled data used in path expression

@lgtm-com
Copy link

lgtm-com bot commented Dec 6, 2021

This pull request introduces 2 alerts when merging a023668 into 147c0c2 - view on LGTM.com

new alerts:

  • 2 for Uncontrolled data used in path expression

…torageprovider_static_test.go

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
@butonic butonic force-pushed the spaces-registry-and-provider branch from 352694d to b48b2f3 Compare December 6, 2021 13:14
@lgtm-com
Copy link

lgtm-com bot commented Dec 6, 2021

This pull request introduces 2 alerts when merging b48b2f3 into 147c0c2 - view on LGTM.com

new alerts:

  • 2 for Uncontrolled data used in path expression

@butonic butonic changed the base branch from master to edge December 6, 2021 14:37
@butonic butonic marked this pull request as ready for review December 6, 2021 14:41
@lgtm-com
Copy link

lgtm-com bot commented Dec 6, 2021

This pull request introduces 2 alerts when merging b48b2f3 into 255730c - view on LGTM.com

new alerts:

  • 2 for Uncontrolled data used in path expression

@butonic butonic merged commit b2a9a7e into cs3org:edge Dec 6, 2021
@butonic butonic deleted the spaces-registry-and-provider branch December 6, 2021 14:59
Copy link
Member

@refs refs left a comment

Choose a reason for hiding this comment

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

👍

Comment on lines +213 to +232
// resourcePath := statResponse.Info.Path

// if strings.HasPrefix(ref.GetPath(), resourcePath) {
// // The path corresponds to the resource to which the token has access.
// // We allow access to it.
// return true, nil
// }

// // If we arrived here that could mean that ref.GetPath is not prefixed with the storage mount path but resourcePath is
// // because it was returned by the gateway which will prefix it. To fix that we remove the mount path from the resourcePath.
// // resourcePath = "/users/<name>/some/path"
// // After the split we have [" ", "users", "<name>/some/path"].
// trimmedPath := "/" + strings.SplitN(resourcePath, "/", 3)[2]
// if strings.HasPrefix(ref.GetPath(), trimmedPath) {
// // The path corresponds to the resource to which the token has access.
// // We allow access to it.
// return true, nil
// }

// return false, nil
Copy link
Member

Choose a reason for hiding this comment

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

I'd remove these lines instead of commenting them. It is clutter.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed in #2383


statRes, err := s.stat(ctx, &storageprovider.StatRequest{
Ref: &storageprovider.Reference{Path: resName},
resChild := ""
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Nope. Removed in #2383

spaceID := ""
mountPath := providerInfos[i].ProviderPath

spacePaths := decodeSpacePaths(providerInfos[i].Opaque)
Copy link
Member

Choose a reason for hiding this comment

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

We're doing the same time and again. I think we could benefit with an abstraction for this section. Perhaps a function should be enough. Also, how volatile is providerInfos, err := s.findProviders(ctx, req.Ref) I would imagine looking for providers depending on a reference a costly unnecessary operation, since resources don't tend to change storages often (or at all...) so caching it would improve quite a bit. I'm unaware of any other caching efforts on this area as for now, but IIRC @kobergj enabled the cached and had it working. Is it because of this perhaps?

Copy link
Contributor

Choose a reason for hiding this comment

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

Caching is enabled in #2372 Provider caching is working there.

I moved logic to a dedicated function in #2383

_ = statCache.SetTTL(time.Duration(c.StatCacheTTL) * time.Second)
statCache.SkipTTLExtensionOnHit(true)

// mountCache := ttlcache.NewCache()
Copy link
Member

Choose a reason for hiding this comment

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

could all lines related to the mountCache be thrown away? it clutters a bit

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed together with caching in #2372

return spacePaths
}
if entry, ok := o.Map["space_paths"]; ok {
_ = json.Unmarshal(entry.Value, &spacePaths)
Copy link
Member

Choose a reason for hiding this comment

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

I think this method is wrong, and assuming too much. CS3 OpaqueEntries do have decoders, assuming the map is encoded in json, and using the json decoder might break things.

Copy link
Contributor

Choose a reason for hiding this comment

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

Added more decoders in #2383

SpaceType: spaceType,
// Mtime is set either as node.tmtime or as fi.mtime below
}

user := ctxpkg.ContextMustGetUser(ctx)

// filter out spaces user cannot access (currently based on stat permission)
Copy link
Member

Choose a reason for hiding this comment

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

clutter. remove these comments

Copy link
Contributor

Choose a reason for hiding this comment

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

Done in #2383

@@ -185,21 +186,24 @@ func (fs *Decomposedfs) NewUpload(ctx context.Context, info tusd.FileInfo) (uplo
log := appctx.GetLogger(ctx)
log.Debug().Interface("info", info).Msg("Decomposedfs: NewUpload")

fn := info.MetaData["filename"]
if fn == "" {
// sanity checks
Copy link
Member

Choose a reason for hiding this comment

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

spureous comment

Copy link
Contributor

Choose a reason for hiding this comment

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

Removed in #2383

return errtypes.AlreadyExists(n.ID) // path?
}

// Allow passing in the node id
Copy link
Member

Choose a reason for hiding this comment

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

spureous?

Copy link
Contributor

Choose a reason for hiding this comment

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

Removed in #2383

return
}

// try to remove the node
Copy link
Member

Choose a reason for hiding this comment

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

unnecessary comment, line below is expressive enough

Copy link
Contributor

Choose a reason for hiding this comment

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

Removed in #2383

e := t.Delete(ctx, n)
switch {
case e != nil:
appctx.GetLogger(ctx).Debug().Err(e).Msg("cannot move to trashcan")
Copy link
Member

Choose a reason for hiding this comment

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

rename: trashcan -> trashbin

Copy link
Contributor

Choose a reason for hiding this comment

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

Changed in #2383

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants