Skip to content

Write a created object configuration under a DEFAULT header - #1104

Merged
cvaroqui merged 1 commit into
opensvc:mainfrom
cvaroqui:ini-default-section
Sep 2, 2026
Merged

Write a created object configuration under a DEFAULT header#1104
cvaroqui merged 1 commit into
opensvc:mainfrom
cvaroqui:ini-default-section

Conversation

@cvaroqui

@cvaroqui cvaroqui commented Sep 2, 2026

Copy link
Copy Markdown
Member

"om test1 create --kw fs#1.type=flag --kw nodes=*" wrote the nodes keyword, and the id that goes with it, past the "[fs#1]" line. The object read back had no nodes and no id, and an fs#1 resource that had both. The same create with the keywords in the other order was correct, so the object a user got depended on the order they typed.

The default section of a parsed document has no header node: the keys before the first section header are its keys, and a document that had no header is written back without one it never had. A key added to it had no node to be inserted after, and insertNodeAfterSection appended it to the end of the document, which is inside the last section. It appended correctly while the default section was still the only one, which is why the first order worked.

A key of a headerless default section now heads the document, where it belongs. Configuration files written before this fix have no DEFAULT header either, so this is what "om set --kw nodes=..." on one of them needed too.

The create codepaths, local and api-side, then materialize the header, and the sections a document is built with are separated by a blank line: a new object configuration looks like the v2 one it replaces, whatever the keyword order.

Only an encoded section header is separated, and only a document with no default section header materializes one, so a configuration nobody reformatted is still written back byte for byte: "om config edit" with no edit leaves the file untouched, and a configuration imported with "--config" keeps the layout it was written in.

"om test1 create --kw fs#1.type=flag --kw nodes=*" wrote the nodes
keyword, and the id that goes with it, past the "[fs#1]" line. The
object read back had no nodes and no id, and an fs#1 resource that had
both. The same create with the keywords in the other order was correct,
so the object a user got depended on the order they typed.

The default section of a parsed document has no header node: the keys
before the first section header are its keys, and a document that had no
header is written back without one it never had. A key added to it had
no node to be inserted after, and insertNodeAfterSection appended it to
the end of the document, which is inside the last section. It appended
correctly while the default section was still the only one, which is why
the first order worked.

A key of a headerless default section now heads the document, where it
belongs. Configuration files written before this fix have no DEFAULT
header either, so this is what "om <obj> set --kw nodes=..." on one of
them needed too.

The create codepaths, local and api-side, then materialize the header,
and the sections a document is built with are separated by a blank line:
a new object configuration looks like the v2 one it replaces, whatever
the keyword order.

Only an encoded section header is separated, and only a document with no
default section header materializes one, so a configuration nobody
reformatted is still written back byte for byte: "om config edit" with
no edit leaves the file untouched, and a configuration imported with
"--config" keeps the layout it was written in.
@cvaroqui
cvaroqui merged commit 0a43471 into opensvc:main Sep 2, 2026
1 check passed
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