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

[Release-1.26] - etcd-snapshot prune does not load retention policy from config #9683

Closed
brandond opened this issue Mar 7, 2024 · 1 comment
Assignees

Comments

@brandond
Copy link
Member

brandond commented Mar 7, 2024

Backport fix for etcd-snapshot prune does not load retention policy from config

@ShylajaDevadiga
Copy link
Contributor

Validated using commit id 8d24a9d on release-1.26 branch

Environment Details

Infrastructure
Cloud EC2 instance

Node(s) CPU architecture, OS, and Version:

$ cat /etc/os-release 
PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"

Cluster Configuration:
Single node

Config.yaml:

etcd-snapshot-retention: 2

Steps to reproduce the issue and validate the fix

  1. Copy config.yaml
  2. Install k3s

Results from reproducing the issue using k3s version v1.26.14+k3s1
--etcd-snapshot-retention was ignored


ubuntu@ip-172-31-7-118:~$ cat config.yaml 
etcd-snapshot-retention: 2

ubuntu@ip-172-31-7-118:~$ sudo k3s etcd-snapshot list
WARN[0000] Unknown flag --etcd-snapshot-retention found in config.yaml, skipping 
Name                                 Location                                                                             Size    Created
on-demand-ip-172-31-7-118-1710182198 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710182198 565280  2024-03-11T18:36:38Z
on-demand-ip-172-31-7-118-1710182201 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710182201 737312  2024-03-11T18:36:41Z
on-demand-ip-172-31-7-118-1710182202 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710182202 737312  2024-03-11T18:36:42Z
on-demand-ip-172-31-7-118-1710182210 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710182210 1036320 2024-03-11T18:36:50Z
ubuntu@ip-172-31-7-118:~$ sudo k3s etcd-snapshot prune
WARN[0000] Unknown flag --etcd-snapshot-retention found in config.yaml, skipping 
INFO[0000] Applying snapshot retention=5 to local snapshots with prefix on-demand in /var/lib/rancher/k3s/server/db/snapshots 
INFO[0000] Reconciling ETCDSnapshotFile resources       
INFO[0000] Reconciliation of ETCDSnapshotFile resources complete 
ubuntu@ip-172-31-7-118:~$ sudo k3s etcd-snapshot list
WARN[0000] Unknown flag --etcd-snapshot-retention found in config.yaml, skipping 
Name                                 Location                                                                             Size    Created
on-demand-ip-172-31-7-118-1710182198 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710182198 565280  2024-03-11T18:36:38Z
on-demand-ip-172-31-7-118-1710182201 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710182201 737312  2024-03-11T18:36:41Z
on-demand-ip-172-31-7-118-1710182202 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710182202 737312  2024-03-11T18:36:42Z
on-demand-ip-172-31-7-118-1710182210 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710182210 1036320 2024-03-11T18:36:50Z
ubuntu@ip-172-31-7-118:~$
 

Results from validation using k3s version v1.26.14+k3s-8d24a9dc
Cannot pass two forms of the same flag

$ cat config.yaml 

etcd-snapshot-retention: 2
snapshot-retention: 2

$ sudo k3s etcd-snapshot save
Incorrect Usage: Cannot use two forms of the same flag: etcd-snapshot-retention snapshot-retention

Passing either snapshot-retention: 2 and etcd-snapshot-retention: 2 retained the expected count of snapshots

ubuntu@ip-172-31-7-118:~$ cat config.yaml 
snapshot-retention: 2

ubuntu@ip-172-31-7-118:~$ k3s -v
k3s version v1.26.14+k3s-8d24a9dc (8d24a9dc)
go version go1.21.7

ubuntu@ip-172-31-7-118:~$ sudo k3s etcd-snapshot list
Name                                 Location                                                                             Size   Created
on-demand-ip-172-31-7-118-1710182421 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710182421 688160 2024-03-11T18:40:21Z
on-demand-ip-172-31-7-118-1710182424 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710182424 700448 2024-03-11T18:40:24Z
on-demand-ip-172-31-7-118-1710182426 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710182426 720928 2024-03-11T18:40:26Z
on-demand-ip-172-31-7-118-1710182428 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710182428 729120 2024-03-11T18:40:28Z
ubuntu@ip-172-31-7-118:~$ sudo k3s etcd-snapshot prune
INFO[0000] Applying snapshot retention=2 to local snapshots with prefix on-demand in /var/lib/rancher/k3s/server/db/snapshots 
INFO[0000] Removing local snapshot /var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710182424 
INFO[0000] Removing local snapshot /var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710182421 
INFO[0000] Reconciling ETCDSnapshotFile resources       
INFO[0000] Deleting ETCDSnapshotFile for on-demand-ip-172-31-7-118-1710182421 
INFO[0000] Deleting ETCDSnapshotFile for on-demand-ip-172-31-7-118-1710182424 
INFO[0000] Reconciliation of ETCDSnapshotFile resources complete 
ubuntu@ip-172-31-7-118:~$ sudo k3s etcd-snapshot list
Name                                 Location                                                                             Size   Created
on-demand-ip-172-31-7-118-1710182426 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710182426 720928 2024-03-11T18:40:26Z
on-demand-ip-172-31-7-118-1710182428 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710182428 729120 2024-03-11T18:40:28Z

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

No branches or pull requests

2 participants