Skip to content

[release-1.13] Fix error when no compute endpoint is passed #1622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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