Skip to content

Commit 0e9cce8

Browse files
authored
Merge pull request #1477 from amacaskill/automated-cherry-pick-of-#1338-upstream-release-1.8
Automated cherry pick of #1338: Always call LoggedError for errors returned from
2 parents e470f2d + 9eec8ea commit 0e9cce8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pkg/gce-pd-csi-driver/controller.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ func (gceCS *GCEControllerServer) executeControllerPublishVolume(ctx context.Con
583583
if gce.IsGCENotFoundError(err) {
584584
return nil, status.Errorf(codes.NotFound, "Could not find instance %v: %v", nodeID, err.Error()), diskType
585585
}
586-
return nil, status.Errorf(codes.Internal, "Failed to get instance: %v", err.Error()), diskType
586+
return nil, common.LoggedError("Failed to get instance: ", err), diskType
587587
}
588588

589589
readWrite := "READ_WRITE"
@@ -618,12 +618,12 @@ func (gceCS *GCEControllerServer) executeControllerPublishVolume(ctx context.Con
618618
machineType := parseMachineType(instance.MachineType)
619619
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
620620
}
621-
return nil, status.Errorf(codes.Internal, "Failed to Attach: %v", err.Error()), diskType
621+
return nil, common.LoggedError("Failed to Attach: ", err), diskType
622622
}
623623

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

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

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

0 commit comments

Comments
 (0)