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:
edi-oai
2026-09-09 08:04:25 +01:00
committed by GitHub
parent 01bf2d72a9
commit 9ac6ca6326
9 changed files with 407 additions and 19 deletions
+10 -4
View File
@@ -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