Skip to content

Commit 64f9659

Browse files
mxm-trmaxime.hubert
authored andcommitted
feat(ovhcloud): update gpu categories
1 parent efed170 commit 64f9659

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

cluster-autoscaler/cloudprovider/ovhcloud/ovh_cloud_node_group.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,11 @@ func (ng *NodeGroup) isGpu() bool {
352352
if err != nil {
353353
// Fallback when we are unable to get the flavor: refer to the only category
354354
// known to be a GPU flavor category
355-
return strings.HasPrefix(ng.Flavor, GPUMachineCategory)
355+
for _, gpuCategoryPrefix := range GPUMachineCategoryPrefixes {
356+
if strings.HasPrefix(ng.Flavor, gpuCategoryPrefix) {
357+
return true
358+
}
359+
}
356360
}
357361

358362
return flavor.GPUs > 0

cluster-autoscaler/cloudprovider/ovhcloud/ovh_cloud_node_group_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,19 @@ func TestOVHCloudNodeGroup_IsGpu(t *testing.T) {
522522
})
523523

524524
t.Run("not found but belong to GPU category", func(t *testing.T) {
525-
ng := newTestNodeGroup(t, GPUMachineCategory+"1-123")
525+
ng := newTestNodeGroup(t, "t1-123")
526526
assert.True(t, ng.isGpu())
527527
})
528+
529+
t.Run("not found but belong to GPU category", func(t *testing.T) {
530+
ng := newTestNodeGroup(t, "h1-123")
531+
assert.True(t, ng.isGpu())
532+
})
533+
534+
t.Run("not found and does not belong to GPU category", func(t *testing.T) {
535+
ng := newTestNodeGroup(t, "n1-123")
536+
assert.False(t, ng.isGpu())
537+
})
528538
}
529539

530540
func TestOVHCloudNodeGroup_GetOptions(t *testing.T) {

cluster-autoscaler/cloudprovider/ovhcloud/ovh_cloud_provider.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ const (
4444

4545
// MachineAvailableState defines the state for available flavors for node resources.
4646
MachineAvailableState = "available"
47-
48-
// GPUMachineCategory defines the default instance category for GPU resources.
49-
GPUMachineCategory = "t"
5047
)
5148

49+
// GPUMachineCategoryPrefixes defines the flavors prefixes for GPU resources.
50+
var GPUMachineCategoryPrefixes = [4]string{"t", "h", "a", "l"}
51+
5252
// OVHCloudProvider implements CloudProvider interface.
5353
type OVHCloudProvider struct {
5454
manager *OvhCloudManager

0 commit comments

Comments
 (0)