-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Remove all versions of a file form the S3 bucket #9171
Conversation
/cc @rifelpet |
Hm this would effect every s3 object that Kops manages, correct? And we'll need a separate etcd-manager PR specifically for its backups? I definitely think having etcd-manager delete all versions of its backups when it deletes the latest version of the object makes sense in essentially all situations. I'm wondering if there are situations where users would not want this behavior for all Kops objects though. Maybe its worth listing the situations in which Kops removes s3 objects. Is it ever more than the I'm wondering how we could go about making this optional, if we decide there are valid cases where we wouldn't want this behavior. |
There is a similar case for vault as well. There I permanently remove all versions, but that may indeed not be necessarily what users want. |
This would indeed affect any S3 object that Kops manages. Seems to me that at the moment Kops only uses the concept of versions for existing files to have some sort of history. Not sure if anyone expects to have the versions for deleted files. Maybe removing an instance group by mistake would be inconvenient, not being able to restore it from S3 history. Though, we should see if this is the intended purpose for S3 versions. If we really want this, we could copy the file to some backup location instead. |
If we added a new |
Sounds good to me. I'll go ahead and do the change. |
Kops references are: Deleting the cluster and instance group are the only cases where I could consider a user wanting the backups. Not that I want the backups. |
There is also the option to rename the previous Remove() to SoftRemove() and use it only for cluster and instance group. |
@justinsb any thoughts on how best to handle this? |
return err | ||
} | ||
|
||
klog.V(8).Infof("removing file %s", p) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "removing all versions of %s" or "remove file %s (all versions)" might be clearer
@@ -59,6 +59,9 @@ type Path interface { | |||
// Remove deletes the file | |||
Remove() error | |||
|
|||
// RemoveAll completely deletes the file (with all its versions and markers) | |||
RemoveAll() error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: RemoveAllVersions might be clearer (vs this being a recursive delete or something akin to MkdirAll)
Prefix: aws.String(p.key), | ||
} | ||
|
||
response, err := client.ListObjectVersions(request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBD: will this require new IAM permissions?
So IIRC kops predates versioned buckets, or at least I wasn't aware of them at the time. People started using (quite rightly) for the kops state store, to recover from disasters where they accidentally deleted some of those files. The interaction with etcd-manager backups was - however - unfortunate! We added that later, and I'm pretty sure it was not the intention of people that enabled versioned buckets to keep their backups forever. So I'm all in favor of what we have here, where we delete those old versions, but only for etcd backup files. I do wonder whether this will require new IAM permissions, but I think we should:
In any case, first step is likely to get this merged; then we can get it into etcd-manager; then we can add any missing permissions to kops... /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hakman, justinsb The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
FYI, this change does not work for buckets with S3 Object Lock enabled. See kubernetes-sigs/etcd-manager#18. |
Kops uses versioned S3 buckets for the state store, which is also used for storing etcd backups.
Currently versions are not deleted and the bucket usage keeps growing over time.
etcd-manager
should be adjusted to use this change.The change works for both versioned and unversioned buckets. In the case of unversioned bucket, the version ID is "null" and deletion still works as expected.
This won't fix older versions that were not deleted, but going forward removal should be permanent.