Skip to content

Commit

Permalink
Bug 1913736: do not fetch image id when booting from volume
Browse files Browse the repository at this point in the history
When we boot a machine from volume, we don't need to fetch the
image id.
  • Loading branch information
Fedosin committed Jan 7, 2021
1 parent ee98fb1 commit 5d51331
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
10 changes: 7 additions & 3 deletions pkg/cloud/openstack/clients/machineservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,13 @@ func (is *InstanceService) InstanceCreate(clusterName string, name string, clust
is.computeClient.Microversion = "2.52"
}

imageID, err := imageutils.IDFromName(is.imagesClient, config.Image)
if err != nil {
return nil, fmt.Errorf("Create new server err: %v", err)
var imageID string

if config.RootVolume == nil {
imageID, err = imageutils.IDFromName(is.imagesClient, config.Image)
if err != nil {
return nil, fmt.Errorf("Create new server err: %v", err)
}
}

flavorID, err := flavorutils.IDFromName(is.computeClient, config.Flavor)
Expand Down
10 changes: 6 additions & 4 deletions pkg/cloud/openstack/machine/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,10 +699,12 @@ func (oc *OpenstackClient) validateMachine(machine *machinev1.Machine) error {

// TODO(mfedosin): add more validations here

// Validate that image exists
err = machineService.DoesImageExist(machineSpec.Image)
if err != nil {
return err
// Validate that image exists when not booting from volume
if machineSpec.RootVolume == nil {
err = machineService.DoesImageExist(machineSpec.Image)
if err != nil {
return err
}
}

// Validate that flavor exists
Expand Down

0 comments on commit 5d51331

Please sign in to comment.