Problem
The backup command introduced by #2344 names backup files using the Kubernetes context, backup type, and int(time.time()). Because the timestamp has one-second resolution, concurrent invocations for the same context can choose the same destination filename.
The successful write path uses os.replace(tmp_path, dest), which replaces an existing destination. A later successful backup can therefore silently overwrite an earlier valid backup, despite the code comment stating that an existing same-name backup is never clobbered.
Expected behavior
A successful backup must not overwrite an existing backup file. The command should either generate collision-resistant filenames or fail safely when the destination has already been reserved or exists.
Acceptance criteria
- Existing completed backups are never silently overwritten.
- Concurrent invocations cannot claim the same output filename.
- Tests cover a successful destination-name collision.
Context
Found while reviewing #2344.
Problem
The backup command introduced by #2344 names backup files using the Kubernetes context, backup type, and
int(time.time()). Because the timestamp has one-second resolution, concurrent invocations for the same context can choose the same destination filename.The successful write path uses
os.replace(tmp_path, dest), which replaces an existing destination. A later successful backup can therefore silently overwrite an earlier valid backup, despite the code comment stating that an existing same-name backup is never clobbered.Expected behavior
A successful backup must not overwrite an existing backup file. The command should either generate collision-resistant filenames or fail safely when the destination has already been reserved or exists.
Acceptance criteria
Context
Found while reviewing #2344.