diff --git a/.github/workflows/e2e-upgrade-test-reusable.yaml b/.github/workflows/e2e-upgrade-test-reusable.yaml index e17ff701..e9d4990c 100644 --- a/.github/workflows/e2e-upgrade-test-reusable.yaml +++ b/.github/workflows/e2e-upgrade-test-reusable.yaml @@ -4,24 +4,31 @@ 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: 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 + +# 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. @@ -31,8 +38,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 @@ -59,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 @@ -74,7 +81,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,18 +92,24 @@ 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 + - 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 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 99d3763d..285290ce 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-commit-sha: ${{ github.sha }} + build-job-name: post-eventing-manager-build + commit-sha: ${{ github.sha }} secrets: inherit 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/sec-scanners-config.yaml b/sec-scanners-config.yaml index 888af0fe..01c307fd 100644 --- a/sec-scanners-config.yaml +++ b/sec-scanners-config.yaml @@ -2,7 +2,7 @@ # The value for the publisher image is extracted from config/manager/manager.yaml. # The value for the webhook image is extracted from config/webhook/kustomization.yaml. module-name: eventing -rc-tag: 0.8.0 +rc-tag: 1.1.0 protecode: - europe-docker.pkg.dev/kyma-project/prod/eventing-manager:0.8.0 - europe-docker.pkg.dev/kyma-project/prod/eventing-publisher-proxy:1.0.1 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