Extend user scripts API, allowing the phase to be specified#435
Open
petrutlucian94 wants to merge 3 commits into
Open
Extend user scripts API, allowing the phase to be specified#435petrutlucian94 wants to merge 3 commits into
petrutlucian94 wants to merge 3 commits into
Conversation
We used to retry all SSH commands that failed, even those that don't actually exist. We're still retrying commands that are expected to fail, wasting time unnecessarily during os morphing: coriolis.exception.CoriolisException: Command "readlink -en /dev/sda2" failed on host '172.17.0.3:22' with exit code: 1 2026-05-18 12:14:11.783 1667765 WARNING coriolis.osmorphing.osmount.base [-] Target not found for symlink: /dev/sda2. Original link path will be returned What makes things even worse is that the caller functions are often retried as well, having the "retry_on_error" decorator without any parameters. Commands that are expected to fail end up being retried 25 times. We'll update "exec_ssh_cmd" so that by default it will perform retries only in case of SSH errors. For convenience, we're exposing the retry helper arguments (number of retries, retry interval and terminal exceptions). In addition to that, we'll introduce a new argument for the list of retried exceptions. If the caller needs the actual commands to be retried as well, "SSHCommandFailed" may be added to the list of retried exceptions.
Member
Author
|
Rebased on top of #433, we should merge that one first. |
d854fd0 to
9fde476
Compare
When deploying replicas, Coriolis users can specify scripts that will be executed
during os-morphing, right after the OS partition is mounted on the minion instance.
In some situations, this is too late since user scripts may be needed in order
to be able to mount the OS disk, for example if it’s encrypted.
In other situations it’s too early. Some scripts may need to be executed on
the replica instance. This may require provider assistance.
To accommodate these use cases, we’ll extend the deployment API, allowing the
user to specify when a given script should be executed. Each script may specify
one of the following execution phases:
* osmorphing-pre-os-mount
* osmorphing-post-os-mount (default)
* replica-initial-boot (TBD)
We'll continue to support the basic script format as well. See the API samples
for a few examples.
Note that we can't use the OS morphing tools to run pre-os-mount scripts.
A few approaches have been considered:
* initialize the OS morphing tools against the minion root partition
* hacky
* unnecessarily complicated and brittle
* use the base Linux/Windows OS morphing classes
* can't be instantiated since not all abstract methods are implemented by
the base classes
* extend the OS mount tools to allow running pre-os-mount user scripts
* easiest and most natural approach, imlemented by this patch
9fde476 to
06f8ba0
Compare
`powershell.exe -File` doesn't propagate the exit code of the specified script. As an alternative, we'll use '& $script; exit $LASTEXITCODE', moving the execution policy and non-interactive parameters to the "exec_ps_command" method.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When deploying replicas, Coriolis users can specify scripts that will be executed during os-morphing, right after the OS partition is mounted on the minion instance.
In some situations, this is too late since user scripts may be needed in order to be able to mount the OS disk, for example if it’s encrypted.
In other situations it’s too early. Some scripts may need to be executed on the replica instance. This may require provider assistance.
To accommodate these use cases, we’ll extend the deployment API, allowing the user to specify when a given script should be executed. Each script may specify one of the following execution phases:
We'll continue to support the basic script format as well. See the API samples for a few examples.
Note that we can't use the OS morphing tools to run pre-os-mount scripts. A few approaches have been considered:
the base classes
The PR also fixes Windows user script execution, ensuring that errors get propagated.