Skip to content

Commit 441642a

Browse files
authored
Merge pull request #1381 from k8s-infra-cherrypick-robot/cherry-pick-1338-to-release-1.10
[release-1.10] Always call LoggedError for errors returned from CloudProvider methods
2 parents 0285da2 + eb5b25e commit 441642a

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
@@ -612,7 +612,7 @@ func (gceCS *GCEControllerServer) executeControllerPublishVolume(ctx context.Con
612612
if gce.IsGCENotFoundError(err) {
613613
return nil, status.Errorf(codes.NotFound, "Could not find instance %v: %v", nodeID, err.Error()), disk
614614
}
615-
return nil, status.Errorf(codes.Internal, "Failed to get instance: %v", err.Error()), disk
615+
return nil, common.LoggedError("Failed to get instance: ", err), disk
616616
}
617617

618618
readWrite := "READ_WRITE"
@@ -647,12 +647,12 @@ func (gceCS *GCEControllerServer) executeControllerPublishVolume(ctx context.Con
647647
machineType := parseMachineType(instance.MachineType)
648648
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
649649
}
650-
return nil, status.Errorf(codes.Internal, "Failed to Attach: %v", err.Error()), disk
650+
return nil, common.LoggedError("Failed to Attach: ", err), disk
651651
}
652652

653653
err = gceCS.CloudProvider.WaitForAttach(ctx, project, volKey, instanceZone, instanceName)
654654
if err != nil {
655-
return nil, status.Errorf(codes.Internal, "Errored during WaitForAttach: %v", err.Error()), disk
655+
return nil, common.LoggedError("Errored during WaitForAttach: ", err), disk
656656
}
657657

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

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

0 commit comments

Comments
 (0)