Skip to content

Commit 63752b0

Browse files
Michael Weibeljackfrancis
authored andcommitted
fix: MachinePool ephemeral osDisk support
1 parent 057332f commit 63752b0

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

azure/services/scalesets/scalesets.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,10 @@ func (s *Service) generateStorageProfile(ctx context.Context, vmssSpec azure.Sca
637637
}
638638
}
639639

640+
if vmssSpec.OSDisk.CachingType != "" {
641+
storageProfile.OsDisk.Caching = compute.CachingTypes(vmssSpec.OSDisk.CachingType)
642+
}
643+
640644
dataDisks := make([]compute.VirtualMachineScaleSetDataDisk, len(vmssSpec.DataDisks))
641645
for i, disk := range vmssSpec.DataDisks {
642646
dataDisks[i] = compute.VirtualMachineScaleSetDataDisk{

azure/services/scalesets/scalesets_test.go

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,30 @@ func TestReconcileVMSS(t *testing.T) {
409409
})
410410
},
411411
},
412+
{
413+
name: "should start creating a vmss with ephemeral osdisk",
414+
expectedError: "failed to get VMSS my-vmss after create or update: failed to get result from future: operation type PUT on Azure resource my-rg/my-vmss is not done",
415+
expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, m *mock_scalesets.MockClientMockRecorder) {
416+
defaultSpec := newDefaultVMSSSpec()
417+
defaultSpec.Size = "VM_SIZE_EPH"
418+
defaultSpec.OSDisk.DiffDiskSettings = &infrav1.DiffDiskSettings{
419+
Option: "Local",
420+
}
421+
defaultSpec.OSDisk.CachingType = "ReadOnly"
422+
423+
s.ScaleSetSpec().Return(defaultSpec).AnyTimes()
424+
setupDefaultVMSSStartCreatingExpectations(s, m)
425+
vmss := newDefaultVMSS("VM_SIZE_EPH")
426+
vmss.VirtualMachineScaleSetProperties.VirtualMachineProfile.StorageProfile.OsDisk.DiffDiskSettings = &compute.DiffDiskSettings{
427+
Option: compute.DiffDiskOptionsLocal,
428+
}
429+
vmss.VirtualMachineScaleSetProperties.VirtualMachineProfile.StorageProfile.OsDisk.Caching = compute.CachingTypesReadOnly
430+
431+
m.CreateOrUpdateAsync(gomockinternal.AContext(), defaultResourceGroup, defaultVMSSName, gomockinternal.DiffEq(vmss)).
432+
Return(putFuture, nil)
433+
setupCreatingSucceededExpectations(s, m, newDefaultExistingVMSS("VM_SIZE_EPH"), putFuture)
434+
},
435+
},
412436
{
413437
name: "should start updating when scale set already exists and not currently in a long running operation",
414438
expectedError: "failed to get VMSS my-vmss after create or update: failed to get result from future: operation type PATCH on Azure resource my-rg/my-vmss is not done",
@@ -887,6 +911,49 @@ func getFakeSkus() []compute.ResourceSku {
887911
},
888912
},
889913
},
914+
{
915+
Name: to.StringPtr("VM_SIZE_EPH"),
916+
ResourceType: to.StringPtr(string(resourceskus.VirtualMachines)),
917+
Kind: to.StringPtr(string(resourceskus.VirtualMachines)),
918+
Locations: &[]string{
919+
"test-location",
920+
},
921+
LocationInfo: &[]compute.ResourceSkuLocationInfo{
922+
{
923+
Location: to.StringPtr("test-location"),
924+
Zones: &[]string{"1", "3"},
925+
ZoneDetails: &[]compute.ResourceSkuZoneDetails{
926+
{
927+
Capabilities: &[]compute.ResourceSkuCapabilities{
928+
{
929+
Name: pointer.String("UltraSSDAvailable"),
930+
Value: pointer.String("True"),
931+
},
932+
},
933+
Name: &[]string{"1", "3"},
934+
},
935+
},
936+
},
937+
},
938+
Capabilities: &[]compute.ResourceSkuCapabilities{
939+
{
940+
Name: to.StringPtr(resourceskus.AcceleratedNetworking),
941+
Value: to.StringPtr(string(resourceskus.CapabilityUnsupported)),
942+
},
943+
{
944+
Name: to.StringPtr(resourceskus.VCPUs),
945+
Value: to.StringPtr("4"),
946+
},
947+
{
948+
Name: to.StringPtr(resourceskus.MemoryGB),
949+
Value: to.StringPtr("4"),
950+
},
951+
{
952+
Name: to.StringPtr(resourceskus.EphemeralOSDisk),
953+
Value: to.StringPtr("True"),
954+
},
955+
},
956+
},
890957
}
891958
}
892959

0 commit comments

Comments
 (0)