Skip to content

fix(keystone): stage fernet keys in .staging/ subdir to avoid key-load race (#1859) - #1918

Open
bjoernt wants to merge 1 commit into
rackerlabs:release-2026.2from
bjoernt:fix-keystone-perm-sync
Open

bjoernt wants to merge 1 commit into
rackerlabs:release-2026.2from
bjoernt:fix-keystone-perm-sync

Conversation

@bjoernt

@bjoernt bjoernt commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Keystone's fernet_utils._get_key_files calls os.listdir + os.path.isfile on the key repository and opens every regular file before checking if the filename is an integer. The sidecar was writing temp files (.tmp.N) directly in the key repo, so Keystone could open them mid-copy with root:root ownership and fail with PermissionError, returning 500 on POST /v3/auth/tokens.

The sync_dir function in both the init container and the sidecar now stages keys in a .staging/ subdirectory inside the same emptyDir. os.path.isfile returns False for a directory, so Keystone skips it entirely. The mv from .staging/ into the key dir is an atomic rename on the same filesystem.

(cherry picked from commit 3746fce)

…d race (rackerlabs#1859)

Keystone's fernet_utils._get_key_files calls os.listdir + os.path.isfile
on the key repository and opens every regular file before checking if the
filename is an integer. The sidecar was writing temp files (.tmp.N)
directly in the key repo, so Keystone could open them mid-copy with
root:root ownership and fail with PermissionError, returning 500 on
POST /v3/auth/tokens.

The sync_dir function in both the init container and the sidecar now
stages keys in a .staging/ subdirectory inside the same emptyDir.
os.path.isfile returns False for a directory, so Keystone skips it
entirely. The mv from .staging/ into the key dir is an atomic rename
on the same filesystem.

(cherry picked from commit 3746fce)

This branch has not been deployed

No deployments
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.

2 participants