Skip to content

Commit fde2e2c

Browse files
Use topology.kubernetes.io labels
1 parent db6505e commit fde2e2c

File tree

6 files changed

+45
-25
lines changed

6 files changed

+45
-25
lines changed

pkg/csi-util/utils.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,16 @@ func (u *Util) LookupNodeAvailableDomain(k kubernetes.Interface, nodeID string)
109109
return "", fmt.Errorf("failed to get node %s", nodeID)
110110
}
111111
if n.Labels != nil {
112-
ad, ok := n.Labels[kubeAPI.LabelZoneFailureDomain]
112+
ad, ok := n.Labels[kubeAPI.LabelTopologyZone]
113+
if !ok {
114+
ad, ok = n.Labels[kubeAPI.LabelZoneFailureDomain]
115+
}
113116
if ok {
114117
return ad, nil
115118
}
116119
}
117-
118-
errMsg := fmt.Sprint("Did not find the label for the fault domain.")
119-
u.Logger.With("nodeId", nodeID, "label", kubeAPI.LabelZoneFailureDomain).Error(errMsg)
120+
errMsg := fmt.Sprintf("Did not find the label for the fault domain. Checked Topology Labels: %s, %s", kubeAPI.LabelTopologyZone, kubeAPI.LabelZoneFailureDomain)
121+
u.Logger.With("nodeId", nodeID).Error(errMsg)
120122
return "", fmt.Errorf(errMsg)
121123
}
122124

pkg/csi/driver/bv_controller.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,11 @@ func (d *BlockVolumeControllerDriver) CreateVolume(ctx context.Context, req *csi
324324

325325
if req.AccessibilityRequirements != nil && req.AccessibilityRequirements.Preferred != nil && availableDomainShortName == "" {
326326
for _, t := range req.AccessibilityRequirements.Preferred {
327-
availableDomainShortName, _ = t.Segments[kubeAPI.LabelZoneFailureDomain]
327+
var ok bool
328+
availableDomainShortName, ok = t.Segments[kubeAPI.LabelTopologyZone]
329+
if !ok {
330+
availableDomainShortName, _ = t.Segments[kubeAPI.LabelZoneFailureDomain]
331+
}
328332
log.With("AD", availableDomainShortName).Info("Using preferred topology for AD.")
329333
if len(availableDomainShortName) > 0 {
330334
break
@@ -335,7 +339,11 @@ func (d *BlockVolumeControllerDriver) CreateVolume(ctx context.Context, req *csi
335339
if availableDomainShortName == "" {
336340
if req.AccessibilityRequirements != nil && req.AccessibilityRequirements.Requisite != nil {
337341
for _, t := range req.AccessibilityRequirements.Requisite {
338-
availableDomainShortName, _ = t.Segments[kubeAPI.LabelZoneFailureDomain]
342+
var ok bool
343+
availableDomainShortName, ok = t.Segments[kubeAPI.LabelTopologyZone]
344+
if !ok {
345+
availableDomainShortName, _ = t.Segments[kubeAPI.LabelZoneFailureDomain]
346+
}
339347
log.With("AD", availableDomainShortName).Info("Using requisite topology for AD.")
340348
if len(availableDomainShortName) > 0 {
341349
break
@@ -360,7 +368,7 @@ func (d *BlockVolumeControllerDriver) CreateVolume(ctx context.Context, req *csi
360368
dimensionsMap[metrics.ComponentDimension] = metricDimension
361369
metrics.SendMetricData(d.metricPusher, metric, time.Since(startTime).Seconds(), dimensionsMap)
362370
log.Error("Available domain short name is not found")
363-
return nil, status.Errorf(codes.InvalidArgument, "%s is required in PreferredTopologies or allowedTopologies", kubeAPI.LabelZoneFailureDomain)
371+
return nil, status.Errorf(codes.InvalidArgument, "(%s) or (%s) is required in PreferredTopologies or allowedTopologies", kubeAPI.LabelTopologyZone, kubeAPI.LabelZoneFailureDomain)
364372
}
365373

366374
//make sure this method is idempotent by checking existence of volume with same name.
@@ -452,6 +460,11 @@ func (d *BlockVolumeControllerDriver) CreateVolume(ctx context.Context, req *csi
452460
VolumeId: *provisionedVolume.Id,
453461
CapacityBytes: *provisionedVolume.SizeInMBs * client.MiB,
454462
AccessibleTopology: []*csi.Topology{
463+
{
464+
Segments: map[string]string{
465+
kubeAPI.LabelTopologyZone: d.util.GetAvailableDomainInNodeLabel(*provisionedVolume.AvailabilityDomain),
466+
},
467+
},
455468
{
456469
Segments: map[string]string{
457470
kubeAPI.LabelZoneFailureDomain: d.util.GetAvailableDomainInNodeLabel(*provisionedVolume.AvailabilityDomain),

pkg/csi/driver/bv_node.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ func (d BlockVolumeNodeDriver) NodeGetInfo(ctx context.Context, req *csi.NodeGet
659659
AccessibleTopology: &csi.Topology{
660660
Segments: map[string]string{
661661
kubeAPI.LabelZoneFailureDomain: ad,
662+
kubeAPI.LabelTopologyZone: ad,
662663
},
663664
},
664665
}, nil

pkg/csi/driver/fss_node.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ func (d FSSNodeDriver) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequ
428428
AccessibleTopology: &csi.Topology{
429429
Segments: map[string]string{
430430
kubeAPI.LabelZoneFailureDomain: ad,
431+
kubeAPI.LabelTopologyZone: ad,
431432
},
432433
},
433434
}, nil

test/e2e/cloud-provider-oci/csi_volume_creation.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323

2424
. "github.com/onsi/ginkgo"
2525
csi_util "github.com/oracle/oci-cloud-controller-manager/pkg/csi-util"
26-
"github.com/oracle/oci-cloud-controller-manager/pkg/volume/provisioner/plugin"
2726
"github.com/oracle/oci-cloud-controller-manager/test/e2e/framework"
2827
)
2928

@@ -392,7 +391,8 @@ var _ = Describe("CSI Ultra High Performance Volumes", func() {
392391
pvcJig.VerifyMultipathEnabled(ctx, f.ComputeClient, pvc.Name, f.Namespace.Name, compartmentId)
393392

394393
f.VolumeIds = append(f.VolumeIds, pvc.Spec.VolumeName)
395-
err := pvcJig.DeleteAndAwaitPod(f.Namespace.Name, podName); if err != nil {
394+
err := pvcJig.DeleteAndAwaitPod(f.Namespace.Name, podName)
395+
if err != nil {
396396
framework.Failf("Error deleting pod: %v", err)
397397
}
398398
_ = f.DeleteStorageClass(scName)
@@ -407,7 +407,8 @@ var _ = Describe("CSI Ultra High Performance Volumes", func() {
407407
pvcJig.VerifyMultipathEnabled(ctx, f.ComputeClient, pvc.Name, f.Namespace.Name, compartmentId)
408408

409409
f.VolumeIds = append(f.VolumeIds, pvc.Spec.VolumeName)
410-
err = pvcJig.DeleteAndAwaitPod(f.Namespace.Name, podName); if err != nil {
410+
err = pvcJig.DeleteAndAwaitPod(f.Namespace.Name, podName)
411+
if err != nil {
411412
framework.Failf("Error deleting pod: %v", err)
412413
}
413414
_ = f.DeleteStorageClass(scName)
@@ -422,14 +423,15 @@ var _ = Describe("CSI Ultra High Performance Volumes", func() {
422423
pvcJig.VerifyMultipathEnabled(ctx, f.ComputeClient, pvc.Name, f.Namespace.Name, compartmentId)
423424

424425
f.VolumeIds = append(f.VolumeIds, pvc.Spec.VolumeName)
425-
err = pvcJig.DeleteAndAwaitPod(f.Namespace.Name, podName); if err != nil {
426+
err = pvcJig.DeleteAndAwaitPod(f.Namespace.Name, podName)
427+
if err != nil {
426428
framework.Failf("Error deleting pod: %v", err)
427429
}
428430
_ = f.DeleteStorageClass(scName)
429431
By("Completed test: Create CSI block volume with UHP Performance Level and xfs file system")
430432

431433
By("Running test: Static Provisioning CSI UHP")
432-
scName = f.CreateStorageClassOrFail(framework.ClassOCIUHP + "-4", "blockvolume.csi.oraclecloud.com",
434+
scName = f.CreateStorageClassOrFail(framework.ClassOCIUHP+"-4", "blockvolume.csi.oraclecloud.com",
433435
map[string]string{framework.AttachmentType: framework.AttachmentTypeParavirtualized, csi_util.VpusPerGB: "30"},
434436
pvcJig.Labels, "WaitForFirstConsumer", true, "Delete", nil)
435437

@@ -439,15 +441,16 @@ var _ = Describe("CSI Ultra High Performance Volumes", func() {
439441
pvcJig.VerifyMultipathEnabled(ctx, f.ComputeClient, pvc.Name, f.Namespace.Name, compartmentId)
440442

441443
pvcJig.CheckVolumeCapacity("50Gi", pvc.Name, f.Namespace.Name)
442-
err = pvcJig.DeleteAndAwaitPod(f.Namespace.Name, podName); if err != nil {
444+
err = pvcJig.DeleteAndAwaitPod(f.Namespace.Name, podName)
445+
if err != nil {
443446
framework.Failf("Error deleting pod: %v", err)
444447
}
445448
f.VolumeIds = append(f.VolumeIds, volumeId)
446449
_ = f.DeleteStorageClass(scName)
447450
By("Completed test: Static Provisioning CSI UHP")
448451

449452
By("Running test: Basic Pod Delete UHP")
450-
scName = f.CreateStorageClassOrFail(framework.ClassOCIUHP + "-5", "blockvolume.csi.oraclecloud.com",
453+
scName = f.CreateStorageClassOrFail(framework.ClassOCIUHP+"-5", "blockvolume.csi.oraclecloud.com",
451454
map[string]string{framework.AttachmentType: framework.AttachmentTypeISCSI, csi_util.VpusPerGB: "30"},
452455
pvcJig.Labels, "WaitForFirstConsumer", true, "Delete", nil)
453456
pvc = pvcJig.CreateAndAwaitPVCOrFailCSI(f.Namespace.Name, framework.MinVolumeBlock, scName, nil, v1.PersistentVolumeFilesystem, v1.ReadWriteOnce, v1.ClaimPending)
@@ -476,7 +479,7 @@ var _ = Describe("CSI Ultra High Performance Volumes", func() {
476479
framework.AttachmentType: framework.AttachmentTypeISCSI,
477480
csi_util.VpusPerGB: "30",
478481
}
479-
scName = f.CreateStorageClassOrFail(framework.ClassOCIKMS + "-1", "blockvolume.csi.oraclecloud.com", scParameter, pvcJig.Labels, "WaitForFirstConsumer", false, "Delete", nil)
482+
scName = f.CreateStorageClassOrFail(framework.ClassOCIKMS+"-1", "blockvolume.csi.oraclecloud.com", scParameter, pvcJig.Labels, "WaitForFirstConsumer", false, "Delete", nil)
480483
pvc = pvcJig.CreateAndAwaitPVCOrFailCSI(f.Namespace.Name, framework.MinVolumeBlock, scName, nil, v1.PersistentVolumeFilesystem, v1.ReadWriteOnce, v1.ClaimPending)
481484
podName = pvcJig.NewPodForCSI("app1", f.Namespace.Name, pvc.Name, setupF.AdLabel)
482485
pvcJig.VerifyMultipathEnabled(ctx, f.ComputeClient, pvc.Name, f.Namespace.Name, compartmentId)
@@ -501,7 +504,7 @@ var _ = Describe("CSI Ultra High Performance Volumes", func() {
501504
By("Running test: Expand PVC VolumeSize from 50Gi to 100Gi and asserts size, file existence and file corruptions for iSCSI UHP volume")
502505
pvcJig.Name = "csi-uhp-pvc-expand-to-100gi"
503506
var size = "100Gi"
504-
scName = f.CreateStorageClassOrFail(framework.ClassOCIUHP + "-6", "blockvolume.csi.oraclecloud.com",
507+
scName = f.CreateStorageClassOrFail(framework.ClassOCIUHP+"-6", "blockvolume.csi.oraclecloud.com",
505508
map[string]string{framework.AttachmentType: framework.AttachmentTypeISCSI, csi_util.VpusPerGB: "30"},
506509
pvcJig.Labels, "WaitForFirstConsumer", true, "Delete", nil)
507510
pvc = pvcJig.CreateAndAwaitPVCOrFailCSI(f.Namespace.Name, framework.MinVolumeBlock, scName, nil, v1.PersistentVolumeFilesystem, v1.ReadWriteOnce, v1.ClaimPending)
@@ -519,7 +522,7 @@ var _ = Describe("CSI Ultra High Performance Volumes", func() {
519522
By("Completed test: Expand PVC VolumeSize from 50Gi to 100Gi and asserts size, file existence and file corruptions for iSCSI UHP volume")
520523

521524
By("Running test: Expand PVC VolumeSize from 50Gi to 100Gi and asserts size, file existence and file corruptions for Paravirtualized UHP volume")
522-
scName = f.CreateStorageClassOrFail(framework.ClassOCIUHP + "-7", "blockvolume.csi.oraclecloud.com",
525+
scName = f.CreateStorageClassOrFail(framework.ClassOCIUHP+"-7", "blockvolume.csi.oraclecloud.com",
523526
map[string]string{framework.AttachmentType: framework.AttachmentTypeParavirtualized, csi_util.VpusPerGB: "30"},
524527
pvcJig.Labels, "WaitForFirstConsumer", true, "Delete", nil)
525528
pvc = pvcJig.CreateAndAwaitPVCOrFailCSI(f.Namespace.Name, framework.MinVolumeBlock, scName, nil, v1.PersistentVolumeFilesystem, v1.ReadWriteOnce, v1.ClaimPending)
@@ -751,8 +754,8 @@ func testTwoPVCSetup(f *framework.CloudProviderFramework, storageclass1params ma
751754
nodeHostname := pvcJig.GetNodeHostnameFromPod(podName, f.Namespace.Name)
752755

753756
nodeLabels := map[string]string{
754-
plugin.LabelZoneFailureDomain: setupF.AdLabel,
755-
framework.NodeHostnameLabel: nodeHostname,
757+
v1.LabelTopologyZone: setupF.AdLabel,
758+
framework.NodeHostnameLabel: nodeHostname,
756759
}
757760

758761
lowPerfScName := f.CreateStorageClassOrFail("storage-class-two", "blockvolume.csi.oraclecloud.com",
@@ -761,7 +764,6 @@ func testTwoPVCSetup(f *framework.CloudProviderFramework, storageclass1params ma
761764
pvcTwo := pvcJig.CreateAndAwaitPVCOrFailCSI(f.Namespace.Name, framework.MinVolumeBlock, lowPerfScName, nil, v1.PersistentVolumeFilesystem, v1.ReadWriteOnce, v1.ClaimPending)
762765
podName2 := pvcJig.NewPodWithLabels("pvc-two-app", f.Namespace.Name, pvcTwo.Name, nodeLabels)
763766

764-
765767
pvcJig.DeleteAndAwaitPodOrFail(f.Namespace.Name, podName)
766768
pvcJig.DeleteAndAwaitPodOrFail(f.Namespace.Name, podName2)
767769
f.VolumeIds = append(f.VolumeIds, pvc.Spec.VolumeName)

test/e2e/framework/pvc_util.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ import (
3636

3737
. "github.com/onsi/ginkgo"
3838
. "github.com/onsi/gomega"
39+
ocicore "github.com/oracle/oci-go-sdk/v65/core"
40+
3941
csi_util "github.com/oracle/oci-cloud-controller-manager/pkg/csi-util"
4042
"github.com/oracle/oci-cloud-controller-manager/pkg/csi/driver"
4143
"github.com/oracle/oci-cloud-controller-manager/pkg/oci/client"
4244
"github.com/oracle/oci-cloud-controller-manager/pkg/volume/provisioner/plugin"
43-
ocicore "github.com/oracle/oci-go-sdk/v65/core"
4445
)
4546

4647
const (
@@ -100,7 +101,7 @@ func (j *PVCTestJig) pvcAddLabelSelector(pvc *v1.PersistentVolumeClaim, adLabel
100101
if pvc != nil {
101102
pvc.Spec.Selector = &metav1.LabelSelector{
102103
MatchLabels: map[string]string{
103-
plugin.LabelZoneFailureDomain: adLabel,
104+
v1.LabelTopologyZone: adLabel,
104105
},
105106
}
106107
}
@@ -686,7 +687,7 @@ func (j *PVCTestJig) NewPodForCSI(name string, namespace string, claimName strin
686687
return pod.Name
687688
}
688689

689-
// NewPodWithLabels returns the default template for this jig,
690+
// newPODTemplate returns the default template for this jig,
690691
// creates the Pod. Attaches PVC to the Pod which is created by CSI
691692
func (j *PVCTestJig) NewPodWithLabels(name string, namespace string, claimName string, labels map[string]string) string {
692693
By("Creating a pod with the claiming PVC created by CSI")
@@ -777,7 +778,7 @@ func (j *PVCTestJig) NewPodForCSIClone(name string, namespace string, claimName
777778
},
778779
},
779780
NodeSelector: map[string]string{
780-
plugin.LabelZoneFailureDomain: adLabel,
781+
v1.LabelTopologyZone: adLabel,
781782
},
782783
},
783784
}, metav1.CreateOptions{})
@@ -832,7 +833,7 @@ func (j *PVCTestJig) NewPodForCSIWithoutWait(name string, namespace string, clai
832833
},
833834
},
834835
NodeSelector: map[string]string{
835-
plugin.LabelZoneFailureDomain: adLabel,
836+
v1.LabelTopologyZone: adLabel,
836837
},
837838
},
838839
}, metav1.CreateOptions{})

0 commit comments

Comments
 (0)