Remove unused param, add OSType to bootstrap param

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2023-03-16 12:29:00 +02:00
parent b17c921a7c
commit 91e2d7b029
No known key found for this signature in database
GPG key ID: 7D073DCC2C074CB5
4 changed files with 9 additions and 5 deletions

View file

@ -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"`

View file

@ -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,

View file

@ -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)
}

View file

@ -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")
}