Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-1.26] fix: improve disk attach/detach error message #2104

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions pkg/azuredisk/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import (
const (
waitForSnapshotCopyInterval = 5 * time.Second
waitForSnapshotCopyTimeout = 10 * time.Minute
maxErrMsgLength = 990
)

// listVolumeStatus explains the return status of `listVolumesByResourceGroup`
Expand Down Expand Up @@ -445,7 +446,11 @@ func (d *Driver) ControllerPublishVolume(ctx context.Context, req *csi.Controlle
}
if err != nil {
klog.Errorf("Attach volume %s to instance %s failed with %v", diskURI, nodeName, err)
return nil, status.Errorf(codes.Internal, "Attach volume %s to instance %s failed with %v", diskURI, nodeName, err)
errMsg := fmt.Sprintf("Attach volume %s to instance %s failed with %v", diskURI, nodeName, err)
if len(errMsg) > maxErrMsgLength {
errMsg = errMsg[:maxErrMsgLength]
}
return nil, status.Errorf(codes.Internal, errMsg)
}
}
klog.V(2).Infof("attach volume %s to node %s successfully", diskURI, nodeName)
Expand Down Expand Up @@ -492,7 +497,12 @@ func (d *Driver) ControllerUnpublishVolume(ctx context.Context, req *csi.Control
if strings.Contains(err.Error(), consts.ErrDiskNotFound) {
klog.Warningf("volume %s already detached from node %s", diskURI, nodeID)
} else {
return nil, status.Errorf(codes.Internal, "Could not detach volume %s from node %s: %v", diskURI, nodeID, err)
klog.Errorf("Could not detach volume %s from node %s: %v", diskURI, nodeID, err)
errMsg := fmt.Sprintf("Could not detach volume %s from node %s: %v", diskURI, nodeID, err)
if len(errMsg) > maxErrMsgLength {
errMsg = errMsg[:maxErrMsgLength]
}
return nil, status.Errorf(codes.Internal, errMsg)
}
}
klog.V(2).Infof("detach volume %s from node %s successfully", diskURI, nodeID)
Expand Down
Loading