-
Notifications
You must be signed in to change notification settings - Fork 150
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
fix(system-backup): handle snapshot of last backup removed #3478
Conversation
WalkthroughThe pull request introduces enhancements to error handling in the Changes
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
controller/system_backup_controller.go (1)
918-921
: LGTM! Good error handling for missing backup.The defensive error handling for missing backup is well implemented. It prevents potential panics and provides clear logging.
Consider making the warning message more consistent with the snapshot case by using "not found" instead of "not found for":
- log.Warnf("Last Backup %v not found for volume %v", lastBackup.Name, volume.Name) + log.Warnf("Last Backup %v not found when checking volume %v", lastBackup.Name, volume.Name)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
controller/system_backup_controller.go
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Build binaries
- GitHub Check: Summary
🔇 Additional comments (1)
controller/system_backup_controller.go (1)
927-930
: LGTM! Good error handling for missing snapshot.The defensive error handling for missing snapshot is well implemented. It prevents potential panics and provides clear logging.
522b96b
to
3a7835d
Compare
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.
LGTM
@mergify backport v1.8.x |
✅ Backports have been created
|
Fixing unit tests now. |
3a7835d
to
80168bf
Compare
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
controller/system_backup_controller_test.go (1)
278-288
: Consider adding validation for snapshot readiness.The test assumes the snapshot is immediately ready (
ReadyToUse: true
). Consider adding a delay or validation step to ensure this matches real-world behavior.existBackupSnap := &longhorn.Snapshot{ ObjectMeta: metav1.ObjectMeta{Name: "exists"}, Spec: longhorn.SnapshotSpec{Volume: TestVolumeName}, Status: longhorn.SnapshotStatus{ - ReadyToUse: true, + ReadyToUse: false, // Initial state CreationTime: metav1.Now().Time.String(), }, } fakeSystemRolloutSnapshot(existBackupSnap, c, informerFactories.LhInformerFactory, lhClient) + +// Simulate snapshot becoming ready after a delay +time.Sleep(100 * time.Millisecond) +existBackupSnap.Status.ReadyToUse = true +fakeSystemRolloutSnapshot(existBackupSnap, c, informerFactories.LhInformerFactory, lhClient)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
controller/system_backup_controller.go
(1 hunks)controller/system_backup_controller_test.go
(5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- controller/system_backup_controller.go
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Build binaries
- GitHub Check: Summary
🔇 Additional comments (2)
controller/system_backup_controller_test.go (2)
49-49
: LGTM! Field addition enhances test coverage.The new
existBackups
field inSystemBackupTestCase
allows testing scenarios with pre-existing backups, improving test coverage.
106-114
: Test cases effectively cover backup policy behaviors.The test cases "if-not-present when backup exists" and "always" thoroughly validate the two backup policies:
if-not-present
: Skips backup creation when a valid backup existsalways
: Creates new backup regardless of existing backupsThis ensures proper handling of both backup policies.
Also applies to: 128-136
The snapshot of the last backup of the volume might be removed. Therefore, volume backup will be not up-to-date and it needs to create a new backup. ref: longhorn/longhorn 10215 Signed-off-by: James Lu <james.lu@suse.com>
80168bf
to
e6b40bc
Compare
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.
LGTM
…3478) (#3479) The snapshot of the last backup of the volume might be removed. Therefore, volume backup will be not up-to-date and it needs to create a new backup. ref: longhorn/longhorn 10215 Signed-off-by: James Lu <james.lu@suse.com> (cherry picked from commit 36f3ed2) Co-authored-by: James Lu <james.lu@suse.com>
Which issue(s) this PR fixes:
Issue # longhorn/longhorn#10215
What this PR does / why we need it:
The snapshot of the last backup of the volume might be removed. Therefore, volume backup will not be up to date and needs to create a new backup.
Special notes for your reviewer:
Additional documentation or context
https://ci.longhorn.io/job/private/job/longhorn-tests-regression/8300/ - passed