diff --git a/.ci/README.md b/.ci/README.md index 47b11a03b..62871f1e2 100644 --- a/.ci/README.md +++ b/.ci/README.md @@ -5,40 +5,21 @@ Che Operator currently support two CI flows for Pull Request checks: ## Openshift CI -Openshift is a Kubernetes based CI/CD system. Jobs can be triggered by various types of events and report their status to many different services. In addition to job execution, Openshift CI provides GitHub automation in the form of policy enforcement, chat-ops via /foo style commands, and automatic PR merging. +Openshift CI is a Kubernetes based CI/CD system. Jobs can be triggered by various types of events and report their status to many different services. In addition to job execution, Openshift CI provides GitHub automation in a form of policy enforcement, chat-ops via /foo style commands and automatic PR merging. -All documentation about how to onboard components in Openshift CI can be found in the Openshift CI jobs [repository](https://github.com/openshift/release). One of the requirements to make changes in Openshift CI jobs is being an openshift GitHub member. +All documentation about how to onboard components in Openshift CI can be found in the Openshift CI jobs [repository](https://github.com/openshift/release). All Che operator jobs configurations are defined in `https://github.com/openshift/release/tree/master/ci-operator/config/eclipse-che/che-operator`. -All Che operator jobs configurations are defined in `https://github.com/openshift/release/tree/master/ci-operator/config/eclipse-che/che-operator`. - -### Jobs -- `che-operator-update` - It tests Eclipse Che update from the latest Eclipse Che release version to a new version from the PR and workspace startup. Note this PR check runs against `main` branch and all `7.x.y` branches. -- `che-operator-olm-latest-changes-tests`- It tests Eclipse Che deployment and workspace startup. - -All Openshift CI checks name in pull request have a special nomenclature. Example: `ci/prow/v6-che-operator-update where` where `v6` is Openshift4 minor version. - -### Triggers -All available plugins to trigger in GitHub Pull Request can be found [here](https://github.com/openshift/release/blob/master/core-services/prow/02_config/_plugins.yaml#L3607). The most important plugin is `test ?`, this trigger displays all the available triggers in the PR. In case of a job failure openshift-robot writes a comment about how to trigger a job which fails. +- `operator-test` for testing Eclipse Che deployment +- `devworkspace-happy-path` for happy path testing (including workspace startup) +- `che-behind-proxy` for testing Eclipse Che deployment behind proxy +- `che-upgrade-stable-to-next` for testing Eclipse Che upgrade from the latest stable to a new development version +- `che-operator-update` for testing Eclipse Che upgrade from the latest stable to a new release version ## Github Actions -GitHub Actions is an API for cause and effect on GitHub: orchestrate any workflow, based on any event, while GitHub manages the execution, provides rich feedback, and secures every step along the way. +All che operator actions are defined in the `.github/workflows` yamls. Scripts are located in `.github/bin/minikube` folder. -All che operator actions are defined in the `.github/workflows` yamls. Scripts are located in `.github/action_scripts` folder. - -### Actions - -#### Minikube -For minikube we currently have: -- `Testing stable versions updates` - It tests Eclipse Che update from the latest Eclipse Che release version to a new version from the PR and workspace startup. -- `Testing latest changes`- It tests Eclipse Che deployment in multi host mode and workspace startup. -- `Testing latest changes (single-host/native)` - It tests Eclipse Che deployment in single host mode with `native` exposure type and workspace startup. -- `Testing latest changes (single-host/gateway)` - It tests Eclipse Che deployment in single host mode with `gateway` exposure type and workspace startup. - -#### Minishift -- `Testing stable versions updates` - It tests Eclipse Che update from the latest Eclipse Che release version to a new version from the PR and workspace startup. -- `Testing latest changes` - It tests Eclipse Che deployment in multi host mode and workspace startup. -- `e2e tests` - It runs basic e2e tests. - -### Triggers -To relaunch failed GitHub action checks you have to use GitHub UI (`Re-run jobs` button). Note the button executes the whole workflow. +- `operator-on-minikube` for testing Eclipse Che deployment +- `backup-restore-test-on-minikub` for testing Eclipse Che backup and restore features +- `upgrade-stable-to-next-on-minikube` for testing Eclipse Che upgrade from the latest stable to a new development version +- `upgrade-stable-to-stable-on-minikube` for testing Eclipse Che upgrade from the latest stable to a new release version diff --git a/.ci/cico_updates_openshift.sh b/.ci/cico_updates_openshift.sh index 4ddddd414..f177c80b2 100755 --- a/.ci/cico_updates_openshift.sh +++ b/.ci/cico_updates_openshift.sh @@ -22,7 +22,6 @@ trap "catchFinish" EXIT SIGINT runTests() { "${OPERATOR_REPO}"/olm/testUpdate.sh -c stable -i quay.io/eclipse/eclipse-che-openshift-opm-catalog:test -n ${NAMESPACE} - waitEclipseCheDeployed ${LAST_PACKAGE_VERSION} } initDefaults diff --git a/.ci/oci-single-host.sh b/.ci/oci-single-host.sh index 9ea78c41d..520d4330c 100755 --- a/.ci/oci-single-host.sh +++ b/.ci/oci-single-host.sh @@ -31,12 +31,13 @@ overrideDefaults() { } runTests() { - oc create namespace ${NAMESPACE} || true + createNamespace ${NAMESPACE} useCustomOperatorImageInCSV ${OPERATOR_IMAGE} - createEclipseCheCRFromCSV - waitEclipseCheDeployed "next" + echo "$(getCheClusterCRFromExistedCSV)" | oc apply -n "${NAMESPACE}" -f - + waitEclipseCheDeployed $(getCheVersionFromExistedCSV) + waitDevWorkspaceControllerStarted } diff --git a/.github/bin/common.sh b/.github/bin/common.sh index fdba70d70..c9a142c25 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -11,9 +11,6 @@ # Red Hat, Inc. - initial API and implementation # -set -e -set -x - catchFinish() { result=$? @@ -246,9 +243,11 @@ updateEclipseChe() { } waitEclipseCheDeployed() { + set -x local version=$1 - export n=0 + echo "[INFO] Wait for Eclipse Che '${version}' version" + export n=0 while [ $n -le 500 ] do cheVersion=$(oc get checluster/eclipse-che -n "${NAMESPACE}" -o "jsonpath={.status.cheVersion}") @@ -256,7 +255,7 @@ waitEclipseCheDeployed() { oc get pods -n ${NAMESPACE} if [ "${cheVersion}" == "${version}" ] && [ "${cheIsRunning}" == "Available" ] then - echo "Eclipse Che ${version} has been succesfully deployed" + echo "[INFO] Eclipse Che '${version}' version has been succesfully deployed" break fi sleep 6 @@ -265,7 +264,7 @@ waitEclipseCheDeployed() { if [ $n -gt 360 ] then - echo "Failed to deploy Eclipse Che ${version}" + echo "[ERROR] Failed to deploy Eclipse Che '${version}' verion" exit 1 fi } @@ -275,15 +274,21 @@ useCustomOperatorImageInCSV() { oc patch csv $(getCSVName) -n ${NAMESPACE} --type=json -p '[{"op": "replace", "path": "/spec/install/spec/deployments/0/spec/template/spec/containers/0/image", "value": "'${image}'"}]' } -createEclipseCheCRFromCSV() { - oc get csv $(getCSVName) -n ${NAMESPACE} -o yaml | yq -r ".metadata.annotations[\"alm-examples\"] | fromjson | .[] | select(.kind == \"CheCluster\")" | oc apply -n "${NAMESPACE}" -f - +getCheClusterCRFromExistedCSV() { + oc get csv $(getCSVName) -n ${NAMESPACE} -o yaml | yq -r ".metadata.annotations[\"alm-examples\"] | fromjson | .[] | select(.kind == \"CheCluster\")" +} + +getCheVersionFromExistedCSV() { + oc get csv $(getCSVName) -n ${NAMESPACE} -o yaml | yq -r '.spec.install.spec.deployments[0].spec.template.spec.containers[0].env[] | select(.name == "CHE_VERSION") | .value' } getCSVName() { - echo $(oc get csv -n ${NAMESPACE} | grep eclipse-che-preview-openshift | awk '{print $1}') + oc get csv -n ${NAMESPACE} | grep eclipse-che-preview-openshift | awk '{print $1}' } waitDevWorkspaceControllerStarted() { + echo "[INFO] Wait for Dev Workspace controller started" + n=0 while [ $n -le 24 ] do @@ -317,6 +322,148 @@ spec: registryPoll: interval: 30m EOF - sleep 10s + + sleep 15s kubectl wait --for=condition=ready pod -l olm.catalogSource=community-catalog -n openshift-marketplace --timeout=120s } + +createCatalogSource() { + local name="${1}" + local image="${2}" + + echo "[INFO] Create catalog source '${name}' with image '${image}'" + + kubectl apply -f - < -``` - -Install the previous version of Eclipse Che using the corresponding version of `chectl`: - -```bash -chectl server:deploy --platform=minishift --installer=operator -``` - -Update Eclipse Che to the latest version. Validate that the correct version is installed and workspace can be created: - -```bash -chectl update stable -chectl server:update --platform=minishift --installer=operator -xdg-open http://$(kubectl get ingress -n che | grep ^che | awk -F ' ' '{ print $2 }') -``` - -## 5. Prepare community operator PR +## 4. Prepare community operator PR See `release-community-operator-PRs.yml` workflow, which will be triggered automatically, once release PRs are merged. Alternatively, it can be run manually: diff --git a/bundle/next/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml b/bundle/next/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml index 681f04832..f0a793c9d 100644 --- a/bundle/next/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml +++ b/bundle/next/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml @@ -113,7 +113,7 @@ metadata: operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 repository: https://github.com/eclipse-che/che-operator support: Eclipse Foundation - name: eclipse-che-preview-openshift.v7.42.0-401.next + name: eclipse-che-preview-openshift.v7.42.0-402.next namespace: placeholder spec: apiservicedefinitions: {} @@ -1455,4 +1455,4 @@ spec: maturity: stable provider: name: Eclipse Foundation - version: 7.42.0-401.next + version: 7.42.0-402.next diff --git a/olm/buildCatalog.sh b/olm/buildCatalog.sh index b729d2447..1b9892b5a 100755 --- a/olm/buildCatalog.sh +++ b/olm/buildCatalog.sh @@ -12,7 +12,6 @@ # set -e -set -x export OPERATOR_REPO="${GITHUB_WORKSPACE}" @@ -63,8 +62,21 @@ init() { } usage () { - echo "Usage: $0 -p (openshift|kubernetes) -c (next|stable) -i CATALOG_IMAGE [-f]" - echo "Example: $0 -p openshift -c next -i quay.io/eclipse/eclipse-che-openshift-opm-catalog:next -f" + echo "Build and push custom catalog and bundle images." + echo + echo "Usage:" + echo -e "\t$0 -i CATALOG_IMAGE -c CHANNEL [-o OPERATOR_IMAGE] [--force]" + echo + echo "OPTIONS:" + echo -e "\t-i,--catalog-image Catalog image to build" + echo -e "\t-c,--channel=next|stable Olm channel to build bundle from" + echo -e "\t-o,--operator-image Operator image to include into bundle" + echo -e "\t-f,--force Force to rebuild a bundle" + echo + echo "Example:" + echo -e "\t$0 -i quay.io/eclipse/eclipse-che-openshift-opm-catalog:next -c next" + echo -e "\t$0 -i quay.io/eclipse/eclipse-che-openshift-opm-catalog:next -c next -f" + echo -e "\t$0 -i quay.io/eclipse/eclipse-che-openshift-opm-catalog:test -c stable" } buildBundle() { @@ -107,6 +119,105 @@ isCatalogExists() { skopeo inspect docker://${CATALOG_IMAGE} 2>/dev/null | jq -r ".RepoTags[]|select(. == \"${CATALOG_TAG}\")" | wc -l } +buildBundleImage() { + CATALOG_BUNDLE_IMAGE_NAME_LOCAL="${1}" + if [ -z "${CATALOG_BUNDLE_IMAGE_NAME_LOCAL}" ]; then + echo "[ERROR] 'opm bundle' is not specified" + exit 1 + fi + channel="${2}" + if [ -z "${channel}" ]; then + echo "[ERROR] 'channel' is not specified" + exit 1 + fi + imageTool="${3}" + if [ -z "${imageTool}" ]; then + echo "[ERROR] 'imageTool' is not specified" + exit 1 + fi + + echo "[INFO] build bundle image" + + pushd "${ROOT_DIR}" || exit + + make bundle-build bundle-push channel="${channel}" BUNDLE_IMG="${CATALOG_BUNDLE_IMAGE_NAME_LOCAL}" IMAGE_TOOL="${imageTool}" + popd || exit +} + +buildCatalogImage() { + CATALOG_IMAGENAME="${1}" + if [ -z "${CATALOG_IMAGENAME}" ]; then + echo "[ERROR] Please specify first argument: 'catalog image'" + exit 1 + fi + + CATALOG_BUNDLE_IMAGE_NAME_LOCAL="${2}" + if [ -z "${CATALOG_BUNDLE_IMAGE_NAME_LOCAL}" ]; then + echo "[ERROR] Please specify second argument: 'opm bundle image'" + exit 1 + fi + + imageTool="${3}" + if [ -z "${imageTool}" ]; then + echo "[ERROR] Please specify third argument: 'image tool'" + exit 1 + fi + + forceBuildAndPush="${4}" + if [ -z "${forceBuildAndPush}" ]; then + echo "[ERROR] Please specify fourth argument: 'force build and push: true or false'" + exit 1 + fi + + # optional argument + FROM_INDEX=${5:-""} + BUILD_INDEX_IMAGE_ARG="" + if [ ! "${FROM_INDEX}" == "" ]; then + BUILD_INDEX_IMAGE_ARG=" --from-index ${FROM_INDEX}" + fi + + SKIP_TLS_ARG="" + SKIP_TLS_VERIFY="" + if [ "${imageTool}" == "podman" ]; then + SKIP_TLS_ARG=" --skip-tls" + SKIP_TLS_VERIFY=" --tls-verify=false" + fi + + pushd "${ROOT_DIR}" || exit + + INDEX_ADD_CMD="make catalog-build \ + CATALOG_IMG=\"${CATALOG_IMAGENAME}\" \ + BUNDLE_IMG=\"${CATALOG_BUNDLE_IMAGE_NAME_LOCAL}\" \ + IMAGE_TOOL=\"${imageTool}\" \ + FROM_INDEX_OPT=\"${BUILD_INDEX_IMAGE_ARG}\"" + + exitCode=0 + # Execute command and store an error output to the variable for following handling. + { + output="$(eval "${INDEX_ADD_CMD}" 2>&1 1>&3 3>&-)"; } 3>&1 || \ + { + exitCode="$?"; + echo "[INFO] ${exitCode}"; + true; + } + echo "${output}" + if [[ "${output}" == *"already exists, Bundle already added that provides package and csv"* ]] && [[ "${forceBuildAndPush}" == "true" ]]; then + echo "[INFO] Ignore error 'Bundle already added'" + # Catalog bundle image contains bundle reference, continue without unnecessary push operation + return + else + echo "[INFO] ${exitCode}" + if [ "${exitCode}" != 0 ]; then + exit "${exitCode}" + fi + fi + + make catalog-push CATALOG_IMG="${CATALOG_IMAGENAME}" + + popd || exit +} + + init $@ installOPM buildBundle diff --git a/olm/olm.sh b/olm/olm.sh index 927e7709e..65bf659e7 100755 --- a/olm/olm.sh +++ b/olm/olm.sh @@ -19,11 +19,23 @@ ROOT_DIR=$(dirname "${BASE_DIR}") source ${ROOT_DIR}/olm/check-yq.sh -function getPackageName() { +getPackageName() { echo "eclipse-che-preview-openshift" } -function getBundlePath() { +getCustomCatalogSourceName() { + echo "eclipse-che-custom-catalog-source" +} + +getSubscriptionName() { + echo "eclipse-che-subscription" +} + +getDevWorkspaceCustomCatalogSourceName() { + echo "custom-devworkspace-operator-catalog" +} + +getBundlePath() { channel="${1}" if [ -z "${channel}" ]; then echo "[ERROR] 'channel' is not specified" @@ -33,183 +45,6 @@ function getBundlePath() { echo "${ROOT_DIR}/bundle/${channel}/$(getPackageName)" } -createCatalogSource() { - namespace="${1}" - if [ -z "${namespace}" ]; then - echo "[ERROR] Please specify second argument: 'namespace'" - exit 1 - fi - CATALOG_IMAGENAME="${2}" - if [ -z "${CATALOG_IMAGENAME}" ]; then - echo "[ERROR] Please specify third argument: 'catalog image'" - exit 1 - fi - packageName=$(getPackageName) - - kubectl apply -f - <&1 1>&3 3>&-)"; } 3>&1 || \ - { - exitCode="$?"; - echo "[INFO] ${exitCode}"; - true; - } - echo "${output}" - if [[ "${output}" == *"already exists, Bundle already added that provides package and csv"* ]] && [[ "${forceBuildAndPush}" == "true" ]]; then - echo "[INFO] Ignore error 'Bundle already added'" - # Catalog bundle image contains bundle reference, continue without unnecessary push operation - return - else - echo "[INFO] ${exitCode}" - if [ "${exitCode}" != 0 ]; then - exit "${exitCode}" - fi - fi - - make catalog-push CATALOG_IMG="${CATALOG_IMAGENAME}" - - popd || exit -} - -# HACK. Unfortunately catalog source image bundle job has image pull policy "IfNotPresent". -# It makes troubles for test scripts, because image bundle could be outdated with -# such pull policy. That's why we launch job to fource image bundle pulling before Che installation. -forcePullingOlmImages() { - namespace="${1}" - if [ -z "${namespace}" ]; then - echo "[ERROR] Please specify first argument: 'namespace'" - exit 1 - fi - CATALOG_BUNDLE_IMAGE_NAME_LOCAL="${2}" - if [ -z "${CATALOG_BUNDLE_IMAGE_NAME_LOCAL}" ]; then - echo "[ERROR] Please specify second argument: opm bundle image" - exit 1 - fi - - yq -r "(.spec.template.spec.containers[0].image) = \"${CATALOG_BUNDLE_IMAGE_NAME_LOCAL}\"" "${BASE_DIR}/force-pulling-olm-images-job.yaml" | kubectl apply -f - -n "${namespace}" - - kubectl wait --for=condition=complete --timeout=30s job/force-pulling-olm-images-job -n "${namespace}" - - kubectl delete job/force-pulling-olm-images-job -n "${namespace}" -} - installOPM() { OPM_BINARY=$(command -v opm) || true if [[ ! -x $OPM_BINARY ]]; then @@ -227,251 +62,3 @@ installOPM() { fi } -createNamespace() { - namespace="${1}" - if [ -z "${namespace}" ]; then - echo "[ERROR] Please specify first argument: 'namespace'" - exit 1 - fi - - kubectl apply -f - </dev/null 2>&1 - then - break - fi - sleep 1 - ((i++)) - done - - if [ $i -gt 240 ] - then - echo "[ERROR] Catalog source not created after 4 minutes" - exit 1 - fi -} - -subscribeToInstallation() { - namespace="${1}" - if [ -z "${namespace}" ]; then - echo "[ERROR] 'namespace' is not specified" - exit 1 - fi - channel="${2}" - if [ -z "${channel}" ]; then - echo "[ERROR] 'channel' is not specified" - exit 1 - fi - - # fourth argument is an optional - CSV_NAME="${3-${CSV_NAME}}" - if [ -n "${CSV_NAME}" ]; then - echo "[INFO] Subscribing to the version: '${CSV_NAME}'" - else - echo "[INFO] Subscribing to latest version for channel: '${channel}'" - fi - - packageName=$(getPackageName) - - kubectl apply -f - <