Skip to content

Commit

Permalink
Merge pull request #1622 from k8s-infra-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…1620-to-release-1.13

[release-1.13] Fix error when no compute endpoint is passed
  • Loading branch information
k8s-ci-robot authored Feb 23, 2024
2 parents 24280ad + e063075 commit 0c94a69
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion cmd/gce-pd-csi-driver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,15 @@ func enumFlag(target *gce.Environment, name string, allowedComputeEnvironment []

func urlFlag(target **url.URL, name string, usage string) {
flag.Func(name, usage, func(flagValue string) error {
if flagValue == "" {
return nil
}
computeURL, err := url.ParseRequestURI(flagValue)
if err == nil {
*target = computeURL
return nil
}
klog.Infof("Error parsing endpoint compute endpoint %v", err)
klog.Errorf("Error parsing endpoint compute endpoint %v", err)
return err
})
}
10 changes: 10 additions & 0 deletions test/e2e/tests/single_zone_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,16 @@ var _ = Describe("GCE PD CSI Driver", func() {

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

// Create new driver and client with valid, empty endpoint
klog.Infof("Setup driver with empty compute endpoint %s\n", i.GetName())
tcEmpty, err := testutils.GCEClientAndDriverSetup(i, "")
if err != nil {
klog.Fatalf("Failed to set up Test Context for instance %v: %v", i.GetName(), err)
}
_, err = tcEmpty.Client.ListVolumes()

Expect(err).To(BeNil(), "no error expected when passed empty compute url")

// Create new driver and client w/ valid, passed-in endpoint
tcValid, err := testutils.GCEClientAndDriverSetup(i, "https://compute.googleapis.com")
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions test/e2e/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ func GCEClientAndDriverSetup(instance *remote.InstanceInfo, computeEndpoint stri
fmt.Sprintf("--extra-labels=%s=%s", DiskLabelKey, DiskLabelValue),
"--max-concurrent-format-and-mount=20", // otherwise the serialization times out the e2e test.
}
if computeEndpoint != "" {
extra_flags = append(extra_flags, fmt.Sprintf("--compute-endpoint %s", computeEndpoint))
}
extra_flags = append(extra_flags, fmt.Sprintf("--compute-endpoint=%s", computeEndpoint))

workspace := remote.NewWorkspaceDir("gce-pd-e2e-")
// Log at V(6) as the compute API calls are emitted at that level and it's
// useful to see what's happening when debugging tests.
Expand Down

0 comments on commit 0c94a69

Please sign in to comment.