Fix csi sanity check - idempotent
* Fix occasion failures cause by volume still being
deleted.
```
Action [attach] not available on [&{sanity-node-full-2b264483-80559138 volume map[self:http://longhorn-backend:9500/v1/volumes/sanity-node-full-2b264483-80559138] map[]}]
```
```
Attaching volume sanity-controller-publish-2b264483-80559 on node ip-172-30-0-21 failed
```
@@ -236,6 +236,10 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
return nil, status.Error(codes.Internal, err.Error())
}
+ if !cs.waitForVolumeState(req.GetVolumeId(), "deleted", isVolumeDeleted, false, true) {
+ return nil, status.Errorf(codes.Aborted, "Failed to delete volume %s", req.GetVolumeId())
+ }
+
return &csi.DeleteVolumeResponse{}, nil
}
@@ -717,6 +721,10 @@ func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi
}, nil
}
+func isVolumeDeleted(vol *longhornclient.Volume) bool {
+ return vol == nil
+}
+
func isVolumeDetached(vol *longhornclient.Volume) bool {
return vol.State == string(types.VolumeStateDetached)
}
