Skip to content

Conversation

@SimonRichardson
Copy link
Member

It's possible to corrupt the controller config file if there is an exception during writing of the file. Instead, we want to only update the controller config atomically. This involves writing the yaml to a temp file and then do a atomic file replace (POSIX). This ensures that it will always be valid if the data is valid.

It's possible to corrupt the controller config file if there is an
exception during writing of the file. Instead, we want to only update
the controller config atomically. This involves writing the yaml to
a temp file and then do a atomic file replace (POSIX). This ensures
that it will always be valid if the data is valid.
@SimonRichardson SimonRichardson changed the title feat: write controller config atomically feat: write controller.conf atomically Aug 7, 2025
temp_name = tmp_file.name

os.replace(temp_name, file_path)
os.remove(temp_name)
Copy link
Member

Choose a reason for hiding this comment

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

Replace is a rename.

Suggested change
os.remove(temp_name)

@SimonRichardson SimonRichardson changed the base branch from main to 4.0 November 20, 2025 15:22
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