From 8bde9bec8216bb72072fab996860fb90fc2c2c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onni=20Pylv=C3=A4nen?= Date: Mon, 30 Nov 2026 15:41:26 +0200 Subject: [PATCH] Fix: Use actual GPU labels on GPU nodes --- .../upcloud/upcloud_cloud_provider.go | 5 ++++- .../upcloud/upcloud_cloud_provider_test.go | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cluster-autoscaler/cloudprovider/upcloud/upcloud_cloud_provider.go b/cluster-autoscaler/cloudprovider/upcloud/upcloud_cloud_provider.go index 2cc977fc676a..5cd15bd1ff0d 100644 --- a/cluster-autoscaler/cloudprovider/upcloud/upcloud_cloud_provider.go +++ b/cluster-autoscaler/cloudprovider/upcloud/upcloud_cloud_provider.go @@ -55,6 +55,9 @@ const ( // ProviderName is the cloud provider name for this provider. ProviderName = "upcloud" + + // GPULabel is the label added to UpCloud Managed Kubernetes nodes with GPU resources. + GPULabel = "uks.upcloud.com/gpu-node" ) type upCloudConfig struct { @@ -130,7 +133,7 @@ func (u *upCloudCloudProvider) GetAvailableGPUTypes(ctx context.Context) map[str // GPULabel returns the label added to nodes with GPU resource. func (u *upCloudCloudProvider) GPULabel(ctx context.Context) string { klog.V(logDebug).Info("UpCloud CloudProvider.GPULabel called") - return "" + return GPULabel } // GetNodeGpuConfig returns the label, type and resource name for the GPU added to node. If node doesn't have diff --git a/cluster-autoscaler/cloudprovider/upcloud/upcloud_cloud_provider_test.go b/cluster-autoscaler/cloudprovider/upcloud/upcloud_cloud_provider_test.go index 5930d501617d..0dddaedd8017 100644 --- a/cluster-autoscaler/cloudprovider/upcloud/upcloud_cloud_provider_test.go +++ b/cluster-autoscaler/cloudprovider/upcloud/upcloud_cloud_provider_test.go @@ -24,6 +24,7 @@ import ( "github.com/google/uuid" "github.com/stretchr/testify/require" v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/autoscaler/cluster-autoscaler/cloudprovider/upcloud/mocks" "k8s.io/autoscaler/cluster-autoscaler/cloudprovider/upcloud/pkg/github.com/upcloudltd/upcloud-go-api/v8/upcloud" "sigs.k8s.io/cluster-autoscaler/pkg/cloudprovider" @@ -152,7 +153,7 @@ func TestUpCloudCloudProvider_GPULabel(t *testing.T) { t.Parallel() p := upCloudCloudProvider{} - require.Empty(t, p.GPULabel(t.Context())) + require.Equal(t, GPULabel, p.GPULabel(t.Context())) } func TestUpCloudCloudProvider_GetAvailableGPUTypes(t *testing.T) { @@ -178,6 +179,18 @@ func TestUpCloudCloudProvider_GetNodeGpuConfig(t *testing.T) { ProviderID: fmt.Sprintf("upcloud:////%s", uuid.NewString()), }, })) + + got := p.GetNodeGpuConfig(t.Context(), &v1.Node{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{GPULabel: "true"}, + }, + Spec: v1.NodeSpec{ + ProviderID: fmt.Sprintf("upcloud:////%s", uuid.NewString()), + }, + }) + require.Equal(t, GPULabel, got.Label) + require.Equal(t, "true", got.Type) + require.Equal(t, v1.ResourceName("nvidia.com/gpu"), got.ExtendedResourceName) } func TestUpCloudCloudProvider_ErrNotImplemented(t *testing.T) {