Skip to content

Commit f41ca87

Browse files
committed
ensure that volumes get rescheduled when fake capacity is exhausted
The driver must return ResourceExhausted when it doesn't have capacity, not OutOfRange. Then external-provisioner knows that it needs to cause rescheduling. Also, that error must not get wrapped because that hides the status code. The incorrect code bug was introduced in 6ad3189 via cut-and-paste. For the case above where the volume is too large for *all* driver instances because it exceeds the configured maximum volume size it makes sense to return OutOfRange because the error is permanent.
1 parent c480b67 commit f41ca87

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

pkg/hostpath/controllerserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (hp *hostPath) CreateVolume(ctx context.Context, req *csi.CreateVolumeReque
139139
kind := req.GetParameters()[storageKind]
140140
vol, err := hp.createVolume(volumeID, req.GetName(), capacity, requestedAccessType, false /* ephemeral */, kind)
141141
if err != nil {
142-
return nil, fmt.Errorf("failed to create volume %v: %w", volumeID, err)
142+
return nil, err
143143
}
144144
glog.V(4).Infof("created volume %s at path %s", vol.VolID, vol.VolPath)
145145

pkg/hostpath/hostpath.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,12 @@ func (hp *hostPath) createVolume(volID, name string, cap int64, volAccessType st
157157
}
158158
if kind == "" {
159159
// Still nothing?!
160-
return nil, status.Errorf(codes.OutOfRange, "requested capacity %d of arbitrary storage exceeds all remaining capacity", cap)
160+
return nil, status.Errorf(codes.ResourceExhausted, "requested capacity %d of arbitrary storage exceeds all remaining capacity", cap)
161161
}
162162
used := hp.sumVolumeSizes(kind)
163163
available := hp.config.Capacity[kind]
164164
if used+cap > available.Value() {
165-
166-
return nil, status.Errorf(codes.OutOfRange, "requested capacity %d exceeds remaining capacity for %q, %s out of %s already used",
165+
return nil, status.Errorf(codes.ResourceExhausted, "requested capacity %d exceeds remaining capacity for %q, %s out of %s already used",
167166
cap, kind, resource.NewQuantity(used, resource.BinarySI).String(), available.String())
168167
}
169168
} else if kind != "" {

0 commit comments

Comments
 (0)