Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down