-
-
Notifications
You must be signed in to change notification settings - Fork 363
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
Example NixOps State Backends #1264
Example NixOps State Backends #1264
Conversation
cb46a0a
to
d105b44
Compare
# Making it part of the type definition allows adding new | ||
# arguments later. | ||
def fetchToFile(self, path: str, **kwargs) -> None: | ||
os.symlink(os.path.abspath(self.state_location()), path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This at one point did not abspath, which was causing problems with legacy paths to state files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me like it would be a bit safer to make an actual copy rather than a symlink.
That way we know that if something goes wrong in the middle of writing the state file to disk, the "proper" statefile won't be corrupted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we were to copy, we would need to implement our own implementation of locking on top. The legacy backend already supports its own locking. My thinking is it would be better to find a way to "escape" the legacy backend, or implement a "backup" feature in the Legacy backend, than implement copying. What do you think?
d105b44
to
63b64d0
Compare
nixops/storage/s3.py
Outdated
ConditionExpression="attribute_not_exists(LockID)", | ||
) | ||
|
||
def unlock(self, path: str) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be cool to use contextmanager for locking as well to ensure a bit of safety
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way it can be moved into Storage abstraction and then backend can implement it or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we should completely conflate looking & storage.
S3, Backblaze B2 & friends don't have any locking mechanisms themselves, so you may want to utilise a dynamodb table for locking.
It's fine if a storage backend implements a default locking mechanism though, as long as it can be overriden by the user.
63b64d0
to
2834cbd
Compare
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
Right now if you don't define
|
If you define
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
A PR can be (and converted to) to a draft, so you wouldn't need a "do not merge" warning. |
todo:
this PR removes the idea of "global " networks and the "-d ..." argument, because of the dependence on |
6d13093
to
9f3d08e
Compare
9f3d08e
to
8becbe2
Compare
8becbe2
to
35a0a89
Compare
35a0a89
to
7157e91
Compare
`nixops.nix` is a much more obvious name and really indicates what tooling is supposed to be used to build/deploy by just eyeballing a directory layout. We also don't want to occupy generic words possibly already used in some deployments.
…ers such as is_flake
This will soon contain a reference to readthedocs.
e9bb679
to
3f7d77a
Compare
We're never going to move forward with this without getting this change out to more people for review. Therefore I'm merging this, with the caveat that it might be somewhat changed before a final release. |
1. Open %s | ||
2. Add: | ||
network.storage.legacy = { | ||
databasefile = "~/.nixops/deployments.nixops" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a reference to databasefile
here that doesn't seem to exist in the code
Looks like the relocation part of this one still needs doing if I'm not mistaken? I couldn't find any reference to |
Whew, I finally got around to playing with this. Good call merging this though! My observations so far: The interface is quite coarse grained, dealing with the whole db only and having no knowledge of which deployment is used. This coarseness means that state file history becomes noisy and locking more problematic as the number of deployments increases. Users can choose distinct backend configurations to compensate for this, but that's effectively duplicating the State is always written, even for read-only operations like Sqlite isn't really an interchange format. If something goes wrong, it's hard to read. I don't know about its format/version strategy (maybe it's good though?) and it's not easy to diff. Perhaps the backends could be based on Which brings us to: |
Is the memory backend functional at all? We tried to use both legacy backend and memory backend in nix-community/infra#123 but they both seem not to work. nixops stable is also broken, which means there is no functional nixops left. |
Yeah, the legacy backend was broken by this, since it now ignores the With that in place, I think we could essentially drop deployments altogether without losing granularity: instead of running |
Store in S3:
Store in Memory:
Legacy, exactly as master works now: