Skip to content

Commit

Permalink
controller: add logs to catch some weird issues
Browse files Browse the repository at this point in the history
The API might return 422 for various kind of situations. However we
don't return an error and there is a possibility an attach/dettach could
fail. Let us log the error and response to see if there is anything we
can do fix stuff on our side.
  • Loading branch information
fatih committed Jun 8, 2018
1 parent 3c0a9b0 commit 7b4ebcd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ func (d *Driver) ControllerPublishVolume(ctx context.Context, req *csi.Controlle
if err != nil {
// don't do anything if attached
if (resp != nil && resp.StatusCode == http.StatusUnprocessableEntity) || strings.Contains(err.Error(), "This volume is already attached") {
ll.WithFields(logrus.Fields{
"error": err,
"resp": resp,
}).Warn("assuming volume is attached already")
return &csi.ControllerPublishVolumeResponse{}, nil
}
return nil, err
Expand Down Expand Up @@ -229,6 +233,10 @@ func (d *Driver) ControllerUnpublishVolume(ctx context.Context, req *csi.Control
action, resp, err := d.doClient.StorageActions.DetachByDropletID(ctx, req.VolumeId, dropletID)
if err != nil {
if (resp != nil && resp.StatusCode == http.StatusUnprocessableEntity) || strings.Contains(err.Error(), "Attachment not found") {
ll.WithFields(logrus.Fields{
"error": err,
"resp": resp,
}).Warn("assuming volume is dettached already")
return &csi.ControllerUnpublishVolumeResponse{}, nil
}
return nil, err
Expand Down

0 comments on commit 7b4ebcd

Please sign in to comment.