Skip to content

Commit

Permalink
Merge pull request #1511 from hercules-ci/allow-ignored-writes-in-rea…
Browse files Browse the repository at this point in the history
…donly-mode

Allow ignored writes in readonly mode
  • Loading branch information
roberth committed Mar 11, 2022
2 parents d939c9b + bb67ee6 commit 7220cbd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion nixops/script_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,17 @@ def network_state(
lock.lock(description=description, exclusive=writable)
try:
storage.fetchToFile(statefile)
state = nixops.statefile.StateFile(statefile, writable, lock=lock)
if writable:
state = nixops.statefile.StateFile(statefile, writable, lock=lock)
else:
# Non-mutating commands use the state file as their data
# structure, therefore requiring mutation to work.
# Changes *will* be lost, as tolerating racy writes will be
# even harder to debug than consistently discarding changes.
# TODO: Change the NixOps architecture to separate reading
# and writing cleanly, so we can request a read-only
# statefile here and 'guarantee' no loss of state changes.
state = nixops.statefile.StateFile(statefile, True, lock=lock)
try:
storage.onOpen(state)

Expand Down

0 comments on commit 7220cbd

Please sign in to comment.