Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locking usability improvements #1470

Merged
merged 11 commits into from
Nov 18, 2021
Merged

Conversation

roberth
Copy link
Member

@roberth roberth commented Aug 24, 2021

With remote state and locking, concurrent use of nixops commands has become impossible. This is bad when, for example, you want to nixops ssh while a nixops deploy is running.

This PR solves a couple of locking related problems by

  • creating a distinction between read-only and read-write NixOps commands
    • allowing read-only commands to run concurrently if supported by the lock backend
    • prevent corrupting state by uploading only when in read-write mode
  • making nixops ssh unlock before the session starts, so read-write operations can resume while presumably-interactive sessions exist
  • adding nixops ssh --now which uses whatever state it can get but does not lock at all

More details are in the commit messages.

This also adds a description parameter to provide human-friendly
context to plugins.
This only expand the coverage of the finally/unlock to the state
initialization. If that initialization fails, we have no reason
to hold on to the lock.
This will help us detect programming errors where we requested
read-only locking but still attempt to write.

Before locking, such a distinction was unnecessary, so it's
important that we enforce this, to promote out-of-sync state bugs
to proper errors.
Because we're now disallowing change when we don't request locks
for writing, we can avoid state upload churn as well.
Even a non-exclusive lock can needlessly block exclusive operations
like deploy, particularly when it's an idle interactive session.
Such upgrades are still necessary and are permissible as long as
the db isn't uploaded (taken care of in earlier commit) and
the upgrade does not touch anything outside the db, which is
currently the case, and is documented inline.
It only matters for construction. After construction, we can erase
the type by upcasting, keeping the types simple and improving mypy
precision.
> 'store_true' and 'store_false' - These are special cases of
> 'store_const' used for storing the values True and False
> respectively. In addition, they create default values of
> False and True respectively.

https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.add_argument
@roberth

This comment has been minimized.

@roberth roberth mentioned this pull request Aug 26, 2021
16 tasks
@roberth
Copy link
Member Author

roberth commented Aug 28, 2021

cc @adisbladis, would you mind reviewing this?

@roberth
Copy link
Member Author

roberth commented Nov 18, 2021

This is sorely needed and has been up for review for nearly 3 months.

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