Allow registering replica-first-boot scripts#448
Conversation
4e35b25 to
c91a481
Compare
We've recently extended the Coriolis API to allow specifying *when* a given user script should be executed. We currently support the following phases: * osmorphing_pre_os_mount * osmorphing_post_os_mount For convenience, we'll also add the following phase: * replica_first_boot These scripts will be executed when the replica VM boots for the first time. We'll inject them during os-morphing. As you may have noticed, the user can already do this but it's quite inconvenient to pass a script that injects another first-boot script. We'll rely on systemd on Linux and cloudbase-init on Windows. All the Linux distributions that we support have switched to Systemd about 10 years ago. Also, as per this commit [1], we rely on the fact that cloudbase-init will be available all the time and that we can use it to run first-boot scripts. Note that we did consider using scheduled tasks on Windows (as opposed to Cloudbase-init). We'd need to use an xml task definition and register it using registry keys, however it seems like we lack the privileges to create entries such as the following: ``` $HIVE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\$TaskGUID" ``` [1] cloudbase@b5f93fd
c91a481 to
74bf4f5
Compare
|
Client PR: cloudbase/python-coriolisclient#101 |
| index: int = 0, | ||
| user_provided=True, | ||
| ): | ||
| if len(script) == 0: |
There was a problem hiding this comment.
In what scenario is this true?
There was a problem hiding this comment.
The user may provide an empty script. I thought that a sanity check wouldn't hurt.
There was a problem hiding this comment.
For what is worth, I've updated the check to use if not script so that we also cover None, just in case.
There was a problem hiding this comment.
Ye, but... why would we accept empty scripts? That sounds like a mistake we should raise on the client side; the user might have made a mistake (e.g.: forgot to save the file before uploading).
There was a problem hiding this comment.
Well, I can send a separarate patch to reject empty user scripts. We'd need it on the API side to also cover requests coming from coriolis-web.
I just wanted to be careful about this since users can omit the script path when updating transfers in order to remove user scripts.
* propagate errors and avoid creating /var/lib/coriolis/firstboot-complete if any of the scripts fails * log a warning if a script isn't executable * use journal+console logging
11c4f05 to
48c009a
Compare
48c009a to
bbdf26e
Compare
We've recently extended the Coriolis API to allow specifying when a given user script should be executed. We currently support the following phases:
For convenience, we'll also add the following phase:
Sample:
These scripts will be executed when the replica VM boots for the first time. We'll inject them during os-morphing. As you may have noticed, the user can already do this but it's quite inconvenient to pass a script that injects another first-boot script.
We'll rely on systemd on Linux and cloudbase-init on Windows. All the Linux distributions that we support have switched to Systemd about 10 years ago. Also, as per this commit [1], we rely on the fact that cloudbase-init will be available all the time and that we can use it to run first-boot scripts.
Note that we did consider using scheduled tasks on Windows (as opposed to Cloudbase-init). We'd need to use an xml task definition and register it using registry keys, however it seems like we lack the privileges to create entries such as the following:
[1] b5f93fd