-
Notifications
You must be signed in to change notification settings - Fork 31
fix(azure): harden NVMe filter and credential handling for compute-sizes #824
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
Closed
rishupk
wants to merge
1
commit into
redhat-developer:main
from
rishupk:fix+azure-nvme-local-storage
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,183 @@ | ||
| package data | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7" | ||
| ) | ||
|
|
||
| func ptr[T any](v T) *T { return &v } | ||
|
|
||
| // noLocalStorageAttached tests | ||
|
|
||
| func TestNoLocalStorageAttached_NoTempDiskNoNvme(t *testing.T) { | ||
| vm := &virtualMachine{MaxResourceVolumeMB: 0, NvmeDiskSizeInMiB: 0} | ||
| if !vm.noLocalStorageAttached() { | ||
| t.Error("expected true: VM with no temp disk and no NVMe should have no local storage") | ||
| } | ||
| } | ||
|
|
||
| func TestNoLocalStorageAttached_HasTempDisk(t *testing.T) { | ||
| vm := &virtualMachine{MaxResourceVolumeMB: 512, NvmeDiskSizeInMiB: 0} | ||
| if vm.noLocalStorageAttached() { | ||
| t.Error("expected false: VM with temp disk should have local storage") | ||
| } | ||
| } | ||
|
|
||
| func TestNoLocalStorageAttached_HasNvmeDisk(t *testing.T) { | ||
| // L-series bug case: MaxResourceVolumeMB=0 but NvmeDiskSizeInMiB>0 | ||
| vm := &virtualMachine{MaxResourceVolumeMB: 0, NvmeDiskSizeInMiB: 5492736} | ||
| if vm.noLocalStorageAttached() { | ||
| t.Error("expected false: L-series VM with NVMe storage should have local storage") | ||
| } | ||
| } | ||
|
|
||
| func TestNoLocalStorageAttached_HasBoth(t *testing.T) { | ||
| vm := &virtualMachine{MaxResourceVolumeMB: 512, NvmeDiskSizeInMiB: 5492736} | ||
| if vm.noLocalStorageAttached() { | ||
| t.Error("expected false: VM with both temp disk and NVMe should have local storage") | ||
| } | ||
| } | ||
|
|
||
| // resourceSKUToVirtualMachine parsing tests | ||
|
|
||
| func TestResourceSKUToVirtualMachine_ParsesNvmeDiskSizeInMiB(t *testing.T) { | ||
| sku := &armcompute.ResourceSKU{ | ||
| ResourceType: ptr("virtualMachines"), | ||
| Name: ptr("Standard_L8aos_v4"), | ||
| Family: ptr("standardLasv4Family"), | ||
| Capabilities: []*armcompute.ResourceSKUCapabilities{ | ||
| {Name: ptr("NvmeDiskSizeInMiB"), Value: ptr("5492736")}, | ||
| }, | ||
| } | ||
| vm := resourceSKUToVirtualMachine(sku) | ||
| if vm == nil { | ||
| t.Fatal("expected non-nil virtualMachine") | ||
| } | ||
| if vm.NvmeDiskSizeInMiB != 5492736 { | ||
| t.Errorf("NvmeDiskSizeInMiB: got %d, want 5492736", vm.NvmeDiskSizeInMiB) | ||
| } | ||
| } | ||
|
|
||
| func TestResourceSKUToVirtualMachine_ParsesDiskControllerTypes(t *testing.T) { | ||
| sku := &armcompute.ResourceSKU{ | ||
| ResourceType: ptr("virtualMachines"), | ||
| Name: ptr("Standard_L8aos_v4"), | ||
| Family: ptr("standardLasv4Family"), | ||
| Capabilities: []*armcompute.ResourceSKUCapabilities{ | ||
| {Name: ptr("DiskControllerTypes"), Value: ptr("NVMe,SCSI")}, | ||
| }, | ||
| } | ||
| vm := resourceSKUToVirtualMachine(sku) | ||
| if vm == nil { | ||
| t.Fatal("expected non-nil virtualMachine") | ||
| } | ||
| if len(vm.DiskControllerTypes) != 2 { | ||
| t.Fatalf("DiskControllerTypes: got %v, want [NVMe SCSI]", vm.DiskControllerTypes) | ||
| } | ||
| if vm.DiskControllerTypes[0] != "NVMe" || vm.DiskControllerTypes[1] != "SCSI" { | ||
| t.Errorf("DiskControllerTypes: got %v, want [NVMe SCSI]", vm.DiskControllerTypes) | ||
| } | ||
| } | ||
|
|
||
| func TestResourceSKUToVirtualMachine_NvmeDiskSizeDefaultsToZero(t *testing.T) { | ||
| sku := &armcompute.ResourceSKU{ | ||
| ResourceType: ptr("virtualMachines"), | ||
| Name: ptr("Standard_D8as_v5"), | ||
| Family: ptr("standardDasv5Family"), | ||
| Capabilities: []*armcompute.ResourceSKUCapabilities{ | ||
| {Name: ptr("MaxResourceVolumeMB"), Value: ptr("307200")}, | ||
| }, | ||
| } | ||
| vm := resourceSKUToVirtualMachine(sku) | ||
| if vm == nil { | ||
| t.Fatal("expected non-nil virtualMachine") | ||
| } | ||
| if vm.NvmeDiskSizeInMiB != 0 { | ||
| t.Errorf("NvmeDiskSizeInMiB: got %d, want 0 for non-NVMe SKU", vm.NvmeDiskSizeInMiB) | ||
| } | ||
| } | ||
|
|
||
| // filterNVMeStorage tests | ||
|
|
||
| func TestFilterNVMeStorage_DropsNvmeSizes(t *testing.T) { | ||
| capabilities := map[string]*virtualMachine{ | ||
| "Standard_D8as_v5": {MaxResourceVolumeMB: 0, NvmeDiskSizeInMiB: 0}, | ||
| "Standard_L8aos_v4": {MaxResourceVolumeMB: 0, NvmeDiskSizeInMiB: 5492736}, | ||
| } | ||
| got, dropped, unknown := filterNVMeStorage([]string{"Standard_D8as_v5", "Standard_L8aos_v4"}, capabilities) | ||
| if len(got) != 1 || got[0] != "Standard_D8as_v5" { | ||
| t.Errorf("filtered: got %v, want [Standard_D8as_v5]", got) | ||
| } | ||
| if len(dropped) != 1 || dropped[0] != "Standard_L8aos_v4" { | ||
| t.Errorf("dropped: got %v, want [Standard_L8aos_v4]", dropped) | ||
| } | ||
| if len(unknown) != 0 { | ||
| t.Errorf("unknown: got %v, want []", unknown) | ||
| } | ||
| } | ||
|
|
||
| func TestFilterNVMeStorage_AllowsTempDiskSizes(t *testing.T) { | ||
| capabilities := map[string]*virtualMachine{ | ||
| "Standard_NC64as_T4_v3": {MaxResourceVolumeMB: 32768, NvmeDiskSizeInMiB: 0}, | ||
| } | ||
| got, dropped, unknown := filterNVMeStorage([]string{"Standard_NC64as_T4_v3"}, capabilities) | ||
| if len(got) != 1 { | ||
| t.Errorf("filtered: got %v, want [Standard_NC64as_T4_v3]", got) | ||
| } | ||
| if len(dropped) != 0 { | ||
| t.Errorf("dropped: got %v, want []", dropped) | ||
| } | ||
| if len(unknown) != 0 { | ||
| t.Errorf("unknown: got %v, want []", unknown) | ||
| } | ||
| } | ||
|
|
||
| func TestFilterNVMeStorage_PassesCleanSizes(t *testing.T) { | ||
| capabilities := map[string]*virtualMachine{ | ||
| "Standard_D8as_v5": {MaxResourceVolumeMB: 0, NvmeDiskSizeInMiB: 0}, | ||
| } | ||
| got, dropped, unknown := filterNVMeStorage([]string{"Standard_D8as_v5"}, capabilities) | ||
| if len(got) != 1 { | ||
| t.Errorf("filtered: got %v, want [Standard_D8as_v5]", got) | ||
| } | ||
| if len(dropped) != 0 { | ||
| t.Errorf("dropped: got %v, want []", dropped) | ||
| } | ||
| if len(unknown) != 0 { | ||
| t.Errorf("unknown: got %v, want []", unknown) | ||
| } | ||
| } | ||
|
|
||
| func TestFilterNVMeStorage_ReportsUnknownSizes(t *testing.T) { | ||
| capabilities := map[string]*virtualMachine{ | ||
| "Standard_D8as_v5": {MaxResourceVolumeMB: 0, NvmeDiskSizeInMiB: 0}, | ||
| } | ||
| got, dropped, unknown := filterNVMeStorage( | ||
| []string{"Standard_D8as_v5", "Standard_Typo_v99"}, capabilities) | ||
| if len(got) != 1 || got[0] != "Standard_D8as_v5" { | ||
| t.Errorf("filtered: got %v, want [Standard_D8as_v5]", got) | ||
| } | ||
| if len(dropped) != 0 { | ||
| t.Errorf("dropped: got %v, want []", dropped) | ||
| } | ||
| if len(unknown) != 1 || unknown[0] != "Standard_Typo_v99" { | ||
| t.Errorf("unknown: got %v, want [Standard_Typo_v99]", unknown) | ||
| } | ||
| } | ||
|
|
||
| // baseFeaturesSupported regression: L-series must be rejected | ||
|
|
||
| func TestBaseFeaturesSupported_LSeriesWithNvmeIsRejected(t *testing.T) { | ||
| vm := &virtualMachine{ | ||
| MaxResourceVolumeMB: 0, | ||
| NvmeDiskSizeInMiB: 5492736, | ||
| AcceleratedNetworkingEnabled: true, | ||
| PremiumIO: true, | ||
| EncryptionAtHostSupported: true, | ||
| HyperVGenerations: []string{"V1", "V2"}, | ||
| } | ||
| if vm.baseFeaturesSupported() { | ||
| t.Error("expected false: L-series VM with NVMe storage must not pass baseFeaturesSupported") | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: redhat-developer/mapt
Length of output: 6358
🏁 Script executed:
Repository: redhat-developer/mapt
Length of output: 1386
🏁 Script executed:
Repository: redhat-developer/mapt
Length of output: 15965
🏁 Script executed:
Repository: redhat-developer/mapt
Length of output: 1090
🏁 Script executed:
Repository: redhat-developer/mapt
Length of output: 854
🏁 Script executed:
Repository: redhat-developer/mapt
Length of output: 933
🏁 Script executed:
Repository: redhat-developer/mapt
Length of output: 1664
🏁 Script executed:
Repository: redhat-developer/mapt
Length of output: 1544
🏁 Script executed:
Repository: redhat-developer/mapt
Length of output: 17456
Scope issue: baseFeaturesSupported() now broadens NVMe/local-storage filtering to generic Azure auto-selection
pkg/provider/azure/data/compute-request.go→ComputeSelector.Select()→filterCPUsAndMemory()callsvm.baseFeaturesSupported(), which now requiresvm.noLocalStorageAttached()(i.e.,MaxResourceVolumeMB == 0 && NvmeDiskSizeInMiB == 0). That selector is used bypkg/provider/azure/modules/allocation/allocation.goandpkg/provider/azure/data/spot.gowheneverComputeRequest.ComputeSizesis empty, and those allocation paths are shared by Azure actions likelinux/windows/rhel/kind—so NVMe-backed sizes are excluded beyondpkg/provider/azure/action/rhel-ai/rhelai.go(which only filters providedComputeSizesviaFilterNoLocalStorageSizeswhen they’re non-empty). [Also affects ~307-323]🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emptyDiskSupported()has been insidebaseFeaturesSupported()since the file was first created (commit c6b2de1) — filtering out local-storage VMs from auto-selection was always a global constraint, not RHEL AI-specific. The only change here is closing the NVMe loophole: L-series VMs reportMaxResourceVolumeMB = 0but expose storage underNvmeDiskSizeInMiB, so the old check missed them. No Azure action in the repo references L-series VMs, and mapt's auto-selection is designed around managed disks, so broadening the filter to catch NVMe local storage is consistent with the original intent.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rishupk, that's a clear and well-reasoned explanation — thank you for the context. You're right: the local-storage exclusion was always a global constraint onbaseFeaturesSupported(), and this PR simply closes the NVMe loophole for L-series VMs that previously slipped through by reportingMaxResourceVolumeMB = 0. My concern doesn't apply here.