Skip to content

Automated cherry pick of #1338: Always call LoggedError for errors returned from #1477

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

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
10 changes: 5 additions & 5 deletions pkg/gce-pd-csi-driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ func (gceCS *GCEControllerServer) executeControllerPublishVolume(ctx context.Con
if gce.IsGCENotFoundError(err) {
return nil, status.Errorf(codes.NotFound, "Could not find instance %v: %v", nodeID, err.Error()), diskType
}
return nil, status.Errorf(codes.Internal, "Failed to get instance: %v", err.Error()), diskType
return nil, common.LoggedError("Failed to get instance: ", err), diskType
}

readWrite := "READ_WRITE"
Expand Down Expand Up @@ -618,12 +618,12 @@ func (gceCS *GCEControllerServer) executeControllerPublishVolume(ctx context.Con
machineType := parseMachineType(instance.MachineType)
return nil, status.Errorf(codes.InvalidArgument, "'%s' is not a compatible disk type with the machine type %s, please review the GCP online documentation for available persistent disk options", udErr.DiskType, machineType), diskType
}
return nil, status.Errorf(codes.Internal, "Failed to Attach: %v", err.Error()), diskType
return nil, common.LoggedError("Failed to Attach: ", err), diskType
}

err = gceCS.CloudProvider.WaitForAttach(ctx, project, volKey, instanceZone, instanceName)
if err != nil {
return nil, status.Errorf(codes.Internal, "Errored during WaitForAttach: %v", err.Error()), diskType
return nil, common.LoggedError("Errored during WaitForAttach: ", err), diskType
}

klog.V(4).Infof("ControllerPublishVolume succeeded for disk %v to instance %v", volKey, nodeID)
Expand Down Expand Up @@ -715,7 +715,7 @@ func (gceCS *GCEControllerServer) executeControllerUnpublishVolume(ctx context.C
klog.Warningf("Treating volume %v as unpublished because node %v could not be found", volKey.String(), instanceName)
return &csi.ControllerUnpublishVolumeResponse{}, nil, diskType
}
return nil, status.Errorf(codes.Internal, "error getting instance: %v", err.Error()), diskType
return nil, common.LoggedError("error getting instance: ", err), diskType
}

deviceName, err := common.GetDeviceName(volKey)
Expand Down Expand Up @@ -965,7 +965,7 @@ func (gceCS *GCEControllerServer) createPDSnapshot(ctx context.Context, project
snapshot, err = gceCS.CloudProvider.GetSnapshot(ctx, project, snapshotName)
if err != nil {
if !gce.IsGCEError(err, "notFound") {
return nil, status.Errorf(codes.Internal, "Failed to get snapshot: %v", err.Error())
return nil, common.LoggedError("Failed to get snapshot: ", err)
}
// If we could not find the snapshot, we create a new one
snapshot, err = gceCS.CloudProvider.CreateSnapshot(ctx, project, volKey, snapshotName, snapshotParams)
Expand Down