You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2022/05/16 04:46:40 UTC

[camel-k] 04/06: Preparing for next release: e2e preflight test improvement

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch prepare-1.9.2
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit acdd7bd802ccedb2ae62a49eb9cb9c30c3c1751b
Author: phantomjinx <p....@phantomjinx.co.uk>
AuthorDate: Thu Apr 28 17:02:19 2022 +0100

    Preparing for next release: e2e preflight test improvement
    
    * preflight-test.sh
     * Wait for the catalog source to become READY rather than assume it is
    
    * build-bundle-image.sh
    * build-index-image.sh
     * Change the upgrade-test channel to avoid a conflict with existing
       channels
    
    * .../operator.go
     * Functions assume existence of Config reference but this is no longer
       being created implicitly so add to avoid panics
---
 .../kamel-build-bundle/build-bundle-image.sh       |  2 +-
 .../kamel-build-bundle/build-index-image.sh        |  2 +-
 .../actions/kamel-preflight-test/preflight-test.sh | 27 ++++++++++++++++++----
 pkg/util/olm/operator.go                           | 10 ++++++++
 4 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/.github/actions/kamel-build-bundle/build-bundle-image.sh b/.github/actions/kamel-build-bundle/build-bundle-image.sh
index ff5aef7b1..575ada06d 100755
--- a/.github/actions/kamel-build-bundle/build-bundle-image.sh
+++ b/.github/actions/kamel-build-bundle/build-bundle-image.sh
@@ -108,7 +108,7 @@ export CUSTOM_IMAGE=${IMAGE_NAME}
 
 export PREV_XY_CHANNEL="stable-$(make get-last-released-version | grep -Po '\d.\d')"
 echo "PREV_XY_CHANNEL=${PREV_XY_CHANNEL}" >> $GITHUB_ENV
-export NEW_XY_CHANNEL=stable-$(make get-version | grep -Po "\d.\d")
+export NEW_XY_CHANNEL=stable-dev-$(make get-version | grep -Po "\d.\d")
 echo "NEW_XY_CHANNEL=${NEW_XY_CHANNEL}" >> $GITHUB_ENV
 
 make bundle-build \
diff --git a/.github/actions/kamel-build-bundle/build-index-image.sh b/.github/actions/kamel-build-bundle/build-index-image.sh
index bfad918f0..8857d1531 100755
--- a/.github/actions/kamel-build-bundle/build-index-image.sh
+++ b/.github/actions/kamel-build-bundle/build-index-image.sh
@@ -211,7 +211,7 @@ cat << EOF >> ${CATALOG_DIR}/camel-k.yaml
 ---
 schema: olm.channel
 package: camel-k
-name: stable-$(make get-version | grep -Po "\d.\d")
+name: stable-dev-$(make get-version | grep -Po "\d.\d")
 entries:
   - name: camel-k.v$(make get-version | grep -Po "\d.\d.\d")
     replaces: $(make get-last-released-img-name).v$(make get-last-released-version | grep -Po "\d.\d.\d")
diff --git a/.github/actions/kamel-preflight-test/preflight-test.sh b/.github/actions/kamel-preflight-test/preflight-test.sh
index f85e41ef7..a815006da 100755
--- a/.github/actions/kamel-preflight-test/preflight-test.sh
+++ b/.github/actions/kamel-preflight-test/preflight-test.sh
@@ -113,11 +113,28 @@ if [ -n "${BUILD_CATALOG_SOURCE}" ]; then
   #
   # Check catalog source is actually available
   #
-  STATE=$(kubectl get catalogsource ${BUILD_CATALOG_SOURCE} -n ${IMAGE_NAMESPACE} -o=jsonpath='{.status.connectionState.lastObservedState}')
-  if [ "${STATE}" != "READY" ]; then
-    echo "Error: catalog source status is not ready."
-    exit 1
-  fi
+  timeout=5
+  catalog_ready=0
+  until [ ${catalog_ready} -eq 1 ] || [ ${timeout} -eq 0 ]
+  do
+    echo "Info: Awaiting catalog source to become ready"
+    let timeout=${timeout}-1
+
+    STATE=$(kubectl get catalogsource ${BUILD_CATALOG_SOURCE} -n ${IMAGE_NAMESPACE} -o=jsonpath='{.status.connectionState.lastObservedState}')
+    if [ "${STATE}" == "READY" ]; then
+      let catalog_ready=1
+      echo "Info: Catalog source is ready"
+      continue
+    else
+      echo "Warning: catalog source status is not ready."
+      if [ ${timeout} -eq 0 ]; then
+        echo "Error: timedout while awaiting catalog source to start"
+        exit 1
+      fi
+    fi
+
+    sleep 1m
+  done
 
   export KAMEL_INSTALL_OLM_SOURCE_NAMESPACE=${IMAGE_NAMESPACE}
   export KAMEL_INSTALL_OLM_SOURCE=${BUILD_CATALOG_SOURCE}
diff --git a/pkg/util/olm/operator.go b/pkg/util/olm/operator.go
index a2f30a9e7..9bc7a86e0 100644
--- a/pkg/util/olm/operator.go
+++ b/pkg/util/olm/operator.go
@@ -176,6 +176,7 @@ func Install(ctx context.Context, client client.Client, namespace string, global
 			Channel:                options.Channel,
 			StartingCSV:            options.StartingCSV,
 			InstallPlanApproval:    operatorsv1alpha1.ApprovalAutomatic,
+			Config:                 &operatorsv1alpha1.SubscriptionConfig{},
 		},
 	}
 	// Additional configuration
@@ -235,6 +236,15 @@ func maybeSetTolerations(sub *operatorsv1alpha1.Subscription, tolArray []string)
 		if err != nil {
 			return err
 		}
+		if sub == nil {
+			panic("sub is nil")
+		}
+		if sub.Spec == nil {
+			panic("sub.Spec is nil")
+		}
+		if sub.Spec.Config == nil {
+			panic("sub.Spec.Config is nil")
+		}
 		sub.Spec.Config.Tolerations = tolerations
 	}
 	return nil