Skip to content

Commit e063075

Browse files
Sneha-atk8s-infra-cherrypick-robot
authored and
k8s-infra-cherrypick-robot
committed
Update to handle when no compute endpoint is passed
1 parent 24280ad commit e063075

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

cmd/gce-pd-csi-driver/main.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,15 @@ func enumFlag(target *gce.Environment, name string, allowedComputeEnvironment []
239239

240240
func urlFlag(target **url.URL, name string, usage string) {
241241
flag.Func(name, usage, func(flagValue string) error {
242+
if flagValue == "" {
243+
return nil
244+
}
242245
computeURL, err := url.ParseRequestURI(flagValue)
243246
if err == nil {
244247
*target = computeURL
245248
return nil
246249
}
247-
klog.Infof("Error parsing endpoint compute endpoint %v", err)
250+
klog.Errorf("Error parsing endpoint compute endpoint %v", err)
248251
return err
249252
})
250253
}

test/e2e/tests/single_zone_e2e_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,16 @@ var _ = Describe("GCE PD CSI Driver", func() {
12951295

12961296
klog.Infof("Creating new driver and client for node %s\n", i.GetName())
12971297

1298+
// Create new driver and client with valid, empty endpoint
1299+
klog.Infof("Setup driver with empty compute endpoint %s\n", i.GetName())
1300+
tcEmpty, err := testutils.GCEClientAndDriverSetup(i, "")
1301+
if err != nil {
1302+
klog.Fatalf("Failed to set up Test Context for instance %v: %v", i.GetName(), err)
1303+
}
1304+
_, err = tcEmpty.Client.ListVolumes()
1305+
1306+
Expect(err).To(BeNil(), "no error expected when passed empty compute url")
1307+
12981308
// Create new driver and client w/ valid, passed-in endpoint
12991309
tcValid, err := testutils.GCEClientAndDriverSetup(i, "https://compute.googleapis.com")
13001310
if err != nil {

test/e2e/utils/utils.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ func GCEClientAndDriverSetup(instance *remote.InstanceInfo, computeEndpoint stri
5757
fmt.Sprintf("--extra-labels=%s=%s", DiskLabelKey, DiskLabelValue),
5858
"--max-concurrent-format-and-mount=20", // otherwise the serialization times out the e2e test.
5959
}
60-
if computeEndpoint != "" {
61-
extra_flags = append(extra_flags, fmt.Sprintf("--compute-endpoint %s", computeEndpoint))
62-
}
60+
extra_flags = append(extra_flags, fmt.Sprintf("--compute-endpoint=%s", computeEndpoint))
61+
6362
workspace := remote.NewWorkspaceDir("gce-pd-e2e-")
6463
// Log at V(6) as the compute API calls are emitted at that level and it's
6564
// useful to see what's happening when debugging tests.

0 commit comments

Comments
 (0)