diff --git a/changes/unreleased/Fixed-20220224-164528.yaml b/changes/unreleased/Fixed-20220224-164528.yaml new file mode 100644 index 000000000..4d6fcfcd6 --- /dev/null +++ b/changes/unreleased/Fixed-20220224-164528.yaml @@ -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" diff --git a/pkg/controllers/init_db.go b/pkg/controllers/init_db.go index 33cacf54b..c7b4c911c 100644 --- a/pkg/controllers/init_db.go +++ b/pkg/controllers/init_db.go @@ -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 @@ -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 diff --git a/pkg/controllers/init_db_test.go b/pkg/controllers/init_db_test.go index 02c8f50e7..4750d47d2 100644 --- a/pkg/controllers/init_db_test.go +++ b/pkg/controllers/init_db_test.go @@ -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() { @@ -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 {