Skip to content

Commit b5f9b20

Browse files
committed
finished error detection when API rejects the attach request
Signed-off-by: Niclas Schad <niclas.schad@stackit.cloud>
1 parent 127f8d7 commit b5f9b20

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

pkg/csi/blockstorage/controllerserver.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,9 @@ func (cs *controllerServer) ControllerPublishVolume(ctx context.Context, req *cs
371371
_, err = cloud.AttachVolume(ctx, instanceID, volumeID)
372372
if err != nil {
373373
// Trigger's an immediate `NodeGetInfo` RPC call when MutableCSINodeAllocatableCount is enabled
374-
// TODO: Finish Implementation of IsTooManyDevicesError
375-
//if stackiterrors.IsTooManyDevicesError(err) {
376-
// return nil, status.Errorf(codes.ResourceExhausted, "[ControllerPublishVolume] Node can't accept any more volumes %v. All PCIe lanes are exhausted!", err)
377-
//}
374+
if stackiterrors.IsTooManyDevicesError(err) {
375+
return nil, status.Errorf(codes.ResourceExhausted, "[ControllerPublishVolume] Node can't accept any more volumes %v. All PCIe lanes are exhausted!", err)
376+
}
378377
klog.Errorf("Failed to AttachVolume: %v", err)
379378
return nil, status.Errorf(codes.Internal, "[ControllerPublishVolume] Attach Volume failed with error %v", err)
380379
}

pkg/stackit/stackiterrors/errors.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ func IsTooManyDevicesError(err error) bool {
2727
return false
2828
}
2929

30-
// TODO: This is just a placeholder. Implement this correctly
31-
return oAPIError.StatusCode == http.StatusInternalServerError &&
32-
strings.Contains(oAPIError.ErrorMessage, "devices")
30+
// TODO: Improve this if possible
31+
return oAPIError.StatusCode == http.StatusForbidden &&
32+
strings.Contains(oAPIError.ErrorMessage, "maximum allowed number of disk devices")
3333
}
3434

3535
func IgnoreNotFound(err error) error {

0 commit comments

Comments
 (0)