Skip to content
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

Fix bug to support Endpoints with trailing slashes #161

Merged
merged 3 commits into from
Feb 25, 2022
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: 5 additions & 0 deletions changes/unreleased/Fixed-20220224-164528.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: Fixed
body: Tolerate slashes being at the end of the communal endpoint url
time: 2022-02-24T16:45:28.95511728-05:00
custom:
Issue: "161"
4 changes: 2 additions & 2 deletions pkg/controllers/init_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ func (g *GenericDatabaseInitializer) getCommunalEndpoint() string {
prefix := []string{"https://", "http://"}
for _, pref := range prefix {
if i := strings.Index(g.Vdb.Spec.Communal.Endpoint, pref); i == 0 {
return g.Vdb.Spec.Communal.Endpoint[len(pref):]
return strings.TrimSuffix(g.Vdb.Spec.Communal.Endpoint[len(pref):], "/")
}
}
return g.Vdb.Spec.Communal.Endpoint
Expand Down Expand Up @@ -491,7 +491,7 @@ func getEndpointHostPort(blobEndpoint string) string {
if len(m) == 0 || len(m[0]) < 3 {
return blobEndpoint
}
return m[0][2]
return strings.TrimSuffix(m[0][2], "/")
}

// getHadoopConfDir gets the string to include in the auth parms for
Expand Down
10 changes: 10 additions & 0 deletions pkg/controllers/init_db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,19 @@ var _ = Describe("init_db", func() {
}

Expect(g.getCommunalEndpoint()).Should(Equal("192.168.0.1"))

Expect(g.getEnableHTTPS()).Should(Equal("1"))

vdb.Spec.Communal.Endpoint = "http://fqdn.example.com:8080"

Expect(g.getCommunalEndpoint()).Should(Equal("fqdn.example.com:8080"))
Expect(g.getEnableHTTPS()).Should(Equal("0"))

vdb.Spec.Communal.Endpoint = "https://minio/"
Expect(g.getCommunalEndpoint()).Should(Equal("minio"))

vdb.Spec.Communal.Endpoint = "https://minio:3000/"
Expect(g.getCommunalEndpoint()).Should(Equal("minio:3000"))
})

It("should fail to get host list if some pods not running", func() {
Expand Down Expand Up @@ -199,7 +206,10 @@ var _ = Describe("init_db", func() {
Expect(getEndpointHostPort("http://hostname")).Should(Equal("hostname"))
Expect(getEndpointHostPort("https://tlsHost:3000")).Should(Equal("tlsHost:3000"))
Expect(getEndpointHostPort("account@myhost")).Should(Equal("account@myhost"))
Expect(getEndpointHostPort("azb://account/container/db/")).Should(Equal("account/container/db"))

})

})

func contructAuthParmsHelper(ctx context.Context, vdb *vapi.VerticaDB, mustHaveCmd string) []cmds.CmdHistory {
Expand Down