Skip to content

Conversation

@Tejeev
Copy link
Contributor

@Tejeev Tejeev commented Jan 31, 2025

Can't count how many times we've seen removing backup etcd dbs put a customer in a bad spot.

@Tejeev Tejeev requested a review from a team as a code owner January 31, 2025 19:35
```

4. Remove the rke2 db directory on the other server nodes as follows:
4. Move the rke2 db directory on the other server nodes as follows (you want to keep a copy to avoid ending up with only an old or corrupt backup to chose for):
Copy link
Member

Choose a reason for hiding this comment

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

Having the old DB dir around on the secondary servers doesn't really help with anything. If you run into problems, restoring a snapshot is a better resolution than moving an old db dir back into place.

Choose a reason for hiding this comment

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

The issue is that we currently run rm -rf /var/lib/rancher/rke2/server/db/, which deletes both the etcd data and the snapshots directory. This means we erase the live data along with its backups.

We've encountered cases where customers, not paying close attention, have accidentally executed this command on all three master/etcd nodes, leading to complete data loss.

This change ensures that snapshots are not deleted until the cluster has been fully restored, allowing customers to perform the cleanup on their own afterward.

Copy link
Member

@brandond brandond Feb 19, 2025

Choose a reason for hiding this comment

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

Hmm, then how about we leave this as-is and just delete the etcd directory?

Choose a reason for hiding this comment

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

@brandond @Tejeev

I agree with the proposed change to use rm -rf /var/lib/rancher/rke2/server/db/etcd instead of the broader directory removal.

The more targeted approach addresses the core issue while providing several important benefits:

  • It removes only the etcd database files that need to be replaced during restoration
  • Preserves the snapshots directory, preventing potential complete data loss scenarios
  • Eliminates the risk we've seen with customers accidentally executing the broader command across all master/etcd nodes simultaneously
  • Requires no additional cleanup steps later in the process

@Tejeev Tejeev requested a review from brandond February 19, 2025 20:34
Comment on lines +57 to +61
mv /var/lib/rancher/rke2/server/db /var/lib/rancher/rke2/server/backups
```
Clean them out after this operation:
```
rm -rf /var/lib/rancher/rke2/server/backups
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
mv /var/lib/rancher/rke2/server/db /var/lib/rancher/rke2/server/backups
```
Clean them out after this operation:
```
rm -rf /var/lib/rancher/rke2/server/backups
rm -rf /var/lib/rancher/rke2/server/db/etcd

This should remove the etcd files but leave the snapshots, without requiring any additional cleanup later.

Copy link
Contributor Author

@Tejeev Tejeev Feb 22, 2025

Choose a reason for hiding this comment

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

I think this is good, unless I'm missing anything; @mattmattox?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants