Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect assignment of Image ID #2291

Merged
merged 3 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/cloud-providers/aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,17 @@ func (p *awsProvider) CreateInstance(ctx context.Context, podName, sandboxID str
}
} else {

imageId := p.serviceConfig.ImageId

if spec.Image != "" {
logger.Printf("Choosing %s from annotation as the AWS AMI for the PodVM image", spec.Image)
p.serviceConfig.ImageId = spec.Image
imageId = spec.Image
}

input = &ec2.RunInstancesInput{
MinCount: aws.Int32(1),
MaxCount: aws.Int32(1),
ImageId: aws.String(p.serviceConfig.ImageId),
ImageId: aws.String(imageId),
InstanceType: types.InstanceType(instanceType),
SecurityGroupIds: p.serviceConfig.SecurityGroupIds,
SubnetId: aws.String(p.serviceConfig.SubnetId),
Expand Down Expand Up @@ -337,8 +339,8 @@ func (p *awsProvider) Teardown() error {
}

func (p *awsProvider) ConfigVerifier() error {
ImageId := p.serviceConfig.ImageId
if len(ImageId) == 0 {
imageId := p.serviceConfig.ImageId
if len(imageId) == 0 {
return fmt.Errorf("ImageId is empty")
}
return nil
Expand Down
18 changes: 10 additions & 8 deletions src/cloud-providers/azure/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,14 @@ func (p *azureProvider) CreateInstance(ctx context.Context, podName, sandboxID s
return nil, err
}

imageId := p.serviceConfig.ImageId

if spec.Image != "" {
logger.Printf("Choosing %s from annotation as the Azure Image for the PodVM image", spec.Image)
p.serviceConfig.ImageId = spec.Image
imageId = spec.Image
}

vmParameters, err := p.getVMParameters(instanceSize, diskName, cloudConfigData, sshBytes, instanceName, nicName)
vmParameters, err := p.getVMParameters(instanceSize, diskName, cloudConfigData, sshBytes, instanceName, nicName, imageId)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -300,8 +302,8 @@ func (p *azureProvider) Teardown() error {
}

func (p *azureProvider) ConfigVerifier() error {
ImageId := p.serviceConfig.ImageId
if len(ImageId) == 0 {
imageId := p.serviceConfig.ImageId
if len(imageId) == 0 {
return fmt.Errorf("ImageId is empty")
}

Expand Down Expand Up @@ -371,7 +373,7 @@ func (p *azureProvider) getResourceTags() map[string]*string {
return tags
}

func (p *azureProvider) getVMParameters(instanceSize, diskName, cloudConfig string, sshBytes []byte, instanceName, nicName string) (*armcompute.VirtualMachine, error) {
func (p *azureProvider) getVMParameters(instanceSize, diskName, cloudConfig string, sshBytes []byte, instanceName, nicName string, imageId string) (*armcompute.VirtualMachine, error) {
userDataB64 := base64.StdEncoding.EncodeToString([]byte(cloudConfig))

// Azure limits the base64 encrypted userData to 64KB.
Expand Down Expand Up @@ -406,11 +408,11 @@ func (p *azureProvider) getVMParameters(instanceSize, diskName, cloudConfig stri
}

imgRef := &armcompute.ImageReference{
ID: to.Ptr(p.serviceConfig.ImageId),
ID: to.Ptr(imageId),
}
if strings.HasPrefix(p.serviceConfig.ImageId, "/CommunityGalleries/") {
if strings.HasPrefix(imageId, "/CommunityGalleries/") {
imgRef = &armcompute.ImageReference{
CommunityGalleryImageID: to.Ptr(p.serviceConfig.ImageId),
CommunityGalleryImageID: to.Ptr(imageId),
}
}

Expand Down
10 changes: 6 additions & 4 deletions src/cloud-providers/ibmcloud-powervs/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ func (p *ibmcloudPowerVSProvider) CreateInstance(ctx context.Context, podName, s
return nil, err
}

imageId := p.serviceConfig.ImageId

if spec.Image != "" {
logger.Printf("Choosing %s from annotation as the Power VS image for the PodVM image", spec.Image)
p.serviceConfig.ImageId = spec.Image
imageId = spec.Image
}

body := &models.PVMInstanceCreate{
ServerName: &instanceName,
ImageID: &p.serviceConfig.ImageId,
ImageID: &imageId,
KeyPairName: p.serviceConfig.SSHKey,
Networks: []*models.PVMInstanceAddNetwork{
{
Expand Down Expand Up @@ -148,8 +150,8 @@ func (p *ibmcloudPowerVSProvider) Teardown() error {
}

func (p *ibmcloudPowerVSProvider) ConfigVerifier() error {
ImageId := p.serviceConfig.ImageId
if len(ImageId) == 0 {
imageId := p.serviceConfig.ImageId
if len(imageId) == 0 {
return fmt.Errorf("ImageId is empty")
}
return nil
Expand Down
Loading