-
Notifications
You must be signed in to change notification settings - Fork 881
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
WIP: early hostkey generation #5728
base: main
Are you sure you want to change the base?
Conversation
try: | ||
# Using subprocess.Popen instead of subp.subp to run | ||
# multiple ssh-keygen commands in parallel. | ||
p = subprocess.Popen( |
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.
Why generate these in parallel? RSA keygen is time-consuming, but generating the other keys is not, so I'm not convinced that the extra complexity outweighs the benefit.
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 really seem any more complex to me, but serial is fine too.
LOG.warning("Failed to retrieve early generated host keys") | ||
return [] | ||
|
||
key_dir = get_early_host_key_dir(rundir) |
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.
nit: why not just use early_key_fifo_path
here?
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.
Whoops, I forgot to update the name (shouldn't end with _dir
), but the reason for the function is needing to pass the rundir and to make sure the same path is used in multiple places.
early_keys: List[ssh_util.KeyPair] = ( | ||
ssh_util.wait_for_early_generated_keys(rundir) | ||
) | ||
if not early_keys or cfg.get("seed_random"): |
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 is a problem with this that needs to be addressed.
Cloud-init's Azure and Openstack code has automatic entropy seeding, which bypasses cloud-config. This change highlights the fact that cloud-init implements datasource-specific code in configuration modules and in datasource modules. Simply checking the merged configuration is insufficient, because for some reason when this was implemented it was decided that this shouldn't just be transformed into vendor-data to be merged (overwritten by user-data).
I strongly suspect that automatic entropy seeding exists on these platforms for legacy reasons only[1][2], and is no longer needed. However, until this tech debt has been resolved, cloud-init should still respect the entropy provided by these platforms.
[1] torvalds/linux@f2580a9
[2] https://bugs.launchpad.net/nova/+bug/1789868
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.
Aside: I realized this should be random_seed
rather than seed_random
. Having the key opposite order from the module name is confusing.
To your point, I was aware of datasources doing their own thing here. I saw random_seed
in the datasources and thought it was using the same key. I didn't realize it's storing the seed under a separate metadata key. This if
statement can just be updated to also check if random_seed
is in cloud.datasource.metadata
, correct?
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 if statement can just be updated to also check if random_seed is in cloud.datasource.metadata, correct?
Yes, I believe so
early_key_fifo_path = _get_early_key_fifo_path(rundir) | ||
if not early_key_fifo_path.exists(): | ||
return [] | ||
if early_key_fifo_path.read_bytes() != b"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.
If not complete, this will block. It would be good to know if this happens, such as by using performance.Timed
or performance.timed()
Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close. If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging TheRealFalcon, and he will ensure that someone takes a look soon. (If the pull request is closed and you would like to continue working on it, please do tag TheRealFalcon to reopen it.) |
Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close. If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging TheRealFalcon, and he will ensure that someone takes a look soon. (If the pull request is closed and you would like to continue working on it, please do tag TheRealFalcon to reopen it.) |
Proposed Commit Message
Additional Context
I'm looking for feedback on the approach. Code currently works for the happy path. Tests, docs, and some refactoring still needed.
Canonical internal only: https://docs.google.com/document/d/1-Cfn-UIpN26vef_LeE0CtQg5D15r3ZRo0fERJ7R0XFg/edit
Test Steps
Merge type