From 3b0ddbf07ea75e21a48211583d0509a980eead90 Mon Sep 17 00:00:00 2001 From: Martin Vladev Date: Wed, 31 Oct 2018 01:57:40 +0200 Subject: [PATCH] fix openstack provider to handle only Cinder volumes When the cloud-controller-manager is running with PV label initializing controller and NFS volume is created, it causes nill reference error. related to #68996 --- pkg/cloudprovider/providers/openstack/openstack_volumes.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/cloudprovider/providers/openstack/openstack_volumes.go b/pkg/cloudprovider/providers/openstack/openstack_volumes.go index c3a81465301..d3e5cf1d3b6 100644 --- a/pkg/cloudprovider/providers/openstack/openstack_volumes.go +++ b/pkg/cloudprovider/providers/openstack/openstack_volumes.go @@ -697,6 +697,11 @@ func (os *OpenStack) ShouldTrustDevicePath() bool { // GetLabelsForVolume implements PVLabeler.GetLabelsForVolume func (os *OpenStack) GetLabelsForVolume(ctx context.Context, pv *v1.PersistentVolume) (map[string]string, error) { + // Ignore if not Cinder. + if pv.Spec.Cinder == nil { + return nil, nil + } + // Ignore any volumes that are being provisioned if pv.Spec.Cinder.VolumeID == k8s_volume.ProvisionedVolumeName { return nil, nil