[#42] Support expiration lifecycle #418
Labels
No labels
P0
P1
P2
P3
good first issue
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-s3-gw#418
Loading…
Reference in a new issue
No description provided.
Delete branch "mbiryukova/frostfs-s3-gw:feature/support_lifecycle"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #42
Signed-off-by: Marina Biryukova m.biryukova@yadro.com
[#42] Support expiration lifecycleto WIP: [#42] Support expiration lifecycle7f3fba1f55
to1c61e59389
WIP: [#42] Support expiration lifecycleto [#42] Support expiration lifecycle@ -90,2 +91,4 @@
func (b *BucketInfo) CORSObjectName() string { return bktCORSConfigurationObject }
func (b *BucketInfo) LifecycleConfigurationObjectName() string {
return bktLifecycleConfigurationObject
Let's also use container id or at least bucket name to form lifecycle object name
@ -0,0 +19,4 @@
Expiration *LifecycleExpiration `xml:"Expiration,omitempty"`
Filter *LifecycleRuleFilter `xml:"Filter,omitempty"`
ID string `xml:"ID,omitempty"`
NoncurrentVersionExpiration *NoncurrentVersionExpiration `xml:"NoncurrentVersionExpiration,omitempty"`
Maybe
Noncurrent*
->NonCurrent*
?@ -0,0 +24,4 @@
var (
ctx = r.Context()
reqInfo = middleware.GetReqInfo(ctx)
)
I suppose we can write just
@ -0,0 +39,4 @@
}
if err = middleware.EncodeToResponse(w, cfg); err != nil {
h.logAndSendError(w, "something went wrong", reqInfo, err)
Let's write more meaningful message (e.g.
could not encode GetBucketLifecycle response
)Then maybe it’s worth fixing in other places too
Big things start small
@ -0,0 +52,4 @@
tee = io.TeeReader(r.Body, &buf)
)
// Content-Md5 is required and should be set
Why?
Will add link to spec
Oh, sorry.
I was seeing wrong (deprecated method) spec https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketLifecycle.html
@ -0,0 +36,4 @@
lifecycleBkt = p.BktInfo
prm.CopiesNumber = p.CopiesNumbers
} else {
lifecycleBkt = &data.BucketInfo{CID: n.lifecycleCnr}
It seems we have to fill more info about lifecycle container because in
objectPutAndHash
theHomomorphicHashDisabled
is used.Also when we use separate container to store lifecycle configuration we should use gateway key (in
objectPutAndHash
function auth params for put request is being filled with user bearer token from access box or anonymous key that slightly incorrect)The same for other methods
@ -172,2 +176,4 @@
user.IDFromKey(&gateOwner, a.key.PrivateKey.PublicKey)
nnsClient := ns.NNS{}
err = nnsClient.Dial(a.cfg.GetString(cfgRPCEndpoint))
It seems we can use
a.bucketResolver
[#42] Support expiration lifecycleto [#42] Support expiration lifecycle1c61e59389
todfaa180995
@ -0,0 +52,4 @@
return apiErr.GetAPIError(apiErr.ErrInvalidDigest)
}
if hex.EncodeToString(hashBytes) != hex.EncodeToString(md5) {
I don't quite understand this condition. Can you elaborate what are we checking here?
Seems that just hash bytes can be compared here
@ -1037,0 +1054,4 @@
}
var id cid.ID
if strings.Contains(containerString, ".") {
Is this pattern is being used somewhere else?
I would expect something like
@ -710,1 +711,4 @@
# `containers` section
Containers configuration.
Let's add a bit more details.
@ -711,0 +720,4 @@
| Parameter | Type | SIGHUP reload | Default value | Description |
|-------------|----------|---------------|---------------|----------------------------------------------|
| `lifecycle` | `string` | no | | Container name for lifecycle configurations. |
Add
If not set, container of the bucket is used
dfaa180995
tod54b26dbfd
Looks good to me, lets see how it works in feature branch together with new lifecycler component.
@ -0,0 +65,4 @@
zap.String("oid", objID.EncodeToString()))
}
return apiErr.GetAPIError(apiErr.ErrInvalidDigest)
Why do we return this error?
By the way, why we don't update tree right after successful object uploading?
Because
Content-MD5
value doesn't match hash received after object uploading, configuration shouldn't be saved in this case@ -0,0 +75,4 @@
}
if !objIDToDeleteNotFound {
if n.lifecycleCnrInfo == nil {
Can we put extract these lines (78-88) to separate function (we have some duplication now)?
@ -1037,0 +1057,4 @@
if err != nil {
id, err = a.bucketResolver.Resolve(ctx, containerString)
}
if err != nil {
It seems we can move this condition into previous one. Now it looks a little odd.
For example:
@ -171,15 +174,22 @@ func (a *App) initLayer() {
var gateOwner user.ID
user.IDFromKey(&gateOwner, a.key.PrivateKey.PublicKey)
lifecycleCnrInfo, err := a.fetchContainerInfo(ctx, cfgContainersLifecycle)
Can we return exactly one non nil value from the
fetchContainerInfo
method? When you briefly look at this it seems we must configurecontainer.lifecycle
(but actually we must not).We can write something like this:
d54b26dbfd
to0e1ab11a1b