mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
Add check to reduce orphaned volume
This commit is contained in:
parent
bd628bc792
commit
7c0b33e012
@ -1415,6 +1415,10 @@ func (ctrl *PersistentVolumeController) provisionClaimOperation(
|
|||||||
|
|
||||||
pvName := ctrl.getProvisionedVolumeNameForClaim(claim)
|
pvName := ctrl.getProvisionedVolumeNameForClaim(claim)
|
||||||
volume, err := ctrl.kubeClient.CoreV1().PersistentVolumes().Get(pvName, metav1.GetOptions{})
|
volume, err := ctrl.kubeClient.CoreV1().PersistentVolumes().Get(pvName, metav1.GetOptions{})
|
||||||
|
if err != nil && !apierrs.IsNotFound(err) {
|
||||||
|
klog.V(3).Infof("error reading persistent volume %q: %v", pvName, err)
|
||||||
|
return pluginName, err
|
||||||
|
}
|
||||||
if err == nil && volume != nil {
|
if err == nil && volume != nil {
|
||||||
// Volume has been already provisioned, nothing to do.
|
// Volume has been already provisioned, nothing to do.
|
||||||
klog.V(4).Infof("provisionClaimOperation [%s]: volume already exists, skipping", claimToClaimKey(claim))
|
klog.V(4).Infof("provisionClaimOperation [%s]: volume already exists, skipping", claimToClaimKey(claim))
|
||||||
|
@ -223,7 +223,7 @@ func (r *VolumeReactor) React(action core.Action) (handled bool, ret runtime.Obj
|
|||||||
return true, volume.DeepCopy(), nil
|
return true, volume.DeepCopy(), nil
|
||||||
}
|
}
|
||||||
klog.V(4).Infof("GetVolume: volume %s not found", name)
|
klog.V(4).Infof("GetVolume: volume %s not found", name)
|
||||||
return true, nil, fmt.Errorf("Cannot find volume %s", name)
|
return true, nil, apierrs.NewNotFound(action.GetResource().GroupResource(), name)
|
||||||
|
|
||||||
case action.Matches("get", "persistentvolumeclaims"):
|
case action.Matches("get", "persistentvolumeclaims"):
|
||||||
name := action.(core.GetAction).GetName()
|
name := action.(core.GetAction).GetName()
|
||||||
|
Loading…
Reference in New Issue
Block a user