Repository navigation
Conversation
…d never write a node configuration that doesn't read back A settings update writes each new value in flow style where the old one was. For a block list or map, the old value starts at its first item on the next line, so the new list went there, at that line's indentation. With a list's "- " items level with the entry's keys (valid YAML, and how hand-written entries often look), the new line read as a stray key: the update of an app's volumes, command and workdir failed, and an update of just its volumes or command would have written a broken apps.yaml. A new block list or map value now goes on its key's own line, after the colon, keeping a comment there. And the file is replaced only when the new text parses and holds the values asked for; otherwise the update fails and the file stays as it was.
Member
Author
|
Folded into #92 (same commit, cherry-picked). |
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.
Problem
A settings update (
PUT /apps/{app}/settings,fleetctl app update) has the node rewrite each changed value in place inapps.yaml, in flow style. For a value that is a block list or map, the old value starts at its first item on the next line, so the new[...]was written there, at that line's indentation.When a list's
-items sit level with the entry's keys, as in hand-written entries likethe new line reads as a stray key. On another node, an update of an app's
workdir,volumesandcommandfailed withwhile scanning a simple key ... could not find expected ':'. It failed only because re-reading the text for the next field raised; an update of justvolumesor justcommandwould have written the broken file and left the node unable to read its configuration.Fix
set_fieldsreplaces the file only when the new text parses and the entry reads back with the values asked for. Otherwise the update fails with aValueError, and the file stays as it was.Tests
test_settings_update_replaces_block_lists_and_maps_however_indented, for lists both level with the keys and indented: it updatesvolumes,commandandenvalone and together, and checks that the other entry and the comment are kept.test_settings_update_never_writes_a_file_that_does_not_read_back: it makes the writer produce broken text, and the file and its directory are unchanged.The unindented case and the read-back test both fail without the fix.
python -m pytest -q bridge/tests deploy/tests: 100 passed.