From f49634719c89be0adbfdd7422b27a2a8fd031787 Mon Sep 17 00:00:00 2001 From: houjun Date: Mon, 6 Nov 2017 15:23:19 +0800 Subject: [PATCH] Should return when claim.Spec.VolumeName is null --- .../volume/persistentvolume/pv_controller_base.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/controller/volume/persistentvolume/pv_controller_base.go b/pkg/controller/volume/persistentvolume/pv_controller_base.go index f40086a8031..2ba5d831cbd 100644 --- a/pkg/controller/volume/persistentvolume/pv_controller_base.go +++ b/pkg/controller/volume/persistentvolume/pv_controller_base.go @@ -243,11 +243,15 @@ func (ctrl *PersistentVolumeController) deleteClaim(claim *v1.PersistentVolumeCl _ = ctrl.claims.Delete(claim) glog.V(4).Infof("claim %q deleted", claimToClaimKey(claim)) + volumeName := claim.Spec.VolumeName + if volumeName == "" { + glog.V(5).Infof("deleteClaim[%q]: volume not bound", claimToClaimKey(claim)) + return + } // sync the volume when its claim is deleted. Explicitly sync'ing the // volume here in response to claim deletion prevents the volume from // waiting until the next sync period for its Release. - volumeName := claim.Spec.VolumeName - glog.V(5).Infof("deleteClaim[%s]: scheduling sync of volume %q", claimToClaimKey(claim), volumeName) + glog.V(5).Infof("deleteClaim[%q]: scheduling sync of volume %s", claimToClaimKey(claim), volumeName) ctrl.volumeQueue.Add(volumeName) }