Skip to content

Write an app's list settings right when its items aren't indented, and never write a node configuration that doesn't read back - #93

Closed
eigmax wants to merge 1 commit into
mainfrom
fix/set-fields-block-lists
Closed

eigmax wants to merge 1 commit into
mainfrom
fix/set-fields-block-lists

Conversation

@eigmax

@eigmax eigmax commented Nov 14, 2026

Copy link
Copy Markdown
Member

Problem

A settings update (PUT /apps/{app}/settings, fleetctl app update) has the node rewrite each changed value in place in apps.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 like

- name: sam3
  volumes:
  - /some/path
  command:
  - python

the new line reads as a stray key. On another node, an update of an app's workdir, volumes and command failed with while scanning a simple key ... could not find expected ':'. It failed only because re-reading the text for the next field raised; an update of just volumes or just command would have written the broken file and left the node unable to read its configuration.

Fix

  • A new value for a block list or map goes on its key's own line, after the colon. A comment on that line is kept.
  • set_fields replaces the file only when the new text parses and the entry reads back with the values asked for. Otherwise the update fails with a ValueError, 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 updates volumes, command and env alone 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.

…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.
@eigmax

eigmax commented Nov 14, 2026

Copy link
Copy Markdown
Member Author

Folded into #92 (same commit, cherry-picked).

@eigmax eigmax closed this Nov 14, 2026
@eigmax
eigmax deleted the fix/set-fields-block-lists branch November 14, 2026 12:58
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.

1 participant