From 9c680da301582257a10d6e2cb628fdabe2b278a5 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Tue, 6 Feb 2024 09:57:42 +0100 Subject: [PATCH 1/5] Correct post-eventing-manager-build name (#455) --- .github/workflows/push-e2e-upgrade-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-e2e-upgrade-test.yaml b/.github/workflows/push-e2e-upgrade-test.yaml index 99d3763d..de2162e2 100644 --- a/.github/workflows/push-e2e-upgrade-test.yaml +++ b/.github/workflows/push-e2e-upgrade-test.yaml @@ -28,6 +28,6 @@ jobs: with: pre-upgrade-image-tag: ${{ needs.get-latest-release.outputs.latest_release_tag }} post-upgrade-image-tag: main - build-job-name: push-eventing-manager-build + build-job-name: post-eventing-manager-build build-job-commit-sha: ${{ github.sha }} secrets: inherit From ffcdf50fd9527ab29383a5caac9f6e2402828587 Mon Sep 17 00:00:00 2001 From: Marco Bebway Date: Tue, 6 Feb 2024 12:09:43 +0100 Subject: [PATCH 2/5] Change Eventing CR status to WARN if cannot connect to NATS (#456) * Change Eventing CR status to WARN if cannot connect to NATS * Fix tests * Add a unit-test * Remove not existing functions from mocks --- .../operator/eventing/controller.go | 4 +-- .../natsconnection/integration_test.go | 29 +++++++++++++++---- test/utils/integration/integration.go | 2 -- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/internal/controller/operator/eventing/controller.go b/internal/controller/operator/eventing/controller.go index 460b83ae..d1d366f0 100644 --- a/internal/controller/operator/eventing/controller.go +++ b/internal/controller/operator/eventing/controller.go @@ -575,11 +575,11 @@ func (r *Reconciler) reconcileNATSBackend(ctx context.Context, if connErr := r.connectToNATS(eventingCR); connErr != nil { if errors.Is(connErr, natsconnectionerrors.ErrCannotConnect) { return kctrl.Result{}, reconcile.TerminalError( - r.syncStatusWithNATSErr(ctx, eventingCR, connErr, log), + r.syncStatusWithNATSState(ctx, operatorv1alpha1.StateWarning, eventingCR, connErr, log), ) } - return kctrl.Result{}, r.syncStatusWithNATSErr(ctx, eventingCR, connErr, log) + return kctrl.Result{}, r.syncStatusWithNATSState(ctx, operatorv1alpha1.StateWarning, eventingCR, connErr, log) } // set NATSAvailable condition to true and update status diff --git a/internal/controller/operator/eventing/integrationtests/natsconnection/integration_test.go b/internal/controller/operator/eventing/integrationtests/natsconnection/integration_test.go index 63cb59a8..908c9e12 100644 --- a/internal/controller/operator/eventing/integrationtests/natsconnection/integration_test.go +++ b/internal/controller/operator/eventing/integrationtests/natsconnection/integration_test.go @@ -6,6 +6,7 @@ import ( natstestutils "github.com/kyma-project/nats-manager/testutils" "github.com/onsi/gomega" gomegatypes "github.com/onsi/gomega/types" + "github.com/pkg/errors" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" kappsv1 "k8s.io/api/apps/v1" @@ -22,6 +23,9 @@ import ( // Test_NATSConnection tests the Eventing CR status when connecting to NATS. func Test_NATSConnection(t *testing.T) { // given + + ErrAny := errors.New("any") + testCases := []struct { name string givenNATSConnectionMock func() *natsconnectionmocks.Connection @@ -33,8 +37,6 @@ func Test_NATSConnection(t *testing.T) { conn := &natsconnectionmocks.Connection{} conn.On("Connect", mock.Anything, mock.Anything).Return(nil) conn.On("IsConnected").Return(true) - conn.On("RegisterReconnectHandler", mock.Anything).Return() - conn.On("RegisterDisconnectErrHandler", mock.Anything).Return() return conn }, wantMatches: gomega.And( @@ -45,17 +47,15 @@ func Test_NATSConnection(t *testing.T) { ), }, { - name: "Eventing CR should be in error state if not connected to NATS", + name: "Eventing CR should be in warning state if the connect behaviour returned a cannot connect error", givenNATSConnectionMock: func() *natsconnectionmocks.Connection { conn := &natsconnectionmocks.Connection{} conn.On("Connect", mock.Anything, mock.Anything).Return(natsconnectionerrors.ErrCannotConnect) conn.On("IsConnected").Return(false) - conn.On("RegisterReconnectHandler", mock.Anything).Return() - conn.On("RegisterDisconnectErrHandler", mock.Anything).Return() return conn }, wantMatches: gomega.And( - matchers.HaveStatusError(), + matchers.HaveStatusWarning(), matchers.HaveBackendNotAvailableConditionWith( natsconnectionerrors.ErrCannotConnect.Error(), operatorv1alpha1.ConditionReasonNATSNotAvailable, @@ -63,6 +63,23 @@ func Test_NATSConnection(t *testing.T) { matchers.HaveFinalizer(), ), }, + { + name: "Eventing CR should be in warning state if the connect behaviour returned any error", + givenNATSConnectionMock: func() *natsconnectionmocks.Connection { + conn := &natsconnectionmocks.Connection{} + conn.On("Connect", mock.Anything, mock.Anything).Return(ErrAny) + conn.On("IsConnected").Return(false) + return conn + }, + wantMatches: gomega.And( + matchers.HaveStatusWarning(), + matchers.HaveBackendNotAvailableConditionWith( + ErrAny.Error(), + operatorv1alpha1.ConditionReasonNATSNotAvailable, + ), + matchers.HaveFinalizer(), + ), + }, } for _, tc := range testCases { diff --git a/test/utils/integration/integration.go b/test/utils/integration/integration.go index 9d587153..9c56f27e 100644 --- a/test/utils/integration/integration.go +++ b/test/utils/integration/integration.go @@ -199,8 +199,6 @@ func NewTestEnvironment(config TestEnvironmentConfig, connMock *natsconnectionmo connMock.On("Connect", mock.Anything, mock.Anything).Return(nil) connMock.On("IsConnected").Return(true) connMock.On("Disconnect").Return() - connMock.On("RegisterReconnectHandler", mock.Anything).Return() - connMock.On("RegisterDisconnectErrHandler", mock.Anything).Return() } // create a new watcher From bc8e97c46330b319a491dfc4502ecf186be1a532 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Tue, 6 Feb 2024 12:35:42 +0100 Subject: [PATCH 3/5] Use checkout GH action branch setting (#459) * Use checkout GH action branch setting * Set branch with checkout GH action * Don't set branch for post upgrade checkout * Use commit sha to change next version commit --- .../workflows/e2e-upgrade-test-reusable.yaml | 24 +++++++++++-------- .github/workflows/pull-e2e-upgrade-test.yaml | 2 +- .github/workflows/push-e2e-upgrade-test.yaml | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/e2e-upgrade-test-reusable.yaml b/.github/workflows/e2e-upgrade-test-reusable.yaml index e17ff701..80aef394 100644 --- a/.github/workflows/e2e-upgrade-test-reusable.yaml +++ b/.github/workflows/e2e-upgrade-test-reusable.yaml @@ -8,20 +8,24 @@ env: on: workflow_call: inputs: - # image tag before upgrade pre-upgrade-image-tag: required: true type: string - # image tag after upgrade + description: "The image tag of the Eventing Manager before the upgrade" post-upgrade-image-tag: required: true type: string - # job name of the prow build job + description: "The image tag of the Eventing Manager after the upgrade" build-job-name: type: string - # commit sha of the PR or main branch commit - build-job-commit-sha: + description: "The name of the build job to wait for" + commit-sha: type: string + description: "The commit sha of the new version" + required: true + +# PR: main -> PR +# main: release -> main jobs: e2e-upgrade: # This job tests the upgrade of Eventing module from the latest image of the main branch to the current commit. @@ -31,8 +35,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Pre-upgrade checkout - run: git checkout -b ${{ inputs.pre-upgrade-image-tag }} + with: + ref: ${{ inputs.pre-upgrade-image-tag }} - name: Install k3d tools run: make -C hack/ci/ install-k3d-tools @@ -74,7 +78,7 @@ jobs: uses: kyma-project/wait-for-commit-status-action@2b3ffe09af8b6f40e1213d5fb7f91a7bd41ffb20 with: context: ${{ inputs.build-job-name }} - commit_ref: "${{ inputs.build-job-commit-sha }}" # Note: 'github.event.pull_request.head.sha' is not same as 'github.sha' on pull requests. + commit_ref: "${{ inputs.commit-sha }}" timeout: 600000 # 10 minutes in milliseconds # The check interval is kept long otherwise it will exhaust the GitHub rate limit (More info: https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limiting) check_interval: 60000 # 1 minute in milliseconds @@ -85,8 +89,8 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Post-upgrade checkout - run: git checkout -b ${{ inputs.post-upgrade-image-tag }} + with: + ref: ${{ inputs.commit-sha }} - name: Install Eventing manager after upgrade run: | diff --git a/.github/workflows/pull-e2e-upgrade-test.yaml b/.github/workflows/pull-e2e-upgrade-test.yaml index 8a577b59..4918fbea 100644 --- a/.github/workflows/pull-e2e-upgrade-test.yaml +++ b/.github/workflows/pull-e2e-upgrade-test.yaml @@ -15,5 +15,5 @@ jobs: pre-upgrade-image-tag: main post-upgrade-image-tag: PR-${{ github.event.number }} build-job-name: pull-eventing-manager-build - build-job-commit-sha: ${{ github.event.pull_request.head.sha }} + commit-sha: ${{ github.event.pull_request.head.sha }} secrets: inherit diff --git a/.github/workflows/push-e2e-upgrade-test.yaml b/.github/workflows/push-e2e-upgrade-test.yaml index de2162e2..285290ce 100644 --- a/.github/workflows/push-e2e-upgrade-test.yaml +++ b/.github/workflows/push-e2e-upgrade-test.yaml @@ -29,5 +29,5 @@ jobs: pre-upgrade-image-tag: ${{ needs.get-latest-release.outputs.latest_release_tag }} post-upgrade-image-tag: main build-job-name: post-eventing-manager-build - build-job-commit-sha: ${{ github.sha }} + commit-sha: ${{ github.sha }} secrets: inherit From 9ae58dd4a368a191226930227123c27fd77c2aa1 Mon Sep 17 00:00:00 2001 From: Carina Kothe <69976260+grischperl@users.noreply.github.com> Date: Tue, 6 Feb 2024 13:41:42 +0100 Subject: [PATCH 4/5] Bump rc-tag on main (#460) --- sec-scanners-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/sec-scanners-config.yaml b/sec-scanners-config.yaml index 956c4175..2f0e12f9 100644 --- a/sec-scanners-config.yaml +++ b/sec-scanners-config.yaml @@ -1,4 +1,5 @@ module-name: eventing +rc-tag: 1.1.0 protecode: - europe-docker.pkg.dev/kyma-project/prod/eventing-manager:main - europe-docker.pkg.dev/kyma-project/prod/eventing-publisher-proxy:1.0.1 From 4fcbb1c4d22b36ed78c4bf4eb3c98a65c6b48a85 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Tue, 6 Feb 2024 16:05:42 +0100 Subject: [PATCH 5/5] Don't use shell script file (#461) * Script is not found as the latest release doesn't have it --- .../workflows/e2e-upgrade-test-reusable.yaml | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/e2e-upgrade-test-reusable.yaml b/.github/workflows/e2e-upgrade-test-reusable.yaml index 80aef394..e9d4990c 100644 --- a/.github/workflows/e2e-upgrade-test-reusable.yaml +++ b/.github/workflows/e2e-upgrade-test-reusable.yaml @@ -4,6 +4,8 @@ env: E2E_LOG_LEVEL: debug KYMA_STABILITY: "unstable" KYMA: "./hack/kyma" + DOCKER_IMAGE_REPO: "europe-docker.pkg.dev/kyma-project/prod/eventing-manager" + DOCKER_IMAGE_REPO_DEV: "europe-docker.pkg.dev/kyma-project/dev/eventing-manager" on: workflow_call: @@ -24,8 +26,9 @@ on: description: "The commit sha of the new version" required: true -# PR: main -> PR -# main: release -> main +# For example, +# PR: main -> PR +# main: latest release -> main jobs: e2e-upgrade: # This job tests the upgrade of Eventing module from the latest image of the main branch to the current commit. @@ -63,13 +66,13 @@ jobs: - name: Install Eventing manager before upgrade run: | - pre_upgrade_image=$(./hack/ci/build-full-image-path.sh ${{ inputs.pre-upgrade-image-tag }}) + pre_upgrade_image=$DOCKER_IMAGE_REPO:${{ inputs.pre-upgrade-image-tag }} echo "Pre-upgrade image: $pre_upgrade_image" make deploy IMG=$pre_upgrade_image - name: Create test resources and wait for eventing CR readiness run: | - export MANAGER_IMAGE=$(./hack/ci/build-full-image-path.sh ${{ inputs.pre-upgrade-image-tag }}) + export MANAGER_IMAGE=$DOCKER_IMAGE_REPO:${{ inputs.pre-upgrade-image-tag }} make e2e-setup make e2e-eventing-setup @@ -92,15 +95,21 @@ jobs: with: ref: ${{ inputs.commit-sha }} - - name: Install Eventing manager after upgrade + - name: Upgrade Eventing manager + id: upgrade-eventing-manager run: | - post_upgrade_image=$(./hack/ci/build-full-image-path.sh ${{ inputs.post-upgrade-image-tag }}) + if [[ ${{ inputs.post-upgrade-image-tag }} == PR* ]]; then + post_upgrade_image=$DOCKER_IMAGE_REPO_DEV:${{ inputs.post-upgrade-image-tag }} + else + post_upgrade_image=$DOCKER_IMAGE_REPO:${{ inputs.post-upgrade-image-tag }} + fi echo "Post-upgrade image: $post_upgrade_image" make deploy IMG=$post_upgrade_image + echo "post_upgrade_image=$post_upgrade_image" >> "$GITHUB_OUTPUT" - name: Create test resources and waits for eventing CR readiness run: | - export MANAGER_IMAGE=$(./hack/ci/build-full-image-path.sh ${{ inputs.post-upgrade-image-tag }}) + export MANAGER_IMAGE=${{ steps.upgrade-eventing-manager.outputs.post_upgrade_image }} make e2e-setup - name: Run e2e tests