Skip to content

Commit c87a60a

Browse files
Add image in GCP only if its a boot disk
1 parent 8846555 commit c87a60a

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

pkg/webhooks/machine_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ func defaultGCPDisks(disks []*machinev1beta1.GCPDisk, clusterID string) []*machi
13721372
disk.Type = defaultGCPDiskType
13731373
}
13741374

1375-
if disk.Image == "" {
1375+
if disk.Boot && disk.Image == "" {
13761376
disk.Image = defaultGCPDiskImage()
13771377
}
13781378
}

pkg/webhooks/machine_webhook_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5124,6 +5124,39 @@ func TestDefaultGCPProviderSpec(t *testing.T) {
51245124
expectedError: "",
51255125
expectedWarnings: itWarnings,
51265126
},
5127+
{
5128+
testCase: "non-boot disk without image remains empty",
5129+
providerSpec: &machinev1beta1.GCPMachineProviderSpec{
5130+
Disks: []*machinev1beta1.GCPDisk{
5131+
{
5132+
Boot: true,
5133+
Image: "custom-boot-image",
5134+
},
5135+
{
5136+
Boot: false,
5137+
SizeGB: 100,
5138+
},
5139+
},
5140+
},
5141+
modifyDefault: func(p *machinev1beta1.GCPMachineProviderSpec) {
5142+
p.Disks = []*machinev1beta1.GCPDisk{
5143+
{
5144+
Boot: true,
5145+
Image: "custom-boot-image",
5146+
Type: defaultGCPDiskType,
5147+
},
5148+
{
5149+
Boot: false,
5150+
SizeGB: 100,
5151+
Type: defaultGCPDiskType,
5152+
Image: "",
5153+
},
5154+
}
5155+
},
5156+
expectedOk: true,
5157+
expectedError: "",
5158+
expectedWarnings: itWarnings,
5159+
},
51275160
}
51285161

51295162
platformStatus := &osconfigv1.PlatformStatus{

0 commit comments

Comments
 (0)