mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-10-22 06:18:16 +02:00
Support Tart Guest Agent transport for VM startup scripts (#490)
* Support Tart Guest Agent transport for VM startup scripts * TestTartGuestAgentStartupScript: make ScriptContent more readable * Align Tart Guest Agent's startup script execution with SSH * Use mvdan.cc/sh/v3/syntax to validate "export" shell commands * Use Bash instead of Zsh on Linux * Invert logic when validating vm.StartupScript.Transport for simplicity * Document startup_script's transport field in OpenAPI specification * Prevent unbounded buffering of startup script output * grpc.WaitForReady(true) → retry.DoWithData()
This commit is contained in:
@@ -38,6 +38,7 @@ var labels map[string]string
|
||||
var randomSerial bool
|
||||
var restartPolicy string
|
||||
var startupScript string
|
||||
var startupScriptTransport string
|
||||
var hostDirsRaw []string
|
||||
var imagePullPolicy string
|
||||
|
||||
@@ -93,6 +94,9 @@ func newCreateVMCommand() *cobra.Command {
|
||||
command.Flags().StringVar(&startupScript, "startup-script", "",
|
||||
"startup script (e.g. --startup-script=\"sync\") or a path to a script file prefixed with \"@\" "+
|
||||
"(e.g. \"--startup-script=@script.sh\")")
|
||||
command.Flags().StringVar(&startupScriptTransport, "startup-script-transport", string(v1.VMScriptTransportSSH),
|
||||
fmt.Sprintf("transport for the startup script: %q or %q (Tart only)",
|
||||
v1.VMScriptTransportSSH, v1.VMScriptTransportTartGuestAgent))
|
||||
command.Flags().StringSliceVar(&hostDirsRaw, "host-dirs", []string{},
|
||||
"directories on the Orchard Worker host to mount to a VM, can be specified multiple times "+
|
||||
"and/or be comma-separated (see \"tart run\"'s --dir argument for syntax)")
|
||||
@@ -169,10 +173,6 @@ func runCreateVM(cmd *cobra.Command, args []string) error {
|
||||
HostDirs: hostDirs,
|
||||
}
|
||||
|
||||
if err := vm.Validate(); err != nil {
|
||||
return fmt.Errorf("%w: %v", ErrVMFailed, err)
|
||||
}
|
||||
|
||||
// Convert resources
|
||||
vm.Resources, err = v1.NewResourcesFromStringToString(resources)
|
||||
if err != nil {
|
||||
@@ -202,13 +202,19 @@ func runCreateVM(cmd *cobra.Command, args []string) error {
|
||||
|
||||
vm.StartupScript = &v1.VMScript{
|
||||
ScriptContent: string(startupScriptBytes),
|
||||
Transport: v1.VMScriptTransport(startupScriptTransport),
|
||||
}
|
||||
} else if startupScript != "" {
|
||||
vm.StartupScript = &v1.VMScript{
|
||||
ScriptContent: startupScript,
|
||||
Transport: v1.VMScriptTransport(startupScriptTransport),
|
||||
}
|
||||
}
|
||||
|
||||
if err := vm.Validate(); err != nil {
|
||||
return fmt.Errorf("%w: %v", ErrVMFailed, err)
|
||||
}
|
||||
|
||||
client, err := client.New()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user