Skip to content

Commit 198240c

Browse files
authored
Merge pull request #1474 from k8s-infra-cherrypick-robot/cherry-pick-1338-to-release-1.9
[release-1.9] Always call LoggedError for errors returned from CloudProvider methods
2 parents 087d0a0 + 5f2a9b5 commit 198240c

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
@@ -597,7 +597,7 @@ func (gceCS *GCEControllerServer) executeControllerPublishVolume(ctx context.Con
597597
if gce.IsGCENotFoundError(err) {
598598
return nil, status.Errorf(codes.NotFound, "Could not find instance %v: %v", nodeID, err.Error()), disk
599599
}
600-
return nil, status.Errorf(codes.Internal, "Failed to get instance: %v", err.Error()), disk
600+
return nil, common.LoggedError("Failed to get instance: ", err), disk
601601
}
602602

603603
readWrite := "READ_WRITE"
@@ -632,12 +632,12 @@ func (gceCS *GCEControllerServer) executeControllerPublishVolume(ctx context.Con
632632
machineType := parseMachineType(instance.MachineType)
633633
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), disk
634634
}
635-
return nil, status.Errorf(codes.Internal, "Failed to Attach: %v", err.Error()), disk
635+
return nil, common.LoggedError("Failed to Attach: ", err), disk
636636
}
637637

638638
err = gceCS.CloudProvider.WaitForAttach(ctx, project, volKey, instanceZone, instanceName)
639639
if err != nil {
640-
return nil, status.Errorf(codes.Internal, "Errored during WaitForAttach: %v", err.Error()), disk
640+
return nil, common.LoggedError("Errored during WaitForAttach: ", err), disk
641641
}
642642

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

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

0 commit comments

Comments
 (0)