diff --git a/.ci/oci-stable-all-namespaces.sh b/.ci/oci-stable-all-namespaces.sh index 180069777..7895a44a9 100755 --- a/.ci/oci-stable-all-namespaces.sh +++ b/.ci/oci-stable-all-namespaces.sh @@ -17,6 +17,14 @@ set -o pipefail # error on unset variables set -u +################################ !!! IMPORTANT !!! ################################ +########### THIS JOB USE openshift ci operators workflows to run ##################### +########## More info about how it is configured can be found here: https://docs.ci.openshift.org/docs/how-tos/testing-operator-sdk-operators ############# +######### Script which install the given bundles from stable-all-namespace https://steps.ci.openshift.org/reference/optional-operators-subscribe ########## +######## !!! Related PR in openshift CI is: https://github.com/openshift/release/pull/20610 ############################################################## +####################################################################################################################################################### + + export OPERATOR_REPO=$(dirname $(dirname $(readlink -f "$0"))); source "${OPERATOR_REPO}"/.github/bin/common.sh source "${OPERATOR_REPO}"/.github/bin/oauth-provision.sh @@ -26,6 +34,7 @@ trap "catchFinish" EXIT SIGINT overrideDefaults() { export DEV_WORKSPACE_ENABLE="true" + export CHE_EXPOSURE_STRATEGY="single-host" } runTests() { diff --git a/README.md b/README.md index 53e53a282..8ab2cf41d 100644 --- a/README.md +++ b/README.md @@ -149,13 +149,13 @@ Before installing Eclipse Che using channel `stable-all-namespaces` we need to c * To update to stable-all-namespaces channel you need first to remove all subscriptions created for che installed from nightly or stable channels. IMPORTANT: Removing subscriptions doesn’t mean Eclipse Che operands(che-server, keycloak or roles) will be removed from the cluster. * DevWorkspace engine will be by default enabled in the new channel. -* In case if you have already installed Che with devWorkspace enabled from channels nightly or stable you need to uninstall DevWorkspace completely from the cluster and then install the Che Operator using stable-all-namespaces channel. +* In case if you have already installed Che with DevWorkspace engine enabled from channels nightly or stable you need to remove all DevWorkspace resources from the cluster following the next [scripts](https://github.com/devfile/devworkspace-operator/blob/main/build/make/deploy.mk#L77). * `stable-all-namespaces` channel is supported only in openshift. If the Openshift Cluster already have all these considerations done you can proceed to install the Eclipse Che using stable-all-namespaces channel from OperatorHub or using the new channel you need to perform next chectl command: ```bash -chectl server:deploy --installer=olm --platform=openshift --olm-channel=stable-all-namespaces +chectl server:deploy --installer=olm --platform=openshift --olm-channel=stable-all-namespaces ``` ### Deploy Che operator using operator-sdk diff --git a/make-release.sh b/make-release.sh index 81b198efe..95d410c6b 100755 --- a/make-release.sh +++ b/make-release.sh @@ -235,10 +235,11 @@ releaseOlmFiles() { local openshift=$RELEASE_DIR/bundle/$channel/eclipse-che-preview-openshift/manifests echo "[INFO] releaseOlmFiles :: Validate changes" - #grep -q "version: "$RELEASE $openshift/che-operator.clusterserviceversion.yaml + grep -q "version: "$RELEASE $openshift/che-operator.clusterserviceversion.yaml if [[ $channel == "stable" ]];then local kubernetes=$RELEASE_DIR/bundle/$channel/eclipse-che-preview-kubernetes/manifests - #grep -q "version: "$RELEASE $kubernetes/che-operator.clusterserviceversion.yaml + grep -q "version: "$RELEASE $kubernetes/che-operator.clusterserviceversion.yaml + test -f $kubernetes/org_v1_che_crd.yaml test -f $kubernetes/org.eclipse.che_chebackupserverconfigurations_crd.yaml test -f $kubernetes/org.eclipse.che_checlusterbackups_crd.yaml diff --git a/olm/prepare-community-operators-update.sh b/olm/prepare-community-operators-update.sh index 8c5f199e8..4a228b040 100755 --- a/olm/prepare-community-operators-update.sh +++ b/olm/prepare-community-operators-update.sh @@ -126,7 +126,7 @@ do if [[ "${lastPackagePreReleaseVersion}" == "${lastPublishedPackageVersion}" ]] && [[ "${FORCE}" == "" ]]; then echo "#### ERROR ####" echo "Release ${lastPackagePreReleaseVersion} already exists in the '${platformSubFolder}/eclipse-che' package !" - #exit 1 + exit 1 fi echo $lastPackagePreReleaseVersion echo $platform @@ -152,14 +152,17 @@ do sed -e "s/${lastPublishedPackageVersion}/${lastPackagePreReleaseVersion}/" "${destinationPackageFilePath}" > "${destinationPackageFilePath}.new" echo + # Append to community operators the stable channel csv version: https://github.com/operator-framework/community-operators/blob/master/community-operators/eclipse-che/eclipse-che.package.yaml if [[ $channel == "stable" ]]; then mv "${destinationPackageFilePath}.new" "${destinationPackageFilePath}" fi + # Append to community operators the stable-all-namespaces channel csv version: https://github.com/operator-framework/community-operators/blob/master/community-operators/eclipse-che/eclipse-che.package.yaml if [[ $channel == "stable-all-namespaces" ]]; then yq -riY ".channels[1] = { \"currentCSV\": \"eclipse-che.v${lastPackagePreReleaseVersion}\", \"name\": \"$channel\"}" $destinationPackageFilePath fi done + # Make by default stable channel in the community operators eclipse-che.package.yaml yq -Yi '.defaultChannel |= "stable"' ${destinationPackageFilePath} # NOTE: if you update this file, you need to submit a PR against these two files: diff --git a/pkg/deploy/dev-workspace/dev_workspace.go b/pkg/deploy/dev-workspace/dev_workspace.go index ab1269187..1126cde6b 100644 --- a/pkg/deploy/dev-workspace/dev_workspace.go +++ b/pkg/deploy/dev-workspace/dev_workspace.go @@ -117,7 +117,7 @@ func ReconcileDevWorkspace(deployContext *deploy.DeployContext) (bool, error) { } // Check if exists devworkspace operator csv is already installed - devWorkspaceOperatorCSVExists := devWorkspaceControllerCSVExists(deployContext) + devWorkspaceOperatorCSVExists := isDevWorkspaceControllerCSVExists(deployContext) if devWorkspaceOperatorCSVExists { return true, nil } @@ -161,14 +161,14 @@ func ReconcileDevWorkspace(deployContext *deploy.DeployContext) (bool, error) { return true, nil } -func devWorkspaceControllerCSVExists(deployContext *deploy.DeployContext) bool { +func isDevWorkspaceControllerCSVExists(deployContext *deploy.DeployContext) bool { // If clusterserviceversions resource doesn't exist in cluster DWO as well will not be present if !util.HasK8SResourceObject(deployContext.ClusterAPI.DiscoveryClient, ClusterServiceVersionResourceName) { return false } csvList := &operatorsv1alpha1.ClusterServiceVersionList{} - err := deployContext.ClusterAPI.NonCachedClient.List(context.TODO(), csvList, &client.ListOptions{}) + err := deployContext.ClusterAPI.Client.List(context.TODO(), csvList, &client.ListOptions{}) if err != nil { return false } diff --git a/pkg/deploy/dev-workspace/dev_workspace_test.go b/pkg/deploy/dev-workspace/dev_workspace_test.go index 24fed06b1..b2ce5deab 100644 --- a/pkg/deploy/dev-workspace/dev_workspace_test.go +++ b/pkg/deploy/dev-workspace/dev_workspace_test.go @@ -12,6 +12,8 @@ package devworkspace import ( + "context" + orgv1 "github.com/eclipse-che/che-operator/api/v1" "github.com/eclipse-che/che-operator/pkg/deploy" "github.com/eclipse-che/che-operator/pkg/util" @@ -21,6 +23,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" fakeDiscovery "k8s.io/client-go/discovery/fake" + "sigs.k8s.io/controller-runtime/pkg/client" "testing" ) @@ -212,12 +215,14 @@ func TestReconcileDevWorkspaceCheckIfCSVExists(t *testing.T) { deployContext := deploy.GetTestDeployContext(cheCluster, []runtime.Object{}) deployContext.ClusterAPI.Scheme.AddKnownTypes(operatorsv1alpha1.SchemeGroupVersion, &operatorsv1alpha1.ClusterServiceVersion{}) - deployContext = deploy.GetTestDeployContext(cheCluster, []runtime.Object{devWorkspaceCSV}) - deployContext.ClusterAPI.Scheme.AddKnownTypes(admissionregistrationv1.SchemeGroupVersion, &admissionregistrationv1.MutatingWebhookConfiguration{}) + deployContext.ClusterAPI.Scheme.AddKnownTypes(operatorsv1alpha1.SchemeGroupVersion, &operatorsv1alpha1.ClusterServiceVersionList{}) + deployContext.ClusterAPI.Client.Create(context.TODO(), devWorkspaceCSV) deployContext.ClusterAPI.DiscoveryClient.(*fakeDiscovery.FakeDiscovery).Fake.Resources = []*metav1.APIResourceList{ { APIResources: []metav1.APIResource{ - {Name: ClusterServiceVersionResourceName}, + { + Name: ClusterServiceVersionResourceName, + }, }, }, } @@ -227,7 +232,13 @@ func TestReconcileDevWorkspaceCheckIfCSVExists(t *testing.T) { reconciled, _ := ReconcileDevWorkspace(deployContext) if !reconciled { - t.Fatalf("Test Failed... DevWorkspace CSV is expected to be craeted") + t.Fatalf("Failed to reconcile DevWorkspace") + } + + // Get Devworkspace namespace. If error is thrown means devworkspace is not anymore installed if CSV is detected + err := deployContext.ClusterAPI.Client.Get(context.TODO(), client.ObjectKey{Name: DevWorkspaceNamespace}, &corev1.Namespace{}) + if err == nil { + t.Fatal("Failed to reconcile DevWorkspace when DWO CSV is exptected to be created") } }