diff --git a/params/params.go b/params/params.go index 96d873b9..ee43e4b9 100644 --- a/params/params.go +++ b/params/params.go @@ -163,6 +163,7 @@ type BootstrapInstance struct { CACertBundle []byte `json:"ca-cert-bundle"` OSArch OSArch `json:"arch"` + OSType OSType `json:"os_type"` Flavor string `json:"flavor"` Image string `json:"image"` Labels []string `json:"labels"` diff --git a/runner/pool/pool.go b/runner/pool/pool.go index 3cc90ff0..5b336185 100644 --- a/runner/pool/pool.go +++ b/runner/pool/pool.go @@ -610,6 +610,7 @@ func (r *basePoolManager) addInstanceToProvider(instance params.Instance) error CallbackURL: instance.CallbackURL, InstanceToken: jwtToken, OSArch: pool.OSArch, + OSType: pool.OSType, Flavor: pool.Flavor, Image: pool.Image, ExtraSpecs: pool.ExtraSpecs, diff --git a/runner/providers/external/external.go b/runner/providers/external/external.go index dcf3c8b3..f5ee282f 100644 --- a/runner/providers/external/external.go +++ b/runner/providers/external/external.go @@ -43,7 +43,7 @@ type external struct { execPath string } -func (e *external) validateCreateResult(inst params.Instance, bootstrapParams params.BootstrapInstance) error { +func (e *external) validateCreateResult(inst params.Instance) error { if inst.ProviderID == "" { return garmErrors.NewProviderError("missing provider ID after create call") } @@ -87,7 +87,7 @@ func (e *external) CreateInstance(ctx context.Context, bootstrapParams params.Bo return params.Instance{}, garmErrors.NewProviderError("failed to decode response from binary: %s", err) } - if err := e.validateCreateResult(param, bootstrapParams); err != nil { + if err := e.validateCreateResult(param); err != nil { return params.Instance{}, garmErrors.NewProviderError("failed to validate result: %s", err) } diff --git a/runner/providers/lxd/lxd.go b/runner/providers/lxd/lxd.go index fe9ca4c3..2ee1dbab 100644 --- a/runner/providers/lxd/lxd.go +++ b/runner/providers/lxd/lxd.go @@ -17,6 +17,7 @@ package lxd import ( "context" "fmt" + "log" "sync" "github.com/cloudbase/garm/config" @@ -159,7 +160,7 @@ func (l *LXD) getProfiles(flavor string) ([]string, error) { return ret, nil } -func (l *LXD) getTools(image *api.Image, tools []*github.RunnerApplicationDownload) (github.RunnerApplicationDownload, error) { +func (l *LXD) getTools(image *api.Image, tools []*github.RunnerApplicationDownload, assumedOSType params.OSType) (github.RunnerApplicationDownload, error) { if image == nil { return github.RunnerApplicationDownload{}, fmt.Errorf("nil image received") } @@ -170,7 +171,8 @@ func (l *LXD) getTools(image *api.Image, tools []*github.RunnerApplicationDownlo osType, err := util.OSToOSType(osName) if err != nil { - return github.RunnerApplicationDownload{}, errors.Wrap(err, "fetching OS type") + log.Printf("failed to determine OS type from image, assuming %s", assumedOSType) + osType = assumedOSType } // Validate image OS. Linux only for now. @@ -232,7 +234,7 @@ func (l *LXD) getCreateInstanceArgs(bootstrapParams params.BootstrapInstance) (a return api.InstancesPost{}, errors.Wrap(err, "getting image details") } - tools, err := l.getTools(image, bootstrapParams.Tools) + tools, err := l.getTools(image, bootstrapParams.Tools, bootstrapParams.OSType) if err != nil { return api.InstancesPost{}, errors.Wrap(err, "getting tools") }