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

etcd-snapshot prune does not load retention policy from config #9532

Closed
inichols opened this issue Feb 20, 2024 · 1 comment
Closed

etcd-snapshot prune does not load retention policy from config #9532

inichols opened this issue Feb 20, 2024 · 1 comment
Assignees
Milestone

Comments

@inichols
Copy link

Environmental Info:
K3s Version:
k3s version v1.26.13+k3s2 (489d9b3)
go version go1.20.13

Node(s) CPU architecture, OS, and Version:
6.2.0-36-generic #37-Ubuntu SMP PREEMPT_DYNAMIC Wed Oct 4 10:14:28 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Cluster Configuration:
1 server cluster

Describe the bug:

When running k3s etcd-snapshot prune would expect it to honor your snapshot retention that you have set in your config.
Steps To Reproduce:

  • Installed K3s:
  • Have both etcd-snapshot-retention": 2 and snapshot-retention: 2 in your config
  • Run k3s etcd-snapshot prune
  • See INFO[0000] Applying snapshot retention=5 to local snapshots with prefix on-demand in /var/lib/rancher/k3s/server/db/snapshots

Expected behavior:

The INFO message should have snapshot retention=2 per what was set in the config
Actual behavior:

config is ignored and default of 5 is set
Additional context / logs:

Related PR: #9502

@ShylajaDevadiga
Copy link
Contributor

ShylajaDevadiga commented Mar 11, 2024

Validated using latest commit id 364dfd8 on master 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.29.2+k3s1


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 --snapshot-retention found in config.yaml, skipping 
Name                                 Location                                                                             Size    Created
on-demand-ip-172-31-7-118-1710176560 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710176560 725024  2024-03-11T17:02:40Z
on-demand-ip-172-31-7-118-1710176562 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710176562 725024  2024-03-11T17:02:42Z
on-demand-ip-172-31-7-118-1710176563 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710176563 749600  2024-03-11T17:02:43Z
on-demand-ip-172-31-7-118-1710176564 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710176564 765984  2024-03-11T17:02:44Z
on-demand-ip-172-31-7-118-1710176573 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710176573 1191968 2024-03-11T17:02:53Z

ubuntu@ip-172-31-7-118:~$ sudo k3s etcd-snapshot prune
WARN[0000] Unknown flag --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 --snapshot-retention found in config.yaml, skipping 
Name                                 Location                                                                             Size    Created
on-demand-ip-172-31-7-118-1710176560 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710176560 725024  2024-03-11T17:02:40Z
on-demand-ip-172-31-7-118-1710176562 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710176562 725024  2024-03-11T17:02:42Z
on-demand-ip-172-31-7-118-1710176563 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710176563 749600  2024-03-11T17:02:43Z
on-demand-ip-172-31-7-118-1710176564 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710176564 765984  2024-03-11T17:02:44Z
on-demand-ip-172-31-7-118-1710176573 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710176573 1191968 2024-03-11T17:02:53Z
ubuntu@ip-172-31-7-118:~$ 

Results from validation using k3s version v1.29.2+k3s-364dfd8b (364dfd8)
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:~$ sudo k3s etcd-snapshot list
Name                                 Location                                                                             Size    Created
on-demand-ip-172-31-7-118-1710176321 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710176321 3072032 2024-03-11T16:58:41Z
on-demand-ip-172-31-7-118-1710176323 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710176323 3072032 2024-03-11T16:58:43Z
on-demand-ip-172-31-7-118-1710176324 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710176324 3100704 2024-03-11T16:58:44Z
on-demand-ip-172-31-7-118-1710176325 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710176325 3100704 2024-03-11T16:58:45Z
on-demand-ip-172-31-7-118-1710176326 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710176326 3100704 2024-03-11T16:58:46Z

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-1710176324 
INFO[0000] Removing local snapshot /var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710176323 
INFO[0000] Removing local snapshot /var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710176321 
INFO[0000] Reconciling ETCDSnapshotFile resources       
INFO[0000] Deleting ETCDSnapshotFile for on-demand-ip-172-31-7-118-1710176321 
INFO[0000] Deleting ETCDSnapshotFile for on-demand-ip-172-31-7-118-1710176323 
INFO[0000] Deleting ETCDSnapshotFile for on-demand-ip-172-31-7-118-1710176324 
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-1710176325 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710176325 3100704 2024-03-11T16:58:45Z
on-demand-ip-172-31-7-118-1710176326 file:///var/lib/rancher/k3s/server/db/snapshots/on-demand-ip-172-31-7-118-1710176326 3100704 2024-03-11T16:58:46Z
ubuntu@ip-172-31-7-118:~$ 

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

3 participants