-
-
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
Hetzner partitioning script #948
Conversation
e5f90bc
to
85f720f
Compare
setattr(self, var, xml_expr_to_python(node)) | ||
|
||
self.main_ipv4 = config["hetzner"]["mainIPv4"] | ||
assert type(self.main_ipv4) is str |
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.
Use descriptors instead? Possibly http://traitlets.readthedocs.io.
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.
These are nice ideas, but here I'm simply unifying the style to use the same as the other backends (such as the EC2 one,
Line 39 in f10999a
self.access_key_id = config["ec2"]["accessKeyId"] |
If we want to push for a change in style in general, we should probably tackle that separately for all backends and in coordination with whoever takes care of the those.
Regarding traitlets, I'm all for more type checking, but as far as I can tell it's an extra dependency so I can't tell whether or not we want to add it to 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.
Apart from that, those types should already be checked by the NixOS module system, so I think most of those asserts aren't really needed.
TODO for myself: Fix
|
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'd move most of the type and conflict checking to the module (for example via the assertions
option) instead of within the Python part, as we can provide better error messages than a traceback from Python if we got an assertion.
Apart from that, it might be a good idea to fall back using nixos-generate-config
(see _detect_hardware
) with filesystem detection, so that providing fsInfo
is optional.
nix/hetzner.nix
Outdated
description = '' | ||
Specify layout of partitions and file systems using Anacondas Kickstart | ||
format. For possible options and commands, please have a look at: | ||
|
||
<link xlink:href="http://fedoraproject.org/wiki/Anaconda/Kickstart"/> | ||
|
||
If the Kickstart is not sufficient for your partitioning needs, |
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.
Probably remove the the
: If Kickstart is not sufficient...
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.
Done
nix/hetzner.nix
Outdated
|
||
Where possible, use the simpler "partitions" option instead of this option. | ||
|
||
The "partitions" and "partitioningScript" options are mutually exclusive. |
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.
<option>partitions</option>
and <option>partitioningScript</option>
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.
Done
nix/hetzner.nix
Outdated
filesystemInfo = mkOption { | ||
type = types.nullOr types.attrs; | ||
default = null; | ||
example = { |
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.
Maybe use literalExample
here, otherwise this ends up like this:
{ boot = { loader = { grub = { devices = [ "/dev/sda" "/dev/sdb" "/dev/sdc" "/dev/sdd" ] ; } ; } ; } ; fileSystems = { / = { fsType = "ext4"; label = "root"; options = [ "journal_path=/dev/disk/by-label/rootjournal" "data=journal" "errors=remount-ro" ] ; } ; } ; swapDevices = [ ] ; }
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.
Done
nix/hetzner.nix
Outdated
description = '' | ||
Override the filesystem info obtained from the machine after partitioning. | ||
|
||
This option is required when "partitioningScript" is used, but can also |
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.
Again, <option/>
.
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.
Done
setattr(self, var, xml_expr_to_python(node)) | ||
|
||
self.main_ipv4 = config["hetzner"]["mainIPv4"] | ||
assert type(self.main_ipv4) is str |
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.
Apart from that, those types should already be checked by the NixOS module system, so I think most of those asserts aren't really needed.
""" | ||
Bootstrap everything needed in order to get Nix and the partitioner | ||
usable in the rescue system. The keyword arguments are only for | ||
partitioning, see reboot_rescue() for description, if not given we will | ||
only mount based on information provided in self.partitions. | ||
|
||
Exactly one of `partitions` and `partitioning_script` must be given as | ||
non-None value. |
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'd check this via the NixOS module system as well.
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.
Yes, but not a reason not to merge, is it?
161d512
to
a794a4d
Compare
Addressed a couple comments, some other ones still outstanding |
…OS#856. The old approach, waiting for the machine to not having an open port, and then waiting for it to be open again, was insufficient, because of the race condition that the machine rebooted so quickly that the port was immediately open again without nixops noticing that it went down. I experienced this on a Hetzner cloud server. The new approach checks the `last reboot` on the remote side to change, which is not racy.
From @aszlig: > the Hetzner backend was written back then where there was > no config argument, so it's a good idea to switch to it
This allows for custom partitioning that Anaconda Kickstart / blivet cannot do.
a794a4d
to
3ca62f2
Compare
self.reboot(hard=hard, reset=False) | ||
|
||
self.log_start("waiting for reboot to complete...") | ||
while True: |
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 doesn't look robust, because perhaps Hetzner did something wrong and it doesn't actually ever come up. I see lots of people who write while True:
loops, but in reality, if it hasn't started after 3 minutes, you will start to wonder what's going on and you would have to manual work.
As such, this level of automation is an improvement over having nothing, but there is room for improvement.
break | ||
self.log_continue(".") | ||
time.sleep(1) | ||
self.log_end("done.") |
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.
In a log it would be more useful see a line that says what actually was done
.
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.
Hello! Thank you for this PR. In the past several months, some major changes have taken place in
This is all accumulating in to what I hope will be a NixOps 2.0 My hope is that by adding types and more thorough automated testing, However, because of the major changes, it has become likely that this If you would like to see this merge, please bring it up to date with Thank you again for the work you've done here, I am sorry to be Graham |
This PR is based on top of PR #857 and thus includes its first commit; that PR should be merged before this one.
This PR modernises how the hetzner backend gets its inputs (using
config
instead of custom XML parsing), and then adds 3 options via which you can do custom partitioning. This is needed e.g. when you want to make an ext4 with external journal, using a combination of SSDs and HDDs that are common at Hetzner.CC @aszlig @cleverca22