fix: restore --rbac should not error when backup has no RBAC access dir#1439
Merged
Slach merged 2 commits intoJun 25, 2026
Merged
Conversation
… restore --rbac skips missing access
Collaborator
|
thanks for contribution |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes
restore --rbaca graceful no-op when a backup contains no RBAC objects, matching the existing behavior ofdownload --rbac. Previously, restoring such a backup failed withrestoreRBAC: restoreRBACResolveAllConflicts: walk backup access path: ... lstat .../access: no such file or directory.Why this matters
fix #1432,
create_remote --rbacon a cluster with no RBAC objects succeeds silently (done createBackupRBAC, size=0B), anddownload --rbacof that backup tolerates the missingaccessdir. Butrestore --rbacof the same backup errors out. This is an inconsistent, surprising failure for a perfectly valid backup.The root cause is error-identity stripping:
restoreRBACResolveAllConflictsrunsfilepath.Walkon<DefaultDataPath>/backup/<name>/access. When that dir is absent, the walk callback wraps the*os.PathErrorviaerrors.Wrap(...), so the function's tail guardos.IsNotExist(walkErr)no longer matches and the error propagates. The same pattern affectsrestoreBackupRelatedDir(andrestoreRBACReplicated), whoseos.StatENOENT was also wrapped before reaching the caller'sos.IsNotExist(err)guards inrestoreRBAC.Changes
pkg/backup/restore.gorestoreRBACResolveAllConflicts: add a narrow early return whenos.Stat(backupAccessPath)reports the dir does not exist (log a debug line, return nil). Only the not-exist case is swallowed; the existingos.IsNotExist(walkErr)tail guard is kept as defense-in-depth.restoreBackupRelatedDirandrestoreRBACReplicated: when the source dir does not exist, return the unwrappedos.Staterror so the callers' existingos.IsNotExist(err)guards inrestoreRBACcan detect it and skip RBAC restore. Non-not-exist stat errors are still wrapped as before.Testing
Added unit tests in
pkg/backup/restore_test.go(no running ClickHouse required):TestRestoreRBACResolveAllConflictsMissingAccessDir: with&Backuper{DefaultDataPath: t.TempDir()}and noaccessdir,restoreRBACResolveAllConflictsreturns nil.TestRestoreBackupRelatedDirMissingDirIsNotExist: a missing source dir yields an error for whichos.IsNotExistis true, ensuringrestoreRBAC's graceful-skip guards keep working.Fixes #1432