Skip to content

Commit ee85b6a

Browse files
committed
Don't report deletion of attached volume as warning
It is part of normal cluster operation. When a pod and PVC are deleted at the same time (e.g. because of the whole namespace was deleted), PV controller may try to delete a volume that is still detached. "Warning" is too strong here, it is going to heal relatively quickly.
1 parent cfdc365 commit ee85b6a

File tree

2 files changed

+15
-1
lines changed
  • staging/src/k8s.io

2 files changed

+15
-1
lines changed

staging/src/k8s.io/cloud-provider/volume/errors/errors.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,13 @@ func NewDanglingError(msg string, node k8stypes.NodeName, devicePath string) err
6565
DevicePath: devicePath,
6666
}
6767
}
68+
69+
// IsDanglingError returns true if an error is DanglingAttachError
70+
func IsDanglingError(err error) bool {
71+
switch err.(type) {
72+
case *DanglingAttachError:
73+
return true
74+
default:
75+
return false
76+
}
77+
}

staging/src/k8s.io/legacy-cloud-providers/aws/aws.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2578,6 +2578,10 @@ func (c *Cloud) DeleteDisk(volumeName KubernetesVolumeID) (bool, error) {
25782578
klog.V(2).Infof("Volume %s not found when deleting it, assuming it's deleted", awsDisk.awsID)
25792579
return false, nil
25802580
}
2581+
if volerr.IsDanglingError(err) {
2582+
// The volume is still attached somewhere
2583+
return false, volerr.NewDeletedVolumeInUseError(err.Error())
2584+
}
25812585
klog.Error(err)
25822586
}
25832587

@@ -2598,7 +2602,7 @@ func (c *Cloud) checkIfAvailable(disk *awsDisk, opName string, instance string)
25982602
}
25992603

26002604
volumeState := aws.StringValue(info.State)
2601-
opError := fmt.Sprintf("Error %s EBS volume %q", opName, disk.awsID)
2605+
opError := fmt.Sprintf("error %s EBS volume %q", opName, disk.awsID)
26022606
if len(instance) != 0 {
26032607
opError = fmt.Sprintf("%q to instance %q", opError, instance)
26042608
}

0 commit comments

Comments
 (0)