From 15a91a0705780bb99dae508892ef3c6cf7f1a007 Mon Sep 17 00:00:00 2001 From: Karl Johan Grahn Date: Mon, 9 Dec 2024 14:13:24 +0100 Subject: [PATCH 01/14] update --- pkg/kube/wrappers/routeWrapper.go | 6 +++--- pkg/kube/wrappers/routeWrapper_test.go | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pkg/kube/wrappers/routeWrapper.go b/pkg/kube/wrappers/routeWrapper.go index 72342dd9..e30e7ef3 100644 --- a/pkg/kube/wrappers/routeWrapper.go +++ b/pkg/kube/wrappers/routeWrapper.go @@ -116,17 +116,17 @@ func (rw *RouteWrapper) GetURL(forceHttps bool, healthEndpoint string) string { } if len(healthEndpoint) != 0 { - u.Path = healthEndpoint + u.EscapedPath = healthEndpoint } else { // Append subpath - u.Path = path.Join(u.Path, rw.getRouteSubPath()) + u.EscapedPath = path.Join(u.EscapedPath, rw.getRouteSubPath()) // Find pod by backtracking route -> service -> pod healthEndpoint, exists := rw.tryGetHealthEndpointFromRoute() // Health endpoint from pod successful if exists { - u.Path = path.Join(u.Path, healthEndpoint) + u.EscapedPath = path.Join(u.EscapedPath, healthEndpoint) } } return u.String() diff --git a/pkg/kube/wrappers/routeWrapper_test.go b/pkg/kube/wrappers/routeWrapper_test.go index cfd5fee4..d06c16df 100644 --- a/pkg/kube/wrappers/routeWrapper_test.go +++ b/pkg/kube/wrappers/routeWrapper_test.go @@ -53,6 +53,14 @@ func TestRouteWrapper_getURL(t *testing.T) { }, want: "http://testurl.stackator.com/hello", }, + { + name: "TestGetUrlWithParams", + fields: fields{ + route: createRouteObjectWithPath("testRoute", "test", routeTestUrl, "/health?standbyok=true&sealedcode=204&uninitcode=204"), + Client: fakekubeclient.NewClientBuilder().Build(), + }, + want: "http://testurl.stackator.com/health?standbyok=true&sealedcode=204&uninitcode=204", + }, { name: "TestGetUrlWithNoPath", fields: fields{ From 3ce0130ae18fbeb61b317a994b4d4c548129b4b1 Mon Sep 17 00:00:00 2001 From: Karl Johan Grahn Date: Mon, 9 Dec 2024 15:26:18 +0100 Subject: [PATCH 02/14] update --- .github/workflows/pull_request.yml | 40 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index a2281ae7..6c03d92e 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -50,26 +50,26 @@ jobs: run: | helm lint charts/ingressmonitorcontroller - # - name: Install kind - # uses: engineerd/setup-kind@v0.5.0 - # with: - # version: ${{ env.KIND_VERSION }} - - # - name: Check cluster info - # run: | - # kubectl version --client - # kind version - # kind version | grep -q ${KIND_VERSION} - - # - name: Set up Cluster - # run: | - # kubectl cluster-info - # make install - # mkdir -p .local - # echo "${{ secrets.IMC_GITHUB_PIPELINE_CONFIG_ENCODED }}" | base64 --decode > .local/test-config.yaml - - # - name: Test - # run: make test + - name: Install kind + uses: engineerd/setup-kind@v0.5.0 + with: + version: ${{ env.KIND_VERSION }} + + - name: Check cluster info + run: | + kubectl version --client + kind version + kind version | grep -q ${KIND_VERSION} + + - name: Set up Cluster + run: | + kubectl cluster-info + make install + mkdir -p .local + echo "${{ secrets.IMC_GITHUB_PIPELINE_CONFIG_ENCODED }}" | base64 --decode > .local/test-config.yaml + + - name: Test + run: make test - name: Generate Tag id: generate_tag From c863757df76f2271dfac4768a124c6fd0c38158b Mon Sep 17 00:00:00 2001 From: Karl Johan Grahn Date: Sun, 15 Dec 2024 22:56:06 +0100 Subject: [PATCH 03/14] update --- .github/workflows/pull_request.yml | 23 --------- .github/workflows/pull_request_test.yaml | 61 ++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/pull_request_test.yaml diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 774d4c7f..e0c2fd5a 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -14,7 +14,6 @@ env: DOCKER_FILE_PATH: Dockerfile GOLANG_VERSION: 1.21 HELM_VERSION: v3.8.2 - KIND_VERSION: "v0.17.0" REGISTRY: ghcr.io jobs: @@ -50,27 +49,6 @@ jobs: run: | helm lint charts/ingressmonitorcontroller - - name: Install kind - uses: engineerd/setup-kind@v0.5.0 - with: - version: ${{ env.KIND_VERSION }} - - - name: Check cluster info - run: | - kubectl version --client - kind version - kind version | grep -q ${KIND_VERSION} - - - name: Set up Cluster - run: | - kubectl cluster-info - make install - mkdir -p .local - echo "${{ secrets.IMC_GITHUB_PIPELINE_CONFIG_ENCODED }}" | base64 --decode > .local/test-config.yaml - - - name: Test - run: make test - - name: Generate Tag id: generate_tag run: | @@ -107,5 +85,4 @@ jobs: ${{ env.GHCR_IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.GIT_TAG }} labels: | org.opencontainers.image.source=${{ github.event.repository.clone_url }} - org.opencontainers.image.created=${{ steps.prep.outputs.created }} org.opencontainers.image.revision=${{ github.sha }} diff --git a/.github/workflows/pull_request_test.yaml b/.github/workflows/pull_request_test.yaml new file mode 100644 index 00000000..efda6799 --- /dev/null +++ b/.github/workflows/pull_request_test.yaml @@ -0,0 +1,61 @@ +name: Run Tests on PR Label + +on: + pull_request: + branches: + - 'master' + paths-ignore: + - '*.md' + - 'docs/' + - 'examples/' + - 'hack/' + - 'config/' + types: [ labeled ] + +env: + KIND_VERSION: "0.23.0" + GOLANG_VERSION: 1.21 + +jobs: + + test: + runs-on: ubuntu-latest + name: Test + if: ${{ github.event.label.name == 'ok-to-test' }} + steps: + + - name: Remove the test label + uses: actions-ecosystem/action-remove-labels@v1 + with: + labels: ok-to-test + + - name: Check out code + uses: actions/checkout@v4 + with: + ref: ${{github.event.pull_request.head.sha}} + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GOLANG_VERSION }} + + - name: Install kind + uses: engineerd/setup-kind@v0.5.0 + with: + version: ${{ env.KIND_VERSION }} + + - name: Check cluster info + run: | + kubectl version --client + kind version + kind version | grep -q ${KIND_VERSION} + + - name: Set up Cluster + run: | + kubectl cluster-info + make install + mkdir -p .local + echo "${{ secrets.IMC_GITHUB_PIPELINE_CONFIG_ENCODED }}" | base64 --decode > .local/test-config.yaml + + - name: Test + run: make test From 82cb916e116e5ee72fbf0901ed2d4c4d0ea0c2d1 Mon Sep 17 00:00:00 2001 From: Karl Johan Grahn Date: Sun, 15 Dec 2024 23:47:19 +0100 Subject: [PATCH 04/14] update --- pkg/kube/wrappers/routeWrapper.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/kube/wrappers/routeWrapper.go b/pkg/kube/wrappers/routeWrapper.go index e30e7ef3..0f30dadc 100644 --- a/pkg/kube/wrappers/routeWrapper.go +++ b/pkg/kube/wrappers/routeWrapper.go @@ -116,17 +116,17 @@ func (rw *RouteWrapper) GetURL(forceHttps bool, healthEndpoint string) string { } if len(healthEndpoint) != 0 { - u.EscapedPath = healthEndpoint + u.EscapedPath() = healthEndpoint } else { // Append subpath - u.EscapedPath = path.Join(u.EscapedPath, rw.getRouteSubPath()) + u.EscapedPath() = path.Join(u.EscapedPath(), rw.getRouteSubPath()) // Find pod by backtracking route -> service -> pod healthEndpoint, exists := rw.tryGetHealthEndpointFromRoute() // Health endpoint from pod successful if exists { - u.EscapedPath = path.Join(u.EscapedPath, healthEndpoint) + u.EscapedPath() = path.Join(u.EscapedPath(), healthEndpoint) } } return u.String() From 0d1a41c8262632c9c0ee3cb529806bf50eade1f2 Mon Sep 17 00:00:00 2001 From: Karl Johan Grahn Date: Sun, 15 Dec 2024 23:50:35 +0100 Subject: [PATCH 05/14] update --- pkg/kube/wrappers/routeWrapper.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/kube/wrappers/routeWrapper.go b/pkg/kube/wrappers/routeWrapper.go index 0f30dadc..e2f409af 100644 --- a/pkg/kube/wrappers/routeWrapper.go +++ b/pkg/kube/wrappers/routeWrapper.go @@ -116,17 +116,17 @@ func (rw *RouteWrapper) GetURL(forceHttps bool, healthEndpoint string) string { } if len(healthEndpoint) != 0 { - u.EscapedPath() = healthEndpoint + u.Path = healthEndpoint } else { // Append subpath - u.EscapedPath() = path.Join(u.EscapedPath(), rw.getRouteSubPath()) + u.Path = path.Join(u.EscapedPath(), rw.getRouteSubPath()) // Find pod by backtracking route -> service -> pod healthEndpoint, exists := rw.tryGetHealthEndpointFromRoute() // Health endpoint from pod successful if exists { - u.EscapedPath() = path.Join(u.EscapedPath(), healthEndpoint) + u.Path = path.Join(u.EscapedPath(), healthEndpoint) } } return u.String() From ecf530740c7472c347f22b7cf9691232247d5323 Mon Sep 17 00:00:00 2001 From: Karl Johan Grahn Date: Mon, 16 Dec 2024 11:56:06 +0100 Subject: [PATCH 06/14] update --- .github/workflows/pull_request_test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request_test.yaml b/.github/workflows/pull_request_test.yaml index efda6799..eada7897 100644 --- a/.github/workflows/pull_request_test.yaml +++ b/.github/workflows/pull_request_test.yaml @@ -13,7 +13,7 @@ on: types: [ labeled ] env: - KIND_VERSION: "0.23.0" + KIND_VERSION: "v0.25.0" GOLANG_VERSION: 1.21 jobs: From 2484918db9c090be386fd57bb7ef5cd118e59752 Mon Sep 17 00:00:00 2001 From: Karl Johan Grahn Date: Mon, 16 Dec 2024 11:57:30 +0100 Subject: [PATCH 07/14] update --- .github/workflows/pull_request_test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_request_test.yaml b/.github/workflows/pull_request_test.yaml index eada7897..ce142aec 100644 --- a/.github/workflows/pull_request_test.yaml +++ b/.github/workflows/pull_request_test.yaml @@ -21,7 +21,7 @@ jobs: test: runs-on: ubuntu-latest name: Test - if: ${{ github.event.label.name == 'ok-to-test' }} + if: ${{ github.event.label.name == 'ok-to-test' }} steps: - name: Remove the test label @@ -42,7 +42,7 @@ jobs: - name: Install kind uses: engineerd/setup-kind@v0.5.0 with: - version: ${{ env.KIND_VERSION }} + version: ${{ env.KIND_VERSION }} - name: Check cluster info run: | From fe15ed7921f0157a2b18fe719de96a7dd739f334 Mon Sep 17 00:00:00 2001 From: Karl Johan Grahn Date: Mon, 16 Dec 2024 18:51:55 +0100 Subject: [PATCH 08/14] update --- pkg/kube/wrappers/routeWrapper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kube/wrappers/routeWrapper.go b/pkg/kube/wrappers/routeWrapper.go index e2f409af..b656652a 100644 --- a/pkg/kube/wrappers/routeWrapper.go +++ b/pkg/kube/wrappers/routeWrapper.go @@ -49,7 +49,7 @@ func (rw *RouteWrapper) getHost() string { } func (rw *RouteWrapper) getRouteSubPath() string { - return rw.Route.Spec.Path + return rw.Route.Spec.EscapedPath() } func (rw *RouteWrapper) hasService() (string, bool) { From 4f35b3b6229cf66abc47869b8a0ec02a7811b2c1 Mon Sep 17 00:00:00 2001 From: Karl Johan Grahn Date: Mon, 16 Dec 2024 19:16:03 +0100 Subject: [PATCH 09/14] update --- pkg/kube/wrappers/routeWrapper.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/kube/wrappers/routeWrapper.go b/pkg/kube/wrappers/routeWrapper.go index b656652a..ce9734c1 100644 --- a/pkg/kube/wrappers/routeWrapper.go +++ b/pkg/kube/wrappers/routeWrapper.go @@ -49,7 +49,7 @@ func (rw *RouteWrapper) getHost() string { } func (rw *RouteWrapper) getRouteSubPath() string { - return rw.Route.Spec.EscapedPath() + return rw.Route.Spec.Path } func (rw *RouteWrapper) hasService() (string, bool) { @@ -106,9 +106,12 @@ func (rw *RouteWrapper) GetURL(forceHttps bool, healthEndpoint string) string { } else { URL = rw.getHost() // Fallback for normal Host } + log.Info(fmt.Sprintf("URL: %s", URL)) // Convert url to url object u, err := url.Parse(URL) + log.Info(fmt.Sprintf("u.Path: %s", u.Path)) + log.Info(fmt.Sprintf("rw.getRouteSubPath(): %s", rw.getRouteSubPath())) if err != nil { log.Info(fmt.Sprintf("URL parsing error in getURL() :%v", err)) From 9a7b0664e978d6748e01b322bef92dcf3ab16e93 Mon Sep 17 00:00:00 2001 From: Karl Johan Grahn Date: Mon, 16 Dec 2024 19:25:19 +0100 Subject: [PATCH 10/14] update --- pkg/kube/wrappers/routeWrapper.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/kube/wrappers/routeWrapper.go b/pkg/kube/wrappers/routeWrapper.go index ce9734c1..4394fdd9 100644 --- a/pkg/kube/wrappers/routeWrapper.go +++ b/pkg/kube/wrappers/routeWrapper.go @@ -106,11 +106,9 @@ func (rw *RouteWrapper) GetURL(forceHttps bool, healthEndpoint string) string { } else { URL = rw.getHost() // Fallback for normal Host } - log.Info(fmt.Sprintf("URL: %s", URL)) // Convert url to url object u, err := url.Parse(URL) - log.Info(fmt.Sprintf("u.Path: %s", u.Path)) log.Info(fmt.Sprintf("rw.getRouteSubPath(): %s", rw.getRouteSubPath())) if err != nil { @@ -132,5 +130,6 @@ func (rw *RouteWrapper) GetURL(forceHttps bool, healthEndpoint string) string { u.Path = path.Join(u.EscapedPath(), healthEndpoint) } } + log.Info(fmt.Sprintf("u.String(): %s", u.String()) return u.String() } From 503f4df1479bb51f99460ae80cda79f4db2d6abf Mon Sep 17 00:00:00 2001 From: Karl Johan Grahn Date: Mon, 16 Dec 2024 20:07:36 +0100 Subject: [PATCH 11/14] update --- pkg/kube/wrappers/routeWrapper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kube/wrappers/routeWrapper.go b/pkg/kube/wrappers/routeWrapper.go index 4394fdd9..9e85500f 100644 --- a/pkg/kube/wrappers/routeWrapper.go +++ b/pkg/kube/wrappers/routeWrapper.go @@ -130,6 +130,6 @@ func (rw *RouteWrapper) GetURL(forceHttps bool, healthEndpoint string) string { u.Path = path.Join(u.EscapedPath(), healthEndpoint) } } - log.Info(fmt.Sprintf("u.String(): %s", u.String()) + log.Info(fmt.Sprintf("u.String(): %s", u.String())) return u.String() } From 4aed25b91d4bb3a85418f24857fcbf994b4c6e87 Mon Sep 17 00:00:00 2001 From: Karl Johan Grahn Date: Mon, 16 Dec 2024 20:37:45 +0100 Subject: [PATCH 12/14] update --- pkg/kube/wrappers/routeWrapper.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/kube/wrappers/routeWrapper.go b/pkg/kube/wrappers/routeWrapper.go index 9e85500f..5f9d09bd 100644 --- a/pkg/kube/wrappers/routeWrapper.go +++ b/pkg/kube/wrappers/routeWrapper.go @@ -109,7 +109,6 @@ func (rw *RouteWrapper) GetURL(forceHttps bool, healthEndpoint string) string { // Convert url to url object u, err := url.Parse(URL) - log.Info(fmt.Sprintf("rw.getRouteSubPath(): %s", rw.getRouteSubPath())) if err != nil { log.Info(fmt.Sprintf("URL parsing error in getURL() :%v", err)) @@ -120,14 +119,20 @@ func (rw *RouteWrapper) GetURL(forceHttps bool, healthEndpoint string) string { u.Path = healthEndpoint } else { // Append subpath + log.Info(fmt.Sprintf("u.EscapedPath(): %s", u.EscapedPath())) + log.Info(fmt.Sprintf("rw.getRouteSubPath(): %s", rw.getRouteSubPath())) u.Path = path.Join(u.EscapedPath(), rw.getRouteSubPath()) + log.Info(fmt.Sprintf("u.Path: %s", u.Path)) // Find pod by backtracking route -> service -> pod healthEndpoint, exists := rw.tryGetHealthEndpointFromRoute() // Health endpoint from pod successful if exists { + log.Info(fmt.Sprintf("u.EscapedPath(): %s", u.EscapedPath())) + log.Info(fmt.Sprintf("healthEndpoint: %s", healthEndpoint)) u.Path = path.Join(u.EscapedPath(), healthEndpoint) + log.Info(fmt.Sprintf("u.Path: %s", u.Path)) } } log.Info(fmt.Sprintf("u.String(): %s", u.String())) From bf4e5289b743406ed221e299514bd8d71ae739b1 Mon Sep 17 00:00:00 2001 From: Karl Johan Grahn Date: Mon, 16 Dec 2024 21:35:33 +0100 Subject: [PATCH 13/14] update --- pkg/kube/wrappers/routeWrapper.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/pkg/kube/wrappers/routeWrapper.go b/pkg/kube/wrappers/routeWrapper.go index 5f9d09bd..1c972fc3 100644 --- a/pkg/kube/wrappers/routeWrapper.go +++ b/pkg/kube/wrappers/routeWrapper.go @@ -119,22 +119,15 @@ func (rw *RouteWrapper) GetURL(forceHttps bool, healthEndpoint string) string { u.Path = healthEndpoint } else { // Append subpath - log.Info(fmt.Sprintf("u.EscapedPath(): %s", u.EscapedPath())) - log.Info(fmt.Sprintf("rw.getRouteSubPath(): %s", rw.getRouteSubPath())) - u.Path = path.Join(u.EscapedPath(), rw.getRouteSubPath()) - log.Info(fmt.Sprintf("u.Path: %s", u.Path)) + u.Path = path.Join(u.Path, rw.getRouteSubPath()) // Find pod by backtracking route -> service -> pod healthEndpoint, exists := rw.tryGetHealthEndpointFromRoute() // Health endpoint from pod successful if exists { - log.Info(fmt.Sprintf("u.EscapedPath(): %s", u.EscapedPath())) - log.Info(fmt.Sprintf("healthEndpoint: %s", healthEndpoint)) - u.Path = path.Join(u.EscapedPath(), healthEndpoint) - log.Info(fmt.Sprintf("u.Path: %s", u.Path)) + u.Path = path.Join(u.Path, healthEndpoint) } } - log.Info(fmt.Sprintf("u.String(): %s", u.String())) - return u.String() + return url.PathUnescape(u.String()) } From 02468a3af925ad4c85f3a605171a7a6648309de8 Mon Sep 17 00:00:00 2001 From: Karl Johan Grahn Date: Mon, 16 Dec 2024 21:39:30 +0100 Subject: [PATCH 14/14] update --- pkg/kube/wrappers/routeWrapper.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/kube/wrappers/routeWrapper.go b/pkg/kube/wrappers/routeWrapper.go index 1c972fc3..4ab47192 100644 --- a/pkg/kube/wrappers/routeWrapper.go +++ b/pkg/kube/wrappers/routeWrapper.go @@ -129,5 +129,10 @@ func (rw *RouteWrapper) GetURL(forceHttps bool, healthEndpoint string) string { u.Path = path.Join(u.Path, healthEndpoint) } } - return url.PathUnescape(u.String()) + path, err := url.PathUnescape(u.String()) + if err != nil { + log.Info(fmt.Sprintf("Error in unescaping path :%v", err)) + return "" + } + return path }