From e4ad11c1a11ec629f2d65cbda0fa4ea3f6a109d8 Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Fri, 4 Dec 2020 08:52:34 +0100 Subject: [PATCH 01/13] Add nightly olm tests script Signed-off-by: Flavius Lacatusu --- .ci/cico_olm_openshift.sh | 73 ----------------------- .ci/oci-nightly-olm.sh | 119 ++++++++++++++++++++++++++++++++++++++ .ci/util/ci_common.sh | 46 ++++++++++++++- 3 files changed, 164 insertions(+), 74 deletions(-) delete mode 100755 .ci/cico_olm_openshift.sh create mode 100755 .ci/oci-nightly-olm.sh diff --git a/.ci/cico_olm_openshift.sh b/.ci/cico_olm_openshift.sh deleted file mode 100755 index 58b3f5632..000000000 --- a/.ci/cico_olm_openshift.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2012-2020 Red Hat, Inc. -# This program and the accompanying materials are made -# available under the terms of the Eclipse Public License 2.0 -# which is available at https://www.eclipse.org/legal/epl-2.0/ -# -# SPDX-License-Identifier: EPL-2.0 -# - -set -e - -# Detect the base directory where che-operator is cloned -SCRIPT=$(readlink -f "$0") -export SCRIPT - -OPERATOR_REPO=$(dirname "$(dirname "$SCRIPT")"); -export OPERATOR_REPO - -# ENV used by Openshift CI -ARTIFACTS_DIR="/tmp/artifacts" -export ARTIFACTS_DIR - -# Component is defined in Openshift CI job configuration. See: https://github.com/openshift/release/blob/master/ci-operator/config/devfile/devworkspace-operator/devfile-devworkspace-operator-master__v4.yaml#L8 -CI_COMPONENT="che-operator-catalog" -export CI_COMPONENT - -CATALOG_SOURCE_IMAGE_NAME=${CI_COMPONENT}:stable -export CATALOG_SOURCE_IMAGE_NAME - -# This image is builded by Openshift CI and exposed to be consumed for olm tests. -#OPENSHIFT_BUILD_NAMESPACE env var exposed by Openshift CI. More info about how images are builded in Openshift CI: https://github.com/openshift/ci-tools/blob/master/TEMPLATES.md#parameters-available-to-templates -CATALOG_SOURCE_IMAGE="che-catalog" -export CATALOG_SOURCE_IMAGE - -# Choose if install Eclipse Che using an operatorsource or Custom Catalog Source -INSTALLATION_TYPE="catalog" -export INSTALLATION_TYPE - -# Execute olm nightly files in openshift -PLATFORM="openshift" -export PLATFORM - -# Test nightly olm files -CHANNEL="nightly" -export CHANNEL - -# Test nightly olm files -NAMESPACE="che" -export NAMESPACE - -# run function run the tests in ci of custom catalog source. -function run() { - export OAUTH="false" - # Execute test catalog source script - source "${OPERATOR_REPO}"/olm/testCatalogSource.sh ${PLATFORM} ${CHANNEL} ${NAMESPACE} ${INSTALLATION_TYPE} ${CATALOG_SOURCE_IMAGE} - - source "${OPERATOR_REPO}"/.ci/util/ci_common.sh - oc project ${NAMESPACE} - - # Create and start a workspace - getCheAcessToken - chectl workspace:create --start --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml - - getCheAcessToken - chectl workspace:list - waitWorkspaceStart -} - -run - -# grab che-operator namespace events after running olm nightly tests -oc get events -n ${NAMESPACE} | tee ${ARTIFACTS_DIR}/che-operator-events.log diff --git a/.ci/oci-nightly-olm.sh b/.ci/oci-nightly-olm.sh new file mode 100755 index 000000000..cfa424e25 --- /dev/null +++ b/.ci/oci-nightly-olm.sh @@ -0,0 +1,119 @@ +#!/bin/bash +# +# Copyright (c) 2012-2020 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# + +################################ !!! IMPORTANT !!! ################################ +########### THIS JOB use Openshift CI operators workflows to run nightly olm tests #### +########## More info about how it is configured can be found here: https://docs.ci.openshift.org/docs/how-tos/testing-operator-sdk-operators ############# +####################################################################################################################################################### + +export XDG_CONFIG_HOME=/tmp/chectl/config +export XDG_CACHE_HOME=/tmp/chectl/cache +export XDG_DATA_HOME=/tmp/chectl/data + +# exit immediately when a command fails +set -e +# only exit with zero if all commands of the pipeline exit successfully +set -o pipefail +# error on unset variables +set -u + +#Stop execution on any error +trap "catchFinish" EXIT SIGINT + +# Detect the base directory where che-operator is cloned +SCRIPT=$(readlink -f "$0") +export SCRIPT + +OPERATOR_REPO=$(dirname "$(dirname "$SCRIPT")"); +export OPERATOR_REPO + +# Artifacts dir where job will store all che events and logs +ARTIFACTS_DIR="/tmp/artifacts" +export ARTIFACTS_DIR + +# Execute olm nightly files in openshift +PLATFORM="openshift" +export PLATFORM + +# Test nightly olm files +NAMESPACE="eclipse-che" +export NAMESPACE + +# CI_CHE_OPERATOR_IMAGE it is che operator image builded in openshift CI job workflow. More info about how works image dependencies in ci:https://github.com/openshift/ci-tools/blob/master/TEMPLATES.md#parameters-available-to-templates +export OPERATOR_IMAGE=${CI_CHE_OPERATOR_IMAGE:-"quay.io/eclipse/che-operator:nightly"} + +# Get nightly CSV +export CSV_FILE +CSV_FILE="${OPERATOR_REPO}/deploy/olm-catalog/eclipse-che-preview-${PLATFORM}/manifests/che-operator.clusterserviceversion.yaml" + +# Import common functions utilities +source "${OPERATOR_REPO}"/.ci/util/ci_common.sh + +# catchFinish is executed after finish script. +function catchFinish() { + result=$? + mkdir -p ${ARTIFACTS_DIR}/che-logs + + if [ "$result" != "0" ]; then + echo "[ERROR] Please check openshift ci artifacts" + chectl server:logs --chenamespace=${NAMESPACE} --directory=${ARTIFACTS_DIR}/che-logs + exit 1 + fi + + echo "[INFO] Job finished Successfully. Please check the artifacts in openshift ci artifacts" + chectl server:logs --chenamespace=${NAMESPACE} --directory=${ARTIFACTS_DIR}/che-logs + + exit $result +} + +# Utility to print objects created by Openshift CI automatically +function printOlmCheObjects() { + echo -e "[INFO] Operator Group object created in namespace ${NAMESPACE}:" + oc get operatorgroup -n "${NAMESPACE}" -o yaml + + echo -e "[INFO] Catalog Source object created in namespace ${NAMESPACE}:" + oc get catalogsource -n "${NAMESPACE}" -o yaml + + echo -e "[INFO] Subscription object created in namespace ${NAMESPACE}" + oc get subscription -n "${NAMESPACE}" -o yaml +} + +# Patch che operator image with image builded from source in Openshift CI job. +function patchCheOperatorImage() { + echo "[INFO] Getting che operator pod name..." + OPERATOR_POD=$(oc get pods -o json -n ${NAMESPACE} | jq -r '.items[] | select(.metadata.name | test("che-operator-")).metadata.name') + oc patch pod ${OPERATOR_POD} -n ${NAMESPACE} --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":'${OPERATOR_IMAGE}'}]' + + # The following command retrieve the operator image + OPERATOR_POD_IMAGE=$(oc get pods -n ${NAMESPACE} -o json | jq -r '.items[] | select(.metadata.name | test("che-operator-")).spec.containers[].image') + echo "[INFO] CHE operator image is ${OPERATOR_POD_IMAGE}" +} + +# Run che deployment after patch operator image. +function deployEclipseChe() { + export OAUTH="false" + + # Deploy Eclipse Che applying CR + applyCRCheCluster + waitCheServerDeploy + + # Create a workspace + getCheAcessToken + chectl workspace:create --start --chenamespace=${NAMESPACE} --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml + + # Start a workspace and wait until workspace it is alive + getCheAcessToken + chectl workspace:list --chenamespace=${NAMESPACE} + waitWorkspaceStart +} + +printOlmCheObjects +patchCheOperatorImage +deployEclipseChe diff --git a/.ci/util/ci_common.sh b/.ci/util/ci_common.sh index ac9da07d5..b74ee657e 100644 --- a/.ci/util/ci_common.sh +++ b/.ci/util/ci_common.sh @@ -37,9 +37,10 @@ function waitWorkspaceStart() { do getCheAcessToken - chectl workspace:list + chectl workspace:list --chenamespace=${NAMESPACE} workspaceList=$(chectl workspace:list --chenamespace=${NAMESPACE}) workspaceStatus=$(echo "$workspaceList" | grep RUNNING | awk '{ print $4} ') + echo -e "" if [ "${workspaceStatus:-NOT_RUNNING}" == "RUNNING" ] then @@ -57,6 +58,49 @@ function waitWorkspaceStart() { fi } +# Create cheCluster object in Openshift ci with desired values +function applyCRCheCluster() { + echo "Creating Custom Resource" + CRs=$(yq -r '.metadata.annotations["alm-examples"]' "${CSV_FILE}") + CR=$(echo "$CRs" | yq -r ".[0]") + if [ "${PLATFORM}" == "kubernetes" ] + then + CR=$(echo "$CR" | yq -r ".spec.k8s.ingressDomain = \"$(minikube ip).nip.io\"") + fi + if [ "${PLATFORM}" == "openshift" ] && [ "${OAUTH}" == "false" ]; then + CR=$(echo "$CR" | yq -r ".spec.auth.openShiftoAuth = false") + fi + + echo "$CR" | oc apply -n "${NAMESPACE}" -f - +} + +# Wait for CheCluster object to be ready +function waitCheServerDeploy() { + echo "[INFO] Waiting for Che server to be deployed" + set +e + + i=0 + while [[ $i -le 480 ]] + do + status=$(oc get checluster/eclipse-che -n "${NAMESPACE}" -o jsonpath={.status.cheClusterRunning}) + echo -e "" + echo -e "[INFO] Che deployment status:" + oc get pods -n "${NAMESPACE}" + if [ "${status:-UNAVAILABLE}" == "Available" ] + then + break + fi + sleep 10 + ((i++)) + done + + if [ $i -gt 480 ] + then + echo "[ERROR] Che server did't start after 8 minutes" + exit 1 + fi +} + # Utility to get all logs from che function getCheClusterLogs() { mkdir -p /tmp/artifacts-che From 33b03866f5b115c849097a02a62467e1377c1681 Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Wed, 9 Dec 2020 08:44:39 +0100 Subject: [PATCH 02/13] Fixes Signed-off-by: Flavius Lacatusu --- .github/bin/minikube/provision-cluster.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/bin/minikube/provision-cluster.sh b/.github/bin/minikube/provision-cluster.sh index 503580886..e6c4fac2a 100755 --- a/.github/bin/minikube/provision-cluster.sh +++ b/.github/bin/minikube/provision-cluster.sh @@ -10,9 +10,10 @@ # Contributors: # Red Hat, Inc. - initial API and implementation set -ex + # Minikube environments config -export MINIKUBE_VERSION=v1.15.1 -export KUBERNETES_VERSION=v1.19.4 +export MINIKUBE_VERSION=v1.8.2 +export KUBERNETES_VERSION=v1.16.2 export MINIKUBE_HOME=$HOME export CHANGE_MINIKUBE_NONE_USER=true export KUBECONFIG=$HOME/.kube/config From 81165dc4c0f9c49032d75bd71319b231cd7a5a9a Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Wed, 9 Dec 2020 14:01:45 +0100 Subject: [PATCH 03/13] Fixes Signed-off-by: Flavius Lacatusu --- .github/bin/common.sh | 2 +- .github/bin/minikube/test-update-olm.sh | 45 +++++-------------------- 2 files changed, 10 insertions(+), 37 deletions(-) diff --git a/.github/bin/common.sh b/.github/bin/common.sh index 012cf924b..d854f019f 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -252,7 +252,7 @@ setCustomOperatorImage() { } insecurePrivateDockerRegistry() { - IMAGE_REGISTRY_HOST="$(minikube ip):5000" + IMAGE_REGISTRY_HOST="0.0.0.0:5000" export IMAGE_REGISTRY_HOST local dockerDaemonConfig="/etc/docker/daemon.json" diff --git a/.github/bin/minikube/test-update-olm.sh b/.github/bin/minikube/test-update-olm.sh index b6b2323cf..3774c6a77 100755 --- a/.github/bin/minikube/test-update-olm.sh +++ b/.github/bin/minikube/test-update-olm.sh @@ -11,48 +11,21 @@ # Red Hat, Inc. - initial API and implementation set -e +set -x export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname $(readlink -f "${BASH_SOURCE[0]}"))))) -NAMESPACE="eclipse-che" -export CTSRC_IMAGE="myimage:latest" -export CONTAINER_HOST=ssh://root@linuxhost/run/podman/podman.sock - - -#"imagePullPolicy":"IfNotPresent" source "${OPERATOR_REPO}"/.github/bin/common.sh # Stop execution on any error trap "catchFinish" EXIT SIGINT -insecurePrivateDockerRegistry - -# Build latest stable catalog image -buildK8SCheCatalogImage() { - echo ${OPERATOR_REPO} - eval $(minikube podman-env) - podman build -t "${CTSRC_IMAGE}" -f "${OPERATOR_REPO}"/olm/eclipse-che-preview-kubernetes/Dockerfile ${OPERATOR_REPO}/olm/eclipse-che-preview-kubernetes - printf '%s\t%s\n' "$(minikube ip)" 'registry.kube' | sudo tee -a /etc/hosts - - podman push $CTSRC_IMAGE $(minikube ip):5000/$CTSRC_IMAGE - exit 0 +runTest() { + "${OPERATOR_REPO}"/olm/testUpdate.sh "kubernetes" "stable" ${NAMESPACE} + waitEclipseCheDeployed ${LAST_PACKAGE_VERSION} + startNewWorkspace + waitWorkspaceStart } -buildK8SCheCatalogImage - -CATSRC=$( - oc create -f - -o jsonpath='{.metadata.name}' < Date: Wed, 9 Dec 2020 15:08:36 +0100 Subject: [PATCH 04/13] Fixes Signed-off-by: Flavius Lacatusu --- .github/bin/common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/bin/common.sh b/.github/bin/common.sh index d854f019f..0fe3b7779 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -197,13 +197,13 @@ startNewWorkspace() { # Create and start a workspace sleep 5s chectl auth:login -u admin -p admin - chectl workspace:create --start --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml + chectl workspace:create --start --devfile=$OPERATOR_REPO/.ci/devfile-test.yaml } createWorkspace() { sleep 5s chectl auth:login -u admin -p admin - chectl workspace:create --devfile=${OPERATOR_REPO}/.ci/util/devfile-test.yaml + chectl workspace:create --devfile=${OPERATOR_REPO}/.ci/devfile-test.yaml } startExistedWorkspace() { From 27dd9c1d78cf42c41ae24070f36af97ad0f4e32d Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Thu, 10 Dec 2020 07:52:43 +0100 Subject: [PATCH 05/13] Use common bash scripts Signed-off-by: Flavius Lacatusu --- .ci/common.sh | 92 ---------------------------------- .ci/oci-nightly-olm.sh | 21 +++++++- .ci/oci-single-host.sh | 18 ++++++- .github/bin/common.sh | 22 ++++---- .github/bin/minishift/certs.sh | 4 +- 5 files changed, 49 insertions(+), 108 deletions(-) delete mode 100644 .ci/common.sh diff --git a/.ci/common.sh b/.ci/common.sh deleted file mode 100644 index ffd2ec20c..000000000 --- a/.ci/common.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2012-2020 Red Hat, Inc. -# This program and the accompanying materials are made -# available under the terms of the Eclipse Public License 2.0 -# which is available at https://www.eclipse.org/legal/epl-2.0/ -# -# SPDX-License-Identifier: EPL-2.0 -# -# Contributors: -# Red Hat, Inc. - initial API and implementation - -set -e - -# Create CheCluster object in Openshift ci with desired values -function applyCRCheCluster() { - echo "Creating Custom Resource" - CRs=$(yq -r '.metadata.annotations["alm-examples"]' "${CSV_FILE}") - CR=$(echo "$CRs" | yq -r ".[0]") - if [ "${PLATFORM}" == "openshift" ] && [ "${OAUTH}" == "false" ]; then - CR=$(echo "$CR" | yq -r ".spec.auth.openShiftoAuth = false") - fi - if [ "${CHE_EXPOSURE_STRATEGY}" == "single-host" ] - then - CR=$(echo "$CR" | yq -r ".spec.server.serverExposureStrategy = \"${CHE_EXPOSURE_STRATEGY}\"") - fi - echo -e "$CR" - echo "$CR" | oc apply -n "${NAMESPACE}" -f - -} - -# Wait for CheCluster object to be ready -function waitCheServerDeploy() { - echo "[INFO] Waiting for Che server to be deployed" - set +e - - i=0 - while [[ $i -le 480 ]] - do - status=$(oc get checluster/eclipse-che -n "${NAMESPACE}" -o jsonpath={.status.cheClusterRunning}) - echo -e "" - echo -e "[INFO] Che deployment status:" - oc get pods -n "${NAMESPACE}" - if [ "${status:-UNAVAILABLE}" == "Available" ] - then - break - fi - sleep 10 - ((i++)) - done - - if [ $i -gt 480 ] - then - echo "[ERROR] Che server did't start after 8 minutes" - exit 1 - fi -} - -# Utility to wait for a workspace to be started after workspace:create. -function waitWorkspaceStart() { - set +e - chectl auth:login --chenamespace=${NAMESPACE} -u admin -p admin - - export x=0 - while [ $x -le 180 ] - do - chectl workspace:list --chenamespace=${NAMESPACE} - workspaceList=$(chectl workspace:list --chenamespace=${NAMESPACE}) - workspaceStatus=$(echo "$workspaceList" | grep RUNNING | awk '{ print $4} ') - echo -e "" - - if [ "${workspaceStatus:-NOT_RUNNING}" == "RUNNING" ] - then - echo "[INFO] Workspace started successfully" - break - fi - sleep 10 - x=$(( x+1 )) - done - - if [ $x -gt 180 ] - then - echo -e "[ERROR] Workspace didn't start after 3 minutes." - exit 1 - fi -} - -function startNewWorkspace() { - # Create and start a workspace - sleep 5s - chectl auth:login -u admin -p admin --chenamespace=${NAMESPACE} - chectl workspace:create --chenamespace=${NAMESPACE} --start --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml -} diff --git a/.ci/oci-nightly-olm.sh b/.ci/oci-nightly-olm.sh index 81e6495d6..65c6a1280 100755 --- a/.ci/oci-nightly-olm.sh +++ b/.ci/oci-nightly-olm.sh @@ -17,6 +17,7 @@ export XDG_CONFIG_HOME=/tmp/chectl/config export XDG_CACHE_HOME=/tmp/chectl/cache export XDG_DATA_HOME=/tmp/chectl/data + # exit immediately when a command fails set -e # only exit with zero if all commands of the pipeline exit successfully @@ -58,7 +59,7 @@ CHE_EXPOSURE_STRATEGY="multiuser" export CHE_EXPOSURE_STRATEGY # Import common functions utilities -source "${OPERATOR_REPO}"/.ci/common.sh +source "${OPERATOR_REPO}"/.github/bin/common.sh # catchFinish is executed after finish script. function catchFinish() { @@ -100,13 +101,29 @@ function patchCheOperatorImage() { echo -e "[INFO] CHE operator image is ${OPERATOR_POD_IMAGE}" } +# Create CheCluster object in Openshift ci with desired values +function applyCRCheCluster() { + echo "Creating Custom Resource" + CRs=$(yq -r '.metadata.annotations["alm-examples"]' "${CSV_FILE}") + CR=$(echo "$CRs" | yq -r ".[0]") + if [ "${PLATFORM}" == "openshift" ] && [ "${OAUTH}" == "false" ]; then + CR=$(echo "$CR" | yq -r ".spec.auth.openShiftoAuth = false") + fi + if [ "${CHE_EXPOSURE_STRATEGY}" == "single-host" ] + then + CR=$(echo "$CR" | yq -r ".spec.server.serverExposureStrategy = \"${CHE_EXPOSURE_STRATEGY}\"") + fi + echo -e "$CR" + echo "$CR" | oc apply -n "${NAMESPACE}" -f - +} + # Run che deployment after patch operator image. function deployEclipseChe() { export OAUTH="false" # Deploy Eclipse Che applying CR applyCRCheCluster - waitCheServerDeploy + waitEclipseCheDeployed startNewWorkspace diff --git a/.ci/oci-single-host.sh b/.ci/oci-single-host.sh index 8feba0512..8d3d01ec2 100755 --- a/.ci/oci-single-host.sh +++ b/.ci/oci-single-host.sh @@ -100,13 +100,29 @@ function patchCheOperatorImage() { echo "[INFO] CHE operator image is ${OPERATOR_POD_IMAGE}" } +# Create CheCluster object in Openshift ci with desired values +function applyCRCheCluster() { + echo "Creating Custom Resource" + CRs=$(yq -r '.metadata.annotations["alm-examples"]' "${CSV_FILE}") + CR=$(echo "$CRs" | yq -r ".[0]") + if [ "${PLATFORM}" == "openshift" ] && [ "${OAUTH}" == "false" ]; then + CR=$(echo "$CR" | yq -r ".spec.auth.openShiftoAuth = false") + fi + if [ "${CHE_EXPOSURE_STRATEGY}" == "single-host" ] + then + CR=$(echo "$CR" | yq -r ".spec.server.serverExposureStrategy = \"${CHE_EXPOSURE_STRATEGY}\"") + fi + echo -e "$CR" + echo "$CR" | oc apply -n "${NAMESPACE}" -f - +} + # Run che deployment after patch operator image. function deployEclipseChe() { export OAUTH="false" # Deploy Eclipse Che applying CR applyCRCheCluster - waitCheServerDeploy + waitEclipseCheDeployed startNewWorkspace diff --git a/.github/bin/common.sh b/.github/bin/common.sh index 0fe3b7779..441e739f4 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -31,7 +31,7 @@ init() { export SCRIPT=$(readlink -f "$0") export SCRIPT_DIR=$(dirname "$SCRIPT") export RAM_MEMORY=8192 - export NAMESPACE="che" + export NAMESPACE="eclipse-che" export ARTIFACTS_DIR="/tmp/artifacts-che" export TEMPLATES=${OPERATOR_REPO}/tmp export OPERATOR_IMAGE="quay.io/eclipse/che-operator:test" @@ -89,7 +89,7 @@ waitWorkspaceStart() { export x=0 while [ $x -le 180 ] do - chectl auth:login -u admin -p admin + chectl auth:login -u admin -p admin --chenamespace=${NAMESPACE} chectl workspace:list workspaceList=$(chectl workspace:list --chenamespace=${NAMESPACE}) workspaceStatus=$(echo "$workspaceList" | grep RUNNING | awk '{ print $4} ') @@ -123,7 +123,7 @@ installYq() { # Graps Eclipse Che logs collectCheLogWithChectl() { mkdir -p ${ARTIFACTS_DIR} - chectl server:logs --directory=${ARTIFACTS_DIR} + chectl server:logs --chenamespace=${NAMESPACE} --directory=${ARTIFACTS_DIR} } # Build latest operator image @@ -190,27 +190,27 @@ updateEclipseChe() { local image=$1 local templates=$2 - chectl server:update -y --che-operator-image=${image} --templates=${templates} + chectl server:update --chenamespace=${NAMESPACE} -y --che-operator-image=${image} --templates=${templates} } startNewWorkspace() { # Create and start a workspace sleep 5s - chectl auth:login -u admin -p admin - chectl workspace:create --start --devfile=$OPERATOR_REPO/.ci/devfile-test.yaml + chectl auth:login -u admin -p admin --chenamespace=${NAMESPACE} + chectl workspace:create --start --chenamespace=${NAMESPACE} --devfile=$OPERATOR_REPO/.ci/devfile-test.yaml } createWorkspace() { sleep 5s - chectl auth:login -u admin -p admin - chectl workspace:create --devfile=${OPERATOR_REPO}/.ci/devfile-test.yaml + chectl auth:login -u admin -p admin --chenamespace=${NAMESPACE} + chectl workspace:create --chenamespace=${NAMESPACE} --devfile=${OPERATOR_REPO}/.ci/devfile-test.yaml } startExistedWorkspace() { sleep 5s - chectl auth:login -u admin -p admin - chectl workspace:list - workspaceList=$(chectl workspace:list) + chectl auth:login -u admin -p admin --chenamespace=${NAMESPACE} + chectl workspace:list --chenamespace=${NAMESPACE} + workspaceList=$(chectl workspace:list --chenamespace=${NAMESPACE}) # Grep applied to MacOS workspaceID=$(echo "$workspaceList" | grep workspace | awk '{ print $1} ') diff --git a/.github/bin/minishift/certs.sh b/.github/bin/minishift/certs.sh index e21c10d13..757a7e4d7 100755 --- a/.github/bin/minishift/certs.sh +++ b/.github/bin/minishift/certs.sh @@ -52,12 +52,12 @@ sleep 60 eval $(minishift oc-env) oc login -u system:admin --insecure-skip-tls-verify=true -oc create namespace che +oc create namespace eclipse-che oc project default oc delete secret router-certs cat domain.crt domain.key > minishift.crt oc create secret tls router-certs --key=domain.key --cert=minishift.crt oc rollout latest router -oc create secret generic self-signed-certificate --from-file=ca.crt -n=che +oc create secret generic self-signed-certificate --from-file=ca.crt -n=eclipse-che oc adm policy add-cluster-role-to-user cluster-admin developer && oc login -u developer -p developer From 8ed79bed5fa151fa62c37be88bca551076a1d701 Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Thu, 10 Dec 2020 08:11:58 +0100 Subject: [PATCH 06/13] fixes Signed-off-by: Flavius Lacatusu --- .github/bin/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/bin/common.sh b/.github/bin/common.sh index 441e739f4..db822b06b 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -90,7 +90,7 @@ waitWorkspaceStart() { while [ $x -le 180 ] do chectl auth:login -u admin -p admin --chenamespace=${NAMESPACE} - chectl workspace:list + chectl workspace:list --chenamespace=${NAMESPACE} workspaceList=$(chectl workspace:list --chenamespace=${NAMESPACE}) workspaceStatus=$(echo "$workspaceList" | grep RUNNING | awk '{ print $4} ') From c1db99d060ad0adbfee6f5b826874d64a2f6bfe9 Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Thu, 10 Dec 2020 09:08:25 +0100 Subject: [PATCH 07/13] fixes Signed-off-by: Flavius Lacatusu --- .ci/oci-nightly-olm.sh | 29 ----------------------------- .ci/oci-single-host.sh | 31 +------------------------------ .github/bin/common.sh | 12 ++++++++++++ 3 files changed, 13 insertions(+), 59 deletions(-) diff --git a/.ci/oci-nightly-olm.sh b/.ci/oci-nightly-olm.sh index 65c6a1280..3a5f72442 100755 --- a/.ci/oci-nightly-olm.sh +++ b/.ci/oci-nightly-olm.sh @@ -61,35 +61,6 @@ export CHE_EXPOSURE_STRATEGY # Import common functions utilities source "${OPERATOR_REPO}"/.github/bin/common.sh -# catchFinish is executed after finish script. -function catchFinish() { - result=$? - mkdir -p ${ARTIFACTS_DIR}/che-logs - - if [ "$result" != "0" ]; then - echo "[ERROR] Please check openshift ci artifacts" - chectl server:logs --chenamespace=${NAMESPACE} --directory=${ARTIFACTS_DIR}/che-logs - exit 1 - fi - - echo "[INFO] Job finished Successfully. Please check the artifacts in openshift ci artifacts" - chectl server:logs --chenamespace=${NAMESPACE} --directory=${ARTIFACTS_DIR}/che-logs - - exit $result -} - -# Utility to print objects created by Openshift CI automatically -function printOlmCheObjects() { - echo -e "[INFO] Operator Group object created in namespace: ${NAMESPACE}" - oc get operatorgroup -n "${NAMESPACE}" -o yaml - - echo -e "[INFO] Catalog Source object created in namespace: ${NAMESPACE}" - oc get catalogsource -n "${NAMESPACE}" -o yaml - - echo -e "[INFO] Subscription object created in namespace: ${NAMESPACE}" - oc get subscription -n "${NAMESPACE}" -o yaml -} - # Patch che operator image with image builded from source in Openshift CI job. function patchCheOperatorImage() { echo -e "[INFO] Getting che operator pod name..." diff --git a/.ci/oci-single-host.sh b/.ci/oci-single-host.sh index 8d3d01ec2..1a1424e9c 100755 --- a/.ci/oci-single-host.sh +++ b/.ci/oci-single-host.sh @@ -58,36 +58,7 @@ CHE_EXPOSURE_STRATEGY="single-host" export CHE_EXPOSURE_STRATEGY # Import common functions utilities -source "${OPERATOR_REPO}"/.ci/common.sh - -# catchFinish is executed after finish script. -function catchFinish() { - result=$? - mkdir -p ${ARTIFACTS_DIR}/che-logs - - if [ "$result" != "0" ]; then - echo "[ERROR] Please check openshift ci artifacts" - chectl server:logs --chenamespace=${NAMESPACE} --directory=${ARTIFACTS_DIR}/che-logs - exit 1 - fi - - echo "[INFO] Job finished Successfully. Please check the artifacts in openshift ci artifacts" - chectl server:logs --chenamespace=${NAMESPACE} --directory=${ARTIFACTS_DIR}/che-logs - - exit $result -} - -# Utility to print objects created by Openshift CI automatically -function printOlmCheObjects() { - echo -e "[INFO] Operator Group object created in namespace ${NAMESPACE}:" - oc get operatorgroup -n "${NAMESPACE}" -o yaml - - echo -e "[INFO] Catalog Source object created in namespace ${NAMESPACE}:" - oc get catalogsource -n "${NAMESPACE}" -o yaml - - echo -e "[INFO] Subscription object created in namespace ${NAMESPACE}" - oc get subscription -n "${NAMESPACE}" -o yaml -} +source "${OPERATOR_REPO}"/.github/bin/common.sh # Patch che operator image with image builded from source in Openshift CI job. function patchCheOperatorImage() { diff --git a/.github/bin/common.sh b/.github/bin/common.sh index db822b06b..879a8edea 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -267,3 +267,15 @@ insecurePrivateDockerRegistry() { sudo service docker restart fi } + +# Utility to print objects created by Openshift CI automatically +function printOlmCheObjects() { + echo -e "[INFO] Operator Group object created in namespace: ${NAMESPACE}" + oc get operatorgroup -n "${NAMESPACE}" -o yaml + + echo -e "[INFO] Catalog Source object created in namespace: ${NAMESPACE}" + oc get catalogsource -n "${NAMESPACE}" -o yaml + + echo -e "[INFO] Subscription object created in namespace: ${NAMESPACE}" + oc get subscription -n "${NAMESPACE}" -o yaml +} From 0aaf04df519b62dc6c3c36c715c4f19168daf9f7 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Thu, 10 Dec 2020 11:18:43 +0200 Subject: [PATCH 08/13] Refactor test scripts Signed-off-by: Anatolii Bazko --- .ci/oci-nightly-olm.sh | 87 +++++++----------------------------------- .github/bin/common.sh | 30 ++++++++++++++- 2 files changed, 42 insertions(+), 75 deletions(-) diff --git a/.ci/oci-nightly-olm.sh b/.ci/oci-nightly-olm.sh index 3a5f72442..e23c66fb6 100755 --- a/.ci/oci-nightly-olm.sh +++ b/.ci/oci-nightly-olm.sh @@ -13,11 +13,6 @@ ########## More info about how it is configured can be found here: https://docs.ci.openshift.org/docs/how-tos/testing-operator-sdk-operators ############# ####################################################################################################################################################### -export XDG_CONFIG_HOME=/tmp/chectl/config -export XDG_CACHE_HOME=/tmp/chectl/cache -export XDG_DATA_HOME=/tmp/chectl/data - - # exit immediately when a command fails set -e # only exit with zero if all commands of the pipeline exit successfully @@ -25,83 +20,27 @@ set -o pipefail # error on unset variables set -u +export OPERATOR_REPO=$(dirname $(dirname $(readlink -f "$0"))); +source "${OPERATOR_REPO}"/.github/bin/common.sh + #Stop execution on any error trap "catchFinish" EXIT SIGINT -# Detect the base directory where che-operator is cloned -SCRIPT=$(readlink -f "$0") -export SCRIPT - -OPERATOR_REPO=$(dirname "$(dirname "$SCRIPT")"); -export OPERATOR_REPO - -# Artifacts dir where job will store all che events and logs -ARTIFACTS_DIR="/tmp/artifacts" -export ARTIFACTS_DIR - -# Execute olm nightly files in openshift -PLATFORM="openshift" -export PLATFORM - -# Test nightly olm files -NAMESPACE="eclipse-che" -export NAMESPACE - -# CI_CHE_OPERATOR_IMAGE it is che operator image builded in openshift CI job workflow. More info about how works image dependencies in ci:https://github.com/openshift/ci-tools/blob/master/TEMPLATES.md#parameters-available-to-templates -export OPERATOR_IMAGE=${CI_CHE_OPERATOR_IMAGE:-"quay.io/eclipse/che-operator:nightly"} - -# Get nightly CSV -export CSV_FILE -CSV_FILE="${OPERATOR_REPO}/deploy/olm-catalog/eclipse-che-preview-${PLATFORM}/manifests/che-operator.clusterserviceversion.yaml" - -# Define Che exposure strategy -CHE_EXPOSURE_STRATEGY="multiuser" -export CHE_EXPOSURE_STRATEGY - -# Import common functions utilities -source "${OPERATOR_REPO}"/.github/bin/common.sh - -# Patch che operator image with image builded from source in Openshift CI job. -function patchCheOperatorImage() { - echo -e "[INFO] Getting che operator pod name..." - OPERATOR_POD=$(oc get pods -o json -n ${NAMESPACE} | jq -r '.items[] | select(.metadata.name | test("che-operator-")).metadata.name') - oc patch pod ${OPERATOR_POD} -n ${NAMESPACE} --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":'${OPERATOR_IMAGE}'}]' - - # The following command retrieve the operator image - OPERATOR_POD_IMAGE=$(oc get pods -n ${NAMESPACE} -o json | jq -r '.items[] | select(.metadata.name | test("che-operator-")).spec.containers[].image') - echo -e "[INFO] CHE operator image is ${OPERATOR_POD_IMAGE}" +overrideDefaults() { + # CI_CHE_OPERATOR_IMAGE it is che operator image builded in openshift CI job workflow. More info about how works image dependencies in ci:https://github.com/openshift/ci-tools/blob/master/TEMPLATES.md#parameters-available-to-templates + export OPERATOR_IMAGE=${CI_CHE_OPERATOR_IMAGE:-"quay.io/eclipse/che-operator:nightly"} } -# Create CheCluster object in Openshift ci with desired values -function applyCRCheCluster() { - echo "Creating Custom Resource" - CRs=$(yq -r '.metadata.annotations["alm-examples"]' "${CSV_FILE}") - CR=$(echo "$CRs" | yq -r ".[0]") - if [ "${PLATFORM}" == "openshift" ] && [ "${OAUTH}" == "false" ]; then - CR=$(echo "$CR" | yq -r ".spec.auth.openShiftoAuth = false") - fi - if [ "${CHE_EXPOSURE_STRATEGY}" == "single-host" ] - then - CR=$(echo "$CR" | yq -r ".spec.server.serverExposureStrategy = \"${CHE_EXPOSURE_STRATEGY}\"") - fi - echo -e "$CR" - echo "$CR" | oc apply -n "${NAMESPACE}" -f - -} - -# Run che deployment after patch operator image. -function deployEclipseChe() { - export OAUTH="false" - +runTests() { # Deploy Eclipse Che applying CR - applyCRCheCluster - waitEclipseCheDeployed - + applyOlmCR + waitEclipseCheDeployed "nightly" startNewWorkspace - - chectl workspace:list --chenamespace=${NAMESPACE} waitWorkspaceStart } +init +overrideDefaults +patchCheOperEclipseCheOperatorSubscription printOlmCheObjects -patchCheOperatorImage -deployEclipseChe +runTests diff --git a/.github/bin/common.sh b/.github/bin/common.sh index 879a8edea..d8be4e00e 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -36,10 +36,15 @@ init() { export TEMPLATES=${OPERATOR_REPO}/tmp export OPERATOR_IMAGE="quay.io/eclipse/che-operator:test" + export CHE_EXPOSURE_STRATEGY="multi-host" + export OAUTH="false" + export XDG_DATA_HOME=/tmp/chectl/data export XDG_CACHE_HOME=/tmp/chectl/cache export XDG_CONFIG_HOME=/tmp/chectl/config + export OPENSHIFT_NIGHTLY_CSV_FILE="${OPERATOR_REPO}/deploy/olm-catalog/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml" + # prepare templates directory rm -rf ${TEMPLATES} mkdir -p "${TEMPLATES}/che-operator" && chmod 777 "${TEMPLATES}" @@ -269,7 +274,7 @@ insecurePrivateDockerRegistry() { } # Utility to print objects created by Openshift CI automatically -function printOlmCheObjects() { +printOlmCheObjects() { echo -e "[INFO] Operator Group object created in namespace: ${NAMESPACE}" oc get operatorgroup -n "${NAMESPACE}" -o yaml @@ -279,3 +284,26 @@ function printOlmCheObjects() { echo -e "[INFO] Subscription object created in namespace: ${NAMESPACE}" oc get subscription -n "${NAMESPACE}" -o yaml } + +# Patch subscription with image builded from source in Openshift CI job. +patchEclipseCheOperatorSubscription() { + OPERATOR_POD=$(oc get pods -o json -n ${NAMESPACE} | jq -r '.items[] | select(.metadata.name | test("che-operator-")).metadata.name') + oc patch pod ${OPERATOR_POD} -n ${NAMESPACE} --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":'${OPERATOR_IMAGE}'}]' + + # The following command retrieve the operator image + OPERATOR_POD_IMAGE=$(oc get pods -n ${NAMESPACE} -o json | jq -r '.items[] | select(.metadata.name | test("che-operator-")).spec.containers[].image') + echo -e "[INFO] CHE operator image is ${OPERATOR_POD_IMAGE}" +} + +# Create CheCluster object in Openshift ci with desired values +applyOlmCR() { + echo "Creating Custom Resource" + + CRs=$(yq -r '.metadata.annotations["alm-examples"]' "${OPENSHIFT_NIGHTLY_CSV_FILE}") + CR=$(echo "$CRs" | yq -r ".[0]") + CR=$(echo "$CR" | yq -r ".spec.auth.openShiftoAuth = \"${OAUTH}\"") + CR=$(echo "$CR" | yq -r ".spec.server.serverExposureStrategy = \"${CHE_EXPOSURE_STRATEGY}\"") + + echo -e "$CR" + echo "$CR" | oc apply -n "${NAMESPACE}" -f - +} From f81487586c9845c6a77e1bab5955118627162340 Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Thu, 10 Dec 2020 11:23:18 +0100 Subject: [PATCH 09/13] fixes Signed-off-by: Flavius Lacatusu --- .ci/oci-nightly-olm.sh | 2 +- .ci/oci-single-host.sh | 87 +++++++----------------------------------- 2 files changed, 15 insertions(+), 74 deletions(-) diff --git a/.ci/oci-nightly-olm.sh b/.ci/oci-nightly-olm.sh index e23c66fb6..6c2b6e7d0 100755 --- a/.ci/oci-nightly-olm.sh +++ b/.ci/oci-nightly-olm.sh @@ -41,6 +41,6 @@ runTests() { init overrideDefaults -patchCheOperEclipseCheOperatorSubscription +patchEclipseCheOperatorSubscription printOlmCheObjects runTests diff --git a/.ci/oci-single-host.sh b/.ci/oci-single-host.sh index 1a1424e9c..ac5fa51c9 100755 --- a/.ci/oci-single-host.sh +++ b/.ci/oci-single-host.sh @@ -13,10 +13,6 @@ ########## More info about how it is configured can be found here: https://docs.ci.openshift.org/docs/how-tos/testing-operator-sdk-operators ############# ####################################################################################################################################################### -export XDG_CONFIG_HOME=/tmp/chectl/config -export XDG_CACHE_HOME=/tmp/chectl/cache -export XDG_DATA_HOME=/tmp/chectl/data - # exit immediately when a command fails set -e # only exit with zero if all commands of the pipeline exit successfully @@ -24,83 +20,28 @@ set -o pipefail # error on unset variables set -u +export OPERATOR_REPO=$(dirname $(dirname $(readlink -f "$0"))); +source "${OPERATOR_REPO}"/.github/bin/common.sh + #Stop execution on any error trap "catchFinish" EXIT SIGINT -# Detect the base directory where che-operator is cloned -SCRIPT=$(readlink -f "$0") -export SCRIPT - -OPERATOR_REPO=$(dirname "$(dirname "$SCRIPT")"); -export OPERATOR_REPO - -# Artifacts dir where job will store all che events and logs -ARTIFACTS_DIR="/tmp/artifacts" -export ARTIFACTS_DIR - -# Execute olm nightly files in openshift -PLATFORM="openshift" -export PLATFORM - -# Test nightly olm files -NAMESPACE="eclipse-che" -export NAMESPACE - -# CI_CHE_OPERATOR_IMAGE it is che operator image builded in openshift CI job workflow. More info about how works image dependencies in ci:https://github.com/openshift/ci-tools/blob/master/TEMPLATES.md#parameters-available-to-templates -export OPERATOR_IMAGE=${CI_CHE_OPERATOR_IMAGE:-"quay.io/eclipse/che-operator:nightly"} - -# Get nightly CSV -CSV_FILE="${OPERATOR_REPO}/deploy/olm-catalog/eclipse-che-preview-${PLATFORM}/manifests/che-operator.clusterserviceversion.yaml" -export CSV_FILE - -# Define Che exposure strategy -CHE_EXPOSURE_STRATEGY="single-host" -export CHE_EXPOSURE_STRATEGY - -# Import common functions utilities -source "${OPERATOR_REPO}"/.github/bin/common.sh - -# Patch che operator image with image builded from source in Openshift CI job. -function patchCheOperatorImage() { - echo "[INFO] Getting che operator pod name..." - OPERATOR_POD=$(oc get pods -o json -n ${NAMESPACE} | jq -r '.items[] | select(.metadata.name | test("che-operator-")).metadata.name') - oc patch pod ${OPERATOR_POD} -n ${NAMESPACE} --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":'${OPERATOR_IMAGE}'}]' - - # The following command retrieve the operator image - OPERATOR_POD_IMAGE=$(oc get pods -n ${NAMESPACE} -o json | jq -r '.items[] | select(.metadata.name | test("che-operator-")).spec.containers[].image') - echo "[INFO] CHE operator image is ${OPERATOR_POD_IMAGE}" +overrideDefaults() { + # CI_CHE_OPERATOR_IMAGE it is che operator image builded in openshift CI job workflow. More info about how works image dependencies in ci:https://github.com/openshift/ci-tools/blob/master/TEMPLATES.md#parameters-available-to-templates + export OPERATOR_IMAGE=${CI_CHE_OPERATOR_IMAGE:-"quay.io/eclipse/che-operator:nightly"} + export CHE_EXPOSURE_STRATEGY="single-host" } -# Create CheCluster object in Openshift ci with desired values -function applyCRCheCluster() { - echo "Creating Custom Resource" - CRs=$(yq -r '.metadata.annotations["alm-examples"]' "${CSV_FILE}") - CR=$(echo "$CRs" | yq -r ".[0]") - if [ "${PLATFORM}" == "openshift" ] && [ "${OAUTH}" == "false" ]; then - CR=$(echo "$CR" | yq -r ".spec.auth.openShiftoAuth = false") - fi - if [ "${CHE_EXPOSURE_STRATEGY}" == "single-host" ] - then - CR=$(echo "$CR" | yq -r ".spec.server.serverExposureStrategy = \"${CHE_EXPOSURE_STRATEGY}\"") - fi - echo -e "$CR" - echo "$CR" | oc apply -n "${NAMESPACE}" -f - -} - -# Run che deployment after patch operator image. -function deployEclipseChe() { - export OAUTH="false" - +runTests() { # Deploy Eclipse Che applying CR - applyCRCheCluster - waitEclipseCheDeployed - + applyOlmCR + waitEclipseCheDeployed "nightly" startNewWorkspace - - chectl workspace:list --chenamespace=${NAMESPACE} waitWorkspaceStart } +init +overrideDefaults +patchEclipseCheOperatorSubscription printOlmCheObjects -patchCheOperatorImage -deployEclipseChe +runTests From 64f368087c3660a0c8835e388605fa097a0085d3 Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Thu, 10 Dec 2020 12:24:09 +0100 Subject: [PATCH 10/13] fixes Signed-off-by: Flavius Lacatusu --- .github/bin/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/bin/common.sh b/.github/bin/common.sh index d8be4e00e..a0e2b206a 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -301,7 +301,7 @@ applyOlmCR() { CRs=$(yq -r '.metadata.annotations["alm-examples"]' "${OPENSHIFT_NIGHTLY_CSV_FILE}") CR=$(echo "$CRs" | yq -r ".[0]") - CR=$(echo "$CR" | yq -r ".spec.auth.openShiftoAuth = \"${OAUTH}\"") + CR=$(echo "$CR" | yq -r ".spec.auth.openShiftoAuth = ${OAUTH}") CR=$(echo "$CR" | yq -r ".spec.server.serverExposureStrategy = \"${CHE_EXPOSURE_STRATEGY}\"") echo -e "$CR" From fcd0865da6499bd9965b398f7dd3d232f608b7dc Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Thu, 10 Dec 2020 14:34:07 +0100 Subject: [PATCH 11/13] Add trap Signed-off-by: Flavius Lacatusu --- .ci/cico_updates_openshift.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.ci/cico_updates_openshift.sh b/.ci/cico_updates_openshift.sh index 571953eb9..208f4e6bf 100755 --- a/.ci/cico_updates_openshift.sh +++ b/.ci/cico_updates_openshift.sh @@ -16,6 +16,9 @@ set -x export OPERATOR_REPO=$(dirname $(dirname $(readlink -f "$0"))); source "${OPERATOR_REPO}"/.github/bin/common.sh +#Stop execution on any error +trap "catchFinish" EXIT SIGINT + runTests() { "${OPERATOR_REPO}"/olm/testUpdate.sh "openshift" "stable" ${NAMESPACE} waitEclipseCheDeployed ${LAST_PACKAGE_VERSION} From ca64df8e77d6e5b4be8f6f75ff982a37b7f76d90 Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Thu, 10 Dec 2020 14:56:11 +0100 Subject: [PATCH 12/13] Tag images Signed-off-by: Flavius Lacatusu --- olm/eclipse-che-preview-kubernetes/Dockerfile | 2 +- olm/eclipse-che-preview-openshift/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/olm/eclipse-che-preview-kubernetes/Dockerfile b/olm/eclipse-che-preview-kubernetes/Dockerfile index c6365cba6..1ad23280b 100644 --- a/olm/eclipse-che-preview-kubernetes/Dockerfile +++ b/olm/eclipse-che-preview-kubernetes/Dockerfile @@ -10,7 +10,7 @@ # Contributors: # Red Hat, Inc. - initial API and implementation -FROM quay.io/operator-framework/upstream-registry-builder as builder +FROM quay.io/operator-framework/upstream-registry-builder:v1.15.3 as builder COPY deploy manifests/eclipse-che-preview-kubernetes RUN /bin/initializer -o ./bundles.db diff --git a/olm/eclipse-che-preview-openshift/Dockerfile b/olm/eclipse-che-preview-openshift/Dockerfile index 96eaaa29c..4c62251f6 100644 --- a/olm/eclipse-che-preview-openshift/Dockerfile +++ b/olm/eclipse-che-preview-openshift/Dockerfile @@ -11,7 +11,7 @@ # Contributors: # Red Hat, Inc. - initial API and implementation -FROM quay.io/operator-framework/upstream-registry-builder as builder +FROM quay.io/operator-framework/upstream-registry-builder:v1.15.3 as builder COPY deploy manifests/eclipse-che-preview-openshift RUN /bin/initializer -o ./bundles.db From 0c4a4024817e19aaa0068ade9af0735a0f5300bf Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Fri, 11 Dec 2020 12:38:33 +0100 Subject: [PATCH 13/13] Re-update testCatalogSource script to older one Signed-off-by: Flavius Lacatusu --- olm/testCatalogSource.sh | 133 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) diff --git a/olm/testCatalogSource.sh b/olm/testCatalogSource.sh index 75b8471eb..c2f27f908 100755 --- a/olm/testCatalogSource.sh +++ b/olm/testCatalogSource.sh @@ -119,6 +119,7 @@ buildOLMImages() { # 1. Kubernetes: # a) Use Minikube cluster. Enable registry addon, build catalog source and olm bundle images, push them to embedded private registry. # b) Provide image registry env variables to push images to the real public registry(docker.io, quay.io etc). + # 2. Openshift: build bundle image and push it using image stream. Launch deployment with custom grpc based catalog source image to install the latest bundle. if [[ "${PLATFORM}" == "kubernetes" ]] then echo "[INFO]: Kubernetes platform detected" @@ -147,6 +148,101 @@ buildOLMImages() { fi echo "[INFO]: Successfully created catalog source container image and enabled minikube ingress." + elif [[ "${PLATFORM}" == "openshift" ]] + then + if [ "${INSTALLATION_TYPE}" == "Marketplace" ];then + return + fi + echo "[INFO]: Starting to build catalog image and push to ImageStream." + + echo "============" + echo "[INFO] Current user is $(oc whoami)" + echo "============" + + oc new-project "${NAMESPACE}" || true + + pull_user="puller" + pull_password="puller" + add_user "${pull_user}" "${pull_password}" + + if [ -z "${KUBECONFIG}" ]; then + KUBECONFIG="${HOME}/.kube/config" + fi + TEMP_KUBE_CONFIG="/tmp/$pull_user.kubeconfig" + rm -rf "${TEMP_KUBE_CONFIG}" + cp "${KUBECONFIG}" "${TEMP_KUBE_CONFIG}" + sleep 180 + + loginLogFile="/tmp/login-log" + touch "${loginLogFile}" + loginCMD="oc login --kubeconfig=${TEMP_KUBE_CONFIG} --username=${pull_user} --password=${pull_password} > ${loginLogFile}" + timeout 900 bash -c "${loginCMD}" || echo "[ERROR] Login Fail" + echo "[INFO] $(cat "${loginLogFile}" || true)" + + echo "[INFO] Applying policy registry-viewer to user '${pull_user}'..." + oc -n "$NAMESPACE" policy add-role-to-user registry-viewer "$pull_user" + + echo "[INFO] Trying to retrieve user '${pull_user}' token..." + token=$(oc --kubeconfig=${TEMP_KUBE_CONFIG} whoami -t) + echo "[INFO] User '${pull_user}' token is: ${token}" + + oc -n "${NAMESPACE}" new-build --binary --strategy=docker --name serverless-bundle + + cp -rf "${PACKAGE_FOLDER_PATH}/bundle.Dockerfile" "${PACKAGE_FOLDER_PATH}/Dockerfile" + if oc -n "${NAMESPACE}" start-build serverless-bundle --from-dir "${PACKAGE_FOLDER_PATH}"; then + rm -rf "${PACKAGE_FOLDER_PATH}/Dockerfile" + else + rm -rf "${PACKAGE_FOLDER_PATH}/Dockerfile" + echo "[ERROR ]Failed to build bundle image." + exit 1 + fi + +cat </dev/null || mktemp -q -d)" + HT_PASSWD_FILE="${PASSWD_TEMP_DIR}/users.htpasswd" + touch "${HT_PASSWD_FILE}" + + htpasswd -b "${HT_PASSWD_FILE}" "$name" "$pass" + echo "HTPASSWD content is:=======================" + cat "${HT_PASSWD_FILE}" + echo "===================================" + + if ! kubectl get secret htpass-secret -n openshift-config 2>/dev/null; then + kubectl create secret generic htpass-secret \ + --from-file=htpasswd="${HT_PASSWD_FILE}" \ + -n openshift-config + fi + +cat <