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

Add the ability to delete an etcd snapshot locally or from S3 #3277

Merged
merged 12 commits into from
May 7, 2021

Conversation

briandowns
Copy link
Contributor

Proposed Changes

This change introduces the ability to perform a deletion of an etcd snapshot from either local storage or an S3 compatible object store.

A subcommand has been added to etcd-snapshot called "delete" that triggers this new behavior and takes all of the same flags as it's parent, allowing for the same default overrides and S3 access.

The "delete" subcommand is depend upon positional arguments being the name of the snapshots to be removed. If none are provided, it errors out.

Types of Changes

This change will require a documentation update. I will do that when the rest of the etcd snapshot CLI CRUD operations are complete.

Verification

For locally stored etcd snapshots:

Create a snapshot

k3s etcd-snapshot  

Get the name of the snapshot from the output.

k3s etcd-snapshot  delete <SNAPSHOT_NAME>

For etcd snapshots stored in s3:

Create a snapshot

k3s etcd-snapshot --s3 --s3-bucket=k3s-snapshots --s3-access-key=<REDACTED> --s3-secret-key=<REDACTED> 

Get the name of the snapshot from the output.

k3s etcd-snapshot delete --s3 --s3-bucket=k3s-snapshots --s3-access-key=<REDACTED> --s3-secret-key=<REDACTED> <SNAPSHOT_NAME>

Linked Issues

#3240

Further Comments

@briandowns briandowns added kind/enhancement An improvement to existing functionality EtcdBackupRestoreEnhancements labels May 5, 2021
@briandowns briandowns requested a review from a team May 5, 2021 03:33
@briandowns briandowns self-assigned this May 5, 2021
@briandowns briandowns requested a review from brandond May 5, 2021 16:06
},
}

func NewEtcdSnapshotCommand(action func(*cli.Context) error, subcommands []cli.Command) cli.Command {
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer the old func NewEtcdSnapshotCommand(action func(*cli.Context) error) signature. Use it to create the snapshot command and then modify the result by hanging the sub-command onto it. I think this would read cleaner in a PR and in general.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was the preferred route but doing so resulted in the binary being bloated passed the checked limit.

Copy link
Contributor

Choose a reason for hiding this comment

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

double-you-tee-eff-dot-gif

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we need to use the command factory pattern to bind different actions to the command and subcommands.
For the 'real' binaries we use the actual functions (Run, Delete, etc) as the command actions; for the self-extracting wrapper we need to bind the internalCLIAction to the command and subcommands so that it can (if necessary) extract out the real binaries and then exec them.

Signed-off-by: Brian Downs <[email protected]>
@briandowns briandowns requested review from brandond and dweomer May 5, 2021 23:06
Signed-off-by: Brian Downs <[email protected]>
Signed-off-by: Brian Downs <[email protected]>
@briandowns briandowns requested review from brandond and dweomer May 6, 2021 01:23
briandowns added 2 commits May 5, 2021 18:23
Signed-off-by: Brian Downs <[email protected]>
Signed-off-by: Brian Downs <[email protected]>
Signed-off-by: Brian Downs <[email protected]>
Oats87
Oats87 previously requested changes May 6, 2021
Signed-off-by: Brian Downs <[email protected]>
@briandowns briandowns requested review from Oats87 and brandond May 6, 2021 21:11
Signed-off-by: Brian Downs <[email protected]>
@briandowns briandowns dismissed Oats87’s stale review May 7, 2021 02:08

Remediated

@briandowns briandowns merged commit e998cd1 into k3s-io:master May 7, 2021
briandowns added a commit to briandowns/k3s that referenced this pull request May 19, 2021
…#3277)

* Add the ability to delete a given set of etcd snapshots from the CLI for locally stored and S3 store snapshots.

Signed-off-by: Brian Downs <[email protected]>
briandowns added a commit to briandowns/k3s that referenced this pull request May 19, 2021
…#3277)

* Add the ability to delete a given set of etcd snapshots from the CLI for locally stored and S3 store snapshots.

Signed-off-by: Brian Downs <[email protected]>
briandowns added a commit to briandowns/k3s that referenced this pull request May 19, 2021
…#3277)

* Add the ability to delete a given set of etcd snapshots from the CLI for locally stored and S3 store snapshots.

Signed-off-by: Brian Downs <[email protected]>
briandowns added a commit to briandowns/k3s that referenced this pull request May 19, 2021
…#3277)

* Add the ability to delete a given set of etcd snapshots from the CLI for locally stored and S3 store snapshots.

Signed-off-by: Brian Downs <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement An improvement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants