nixops
nixops copied to clipboard
`nixops deploy --build-only` can corrupt the state
Workaround (Hercules CI Effects users)
Use runIf instead of action = "build";. This will perform a pure build instead of running nixops with access to the state.
To Reproduce
-
nixops deployon production branch - create feature branch, which removes some nodes, adds some
-
nixops deploy --build-onlyon feature branch -
nixops deploy --build-onlyon feature branch -
nixops deploy --build-onlyon feature branch -
nixops checklocally on production branch - nodes that aren't in the feature branch are missing from the production state!
I was lucky to notice the problem in nixops check; don't know what would've happened if the next step was nixops deploy from production.
I'm also glad that I took the precaution of using the hercules ci state backend, which preserves old state revisions remotely.
Suggested fix
- run the
deploycommand with the state db in read-only mode, if certain flags are present, such as--build-only. - make the rest of the
deploycode work with that change