Content-Length: 267727 | pFad | https://github.com/kubernetes/kubernetes/commit/ee315804e7bef5b62640ec5076100d08c3436e16

66 Merge pull request #124528 from jsafrane/fix-azure-topology · kubernetes/kubernetes@ee31580 · GitHub
Skip to content

Commit

Permalink
Merge pull request #124528 from jsafrane/fix-azure-topology
Browse files Browse the repository at this point in the history
1.29: Fix PersistentVolumeLabel admission plugin on Azure
  • Loading branch information
k8s-ci-robot authored May 29, 2024
2 parents dbefeef + e5561a4 commit ee31580
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,11 @@ func (c *Cloud) GetAzureDiskLabels(diskURI string) (map[string]string, error) {
return nil, err
}

if c.Location == "" {
// The cloud provider is not initialized and cannot get the topology labels.
return nil, nil
}

labels := map[string]string{
v1.LabelTopologyRegion: c.Location,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
cloudprovider "k8s.io/cloud-provider"

v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
Expand Down Expand Up @@ -551,3 +552,31 @@ func TestGetLabelsForVolume(t *testing.T) {
assert.Equal(t, test.expectedErrMsg, err, "TestCase[%d]: %s, expected: %v, return: %v", i, test.desc, test.expectedErrMsg, err)
}
}

func TestGetAzureDiskLabelsUninitialized(t *testing.T) {
// Create an uninitialized Azure cloud provider
testCloud, err := NewCloud(nil)
if err != nil {
t.Fatalf("Failed to create uninitialized cloud: %v", err)
}

pv := &v1.PersistentVolume{
Spec: v1.PersistentVolumeSpec{
PersistentVolumeSource: v1.PersistentVolumeSource{
AzureDisk: &v1.AzureDiskVolumeSource{
DiskName: cloudvolume.ProvisionedVolumeName,
DataDiskURI: "/subscriptions/4347f140-6c74-4199-b4fc-1938eb6c16c0/resourceGroups/test/providers/Microsoft.Compute/disks/pvc-ade30d58-5a51-4a62-a83a-142267b74f9e",
},
},
},
}

labeller := testCloud.(cloudprovider.PVLabeler)
labels, err := labeller.GetLabelsForVolume(context.Background(), pv)
if err != nil {
t.Errorf("Unexpected GetLabelsForVolume error: %v", err)
}
if labels != nil {
t.Errorf("The cloud provider should return nil labels for uninitialized cloud, got: %v", labels)
}
}

0 comments on commit ee31580

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/kubernetes/kubernetes/commit/ee315804e7bef5b62640ec5076100d08c3436e16

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy