From ddea0e0229d8d3bb5c907093bcde9c2c45dd1c78 Mon Sep 17 00:00:00 2001 From: Ricardo Maraschini Date: Mon, 28 Aug 2023 13:04:58 +0200 Subject: [PATCH 1/7] feat: enable tests on top of helmvm enables kots tests on top of helmvm. --- .github/workflows/regression.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/regression.yaml b/.github/workflows/regression.yaml index e0047b5c5b..2a99593730 100644 --- a/.github/workflows/regression.yaml +++ b/.github/workflows/regression.yaml @@ -189,6 +189,11 @@ jobs: backend_config: "existing-airgapped-upgrade-minimum-backend-config.tfvars", terraform_script: "existing-airgapped-upgrade-minimum.sh", is_upgrade: "1" + }, + { + name: "type=helmvm cluster, env=online, phase=new install, rbac=cluster admin", + backend_config: "helmvm-online-install-backend-config.tfvars", + terraform_script: "helmvm-online-install.sh" } ] steps: From 33c2b959e8058ebe9a53a8e93ae4a68e5193542a Mon Sep 17 00:00:00 2001 From: Salah Aldeen Al Saleh Date: Thu, 31 Aug 2023 18:03:57 +0000 Subject: [PATCH 2/7] temp change to run regression tests --- .github/workflows/release.yaml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 7b344f1383..8a621e0dd9 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -11,7 +11,7 @@ jobs: generate-tag: runs-on: ubuntu-20.04 outputs: - tag: ${{ github.ref_type == 'branch' && steps.get_tag.outputs.GIT_TAG || github.ref_name }} + tag: ${{ github.ref_type != 'branch' && steps.get_tag.outputs.GIT_TAG || github.ref_name }} steps: - name: Checkout uses: actions/checkout@v3 @@ -19,7 +19,7 @@ jobs: id: get_tag uses: ./.github/actions/version-tag - name: Push tag - if: github.ref_type == 'branch' + if: github.ref_type != 'branch' env: GIT_TAG: ${{ steps.get_tag.outputs.GIT_TAG }} run: | @@ -214,7 +214,7 @@ jobs: goreleaser: runs-on: ubuntu-20.04 - if: github.ref_type != 'branch' + if: github.ref_type == 'branch' needs: [build-web] steps: - uses: actions/setup-go@v3 @@ -299,7 +299,7 @@ jobs: id: addon-generate with: addon_version: ${{ steps.vars.outputs.addon_version }} - s3_prefix: "${{ github.ref_type != 'branch' && '' || 'test/' }}" + s3_prefix: "${{ github.ref_type == 'branch' && '' || 'test/' }}" kotsadm_binary_override: bin/kots.tar.gz # only run validate-kurl-addon if changes to "deploy/kurl/kotsadm/template/**" kurl-addon-changes-filter: @@ -317,7 +317,7 @@ jobs: - 'deploy/kurl/kotsadm/testgrid-os-spec.yaml' validate-kurl-addon: runs-on: ubuntu-20.04 - if: ${{ github.ref_type != 'branch' || needs.kurl-addon-changes-filter.outputs.ok-to-test == 'true' }} + if: ${{ github.ref_type == 'branch' || needs.kurl-addon-changes-filter.outputs.ok-to-test == 'true' }} needs: [ generate-tag, generate-kurl-addon, kurl-addon-changes-filter ] steps: - name: checkout @@ -331,11 +331,11 @@ jobs: with: addon_version: ${{ steps.vars.outputs.addon_version }} addon_package_url: "${{ needs.generate-kurl-addon.outputs.addon_package_url }}" - priority: ${{ github.ref_type != 'branch' && '1' || '0' }} + priority: ${{ github.ref_type == 'branch' && '1' || '0' }} testgrid_api_token: ${{ secrets.TESTGRID_PROD_API_TOKEN }} publish-kurl-addon: runs-on: ubuntu-20.04 - if: ${{ github.ref_type != 'branch' }} + if: ${{ github.ref_type == 'branch' }} needs: [ generate-tag, generate-kurl-addon ] env: AWS_ACCESS_KEY_ID: ${{ secrets.KURL_ADDONS_AWS_ACCESS_KEY_ID }} @@ -359,7 +359,7 @@ jobs: generate-kots-release-notes-pr: runs-on: ubuntu-20.04 needs: [generate-tag] - if: github.ref_type != 'branch' + if: github.ref_type == 'branch' steps: - name: Checkout uses: actions/checkout@v3 @@ -376,7 +376,7 @@ jobs: build-airgap: runs-on: ubuntu-20.04 - if: github.ref_type != 'branch' + if: github.ref_type == 'branch' needs: [release-go-api-tagged, goreleaser, build-schema-migrations, generate-tag] steps: - name: Download migrations @@ -411,7 +411,7 @@ jobs: regression-test-setup: name: Run regression testing - if: github.ref_type == 'branch' + if: github.ref_type != 'branch' runs-on: ubuntu-latest needs: [ generate-tag ] outputs: @@ -435,7 +435,7 @@ jobs: echo "id=${id:0:7}" >> "$GITHUB_OUTPUT" regression-test: - if: github.ref_type == 'branch' + if: github.ref_type != 'branch' needs: [ regression-test-setup, generate-tag, build-go-api, release-go-api-tagged, generate-kurl-addon ] uses: ./.github/workflows/regression.yaml with: From c2dcbe3ead25559925113e3a534326d064efa7d8 Mon Sep 17 00:00:00 2001 From: Salah Aldeen Al Saleh Date: Thu, 31 Aug 2023 18:07:17 +0000 Subject: [PATCH 3/7] make regression tests work --- .github/workflows/release.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8a621e0dd9..a7d71cb4e7 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,13 +5,13 @@ on: tags: - "v*.*.*" branches: - - main + - ricardomaraschini/sc-86964/kots-test-workflow-for-helmvm jobs: generate-tag: runs-on: ubuntu-20.04 outputs: - tag: ${{ github.ref_type != 'branch' && steps.get_tag.outputs.GIT_TAG || github.ref_name }} + tag: ${{ github.ref_type == 'branch' && steps.get_tag.outputs.GIT_TAG || github.ref_name }} steps: - name: Checkout uses: actions/checkout@v3 @@ -19,7 +19,7 @@ jobs: id: get_tag uses: ./.github/actions/version-tag - name: Push tag - if: github.ref_type != 'branch' + if: github.ref_type == 'branch' env: GIT_TAG: ${{ steps.get_tag.outputs.GIT_TAG }} run: | @@ -214,7 +214,7 @@ jobs: goreleaser: runs-on: ubuntu-20.04 - if: github.ref_type == 'branch' + if: github.ref_type != 'branch' needs: [build-web] steps: - uses: actions/setup-go@v3 @@ -299,7 +299,7 @@ jobs: id: addon-generate with: addon_version: ${{ steps.vars.outputs.addon_version }} - s3_prefix: "${{ github.ref_type == 'branch' && '' || 'test/' }}" + s3_prefix: "${{ github.ref_type != 'branch' && '' || 'test/' }}" kotsadm_binary_override: bin/kots.tar.gz # only run validate-kurl-addon if changes to "deploy/kurl/kotsadm/template/**" kurl-addon-changes-filter: @@ -317,7 +317,7 @@ jobs: - 'deploy/kurl/kotsadm/testgrid-os-spec.yaml' validate-kurl-addon: runs-on: ubuntu-20.04 - if: ${{ github.ref_type == 'branch' || needs.kurl-addon-changes-filter.outputs.ok-to-test == 'true' }} + if: ${{ github.ref_type != 'branch' || needs.kurl-addon-changes-filter.outputs.ok-to-test == 'true' }} needs: [ generate-tag, generate-kurl-addon, kurl-addon-changes-filter ] steps: - name: checkout @@ -331,11 +331,11 @@ jobs: with: addon_version: ${{ steps.vars.outputs.addon_version }} addon_package_url: "${{ needs.generate-kurl-addon.outputs.addon_package_url }}" - priority: ${{ github.ref_type == 'branch' && '1' || '0' }} + priority: ${{ github.ref_type != 'branch' && '1' || '0' }} testgrid_api_token: ${{ secrets.TESTGRID_PROD_API_TOKEN }} publish-kurl-addon: runs-on: ubuntu-20.04 - if: ${{ github.ref_type == 'branch' }} + if: ${{ github.ref_type != 'branch' }} needs: [ generate-tag, generate-kurl-addon ] env: AWS_ACCESS_KEY_ID: ${{ secrets.KURL_ADDONS_AWS_ACCESS_KEY_ID }} @@ -359,7 +359,7 @@ jobs: generate-kots-release-notes-pr: runs-on: ubuntu-20.04 needs: [generate-tag] - if: github.ref_type == 'branch' + if: github.ref_type != 'branch' steps: - name: Checkout uses: actions/checkout@v3 @@ -376,7 +376,7 @@ jobs: build-airgap: runs-on: ubuntu-20.04 - if: github.ref_type == 'branch' + if: github.ref_type != 'branch' needs: [release-go-api-tagged, goreleaser, build-schema-migrations, generate-tag] steps: - name: Download migrations @@ -411,7 +411,7 @@ jobs: regression-test-setup: name: Run regression testing - if: github.ref_type != 'branch' + if: github.ref_type == 'branch' runs-on: ubuntu-latest needs: [ generate-tag ] outputs: @@ -435,7 +435,7 @@ jobs: echo "id=${id:0:7}" >> "$GITHUB_OUTPUT" regression-test: - if: github.ref_type != 'branch' + if: github.ref_type == 'branch' needs: [ regression-test-setup, generate-tag, build-go-api, release-go-api-tagged, generate-kurl-addon ] uses: ./.github/workflows/regression.yaml with: From 91d014e48a755dc7d7aff6beb08dced6a943a71c Mon Sep 17 00:00:00 2001 From: Ricardo Maraschini Date: Fri, 1 Sep 2023 10:38:06 +0200 Subject: [PATCH 4/7] tests: temporarily use different branch for kots regression this commits makes github ci to use a different branch of kots regression automation repository. this is temporary, for tests purpose. --- .github/workflows/regression.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/regression.yaml b/.github/workflows/regression.yaml index 2a99593730..c192d62d74 100644 --- a/.github/workflows/regression.yaml +++ b/.github/workflows/regression.yaml @@ -203,7 +203,7 @@ jobs: repository: replicatedhq/kots-regression-automation token: ${{ secrets.E2E_GH_PAT }} path: automation - ref: main + ref: temporarily-use-my-testim-branch - name: Initialize terraform if: always() working-directory: automation/cluster From 004d72d53117f79c5796a7fdb3f252a925906b0f Mon Sep 17 00:00:00 2001 From: Craig O'Donnell Date: Tue, 12 Sep 2023 16:05:25 -0400 Subject: [PATCH 5/7] fix race condition when updating registry settings --- pkg/handlers/registry.go | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/pkg/handlers/registry.go b/pkg/handlers/registry.go index 21697cc895..75ce23dd61 100644 --- a/pkg/handlers/registry.go +++ b/pkg/handlers/registry.go @@ -210,21 +210,31 @@ func (h *Handler) UpdateAppRegistry(w http.ResponseWriter, r *http.Request) { return } + skipImagePush := updateAppRegistryRequest.IsReadOnly + if foundApp.IsAirgap { + // TODO: pushing images not yet supported in airgapped instances. + skipImagePush = true + } + + latestSequence, err := store.GetStore().GetLatestAppSequence(foundApp.ID, true) + if err != nil { + logger.Error(errors.Wrapf(err, "failed to get latest app sequence for app %s", foundApp.Slug)) + updateAppRegistryResponse.Error = err.Error() + JSON(w, http.StatusInternalServerError, updateAppRegistryResponse) + return + } + + // set task status before starting the goroutine so that the UI can show the status + if err := store.GetStore().SetTaskStatus("image-rewrite", "Updating registry settings", "running"); err != nil { + logger.Error(errors.Wrap(err, "failed to set task status")) + updateAppRegistryResponse.Error = err.Error() + JSON(w, http.StatusInternalServerError, updateAppRegistryResponse) + return + } + // in a goroutine, start pushing the images to the remote registry // we will let this function return while this happens go func() { - skipImagePush := updateAppRegistryRequest.IsReadOnly - if foundApp.IsAirgap { - // TODO: pushing images not yet supported in airgapped instances. - skipImagePush = true - } - - latestSequence, err := store.GetStore().GetLatestAppSequence(foundApp.ID, true) - if err != nil { - logger.Error(errors.Wrapf(err, "failed to get latest app sequence for app %s", foundApp.Slug)) - return - } - appDir, err := registry.RewriteImages( foundApp.ID, latestSequence, updateAppRegistryRequest.Hostname, updateAppRegistryRequest.Username, registryPassword, From 465eb35d573ecd0d7a8f4c38648267ffd55e6da3 Mon Sep 17 00:00:00 2001 From: Ricardo Maraschini Date: Thu, 14 Sep 2023 18:07:56 +0200 Subject: [PATCH 6/7] chore: restore regression to main branch --- .github/workflows/regression.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/regression.yaml b/.github/workflows/regression.yaml index c192d62d74..2a99593730 100644 --- a/.github/workflows/regression.yaml +++ b/.github/workflows/regression.yaml @@ -203,7 +203,7 @@ jobs: repository: replicatedhq/kots-regression-automation token: ${{ secrets.E2E_GH_PAT }} path: automation - ref: temporarily-use-my-testim-branch + ref: main - name: Initialize terraform if: always() working-directory: automation/cluster From d608068d39b3243eb73131e64d6227b0f053655c Mon Sep 17 00:00:00 2001 From: Ricardo Maraschini Date: Thu, 14 Sep 2023 18:09:56 +0200 Subject: [PATCH 7/7] chore: restore release workflow on main branch --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a7d71cb4e7..7b344f1383 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,7 +5,7 @@ on: tags: - "v*.*.*" branches: - - ricardomaraschini/sc-86964/kots-test-workflow-for-helmvm + - main jobs: generate-tag: