build: Enable Image Puller for tests (#960)
* build: Enable Image Puller for tests Signed-off-by: Anatolii Bazko <abazko@redhat.com>pull/969/head
parent
833b3aad86
commit
4e5ffb8132
|
|
@ -34,6 +34,10 @@ overrideDefaults() {
|
|||
|
||||
runTests() {
|
||||
deployEclipseCheStable "operator" "openshift" ${LAST_PACKAGE_VERSION}
|
||||
|
||||
deployCommunityCatalog
|
||||
enableImagePuller
|
||||
|
||||
provisionOAuth
|
||||
createWorkspace
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ initDefaults() {
|
|||
export DEV_WORKSPACE_ENABLE="false"
|
||||
export DEVWORKSPACE_CONTROLLER_TEST_NAMESPACE=devworkspace-controller-test
|
||||
export DEVWORKSPACE_CHE_OPERATOR_TEST_NAMESPACE=devworkspace-cheoperator-test
|
||||
export IMAGE_PULLER_ENABLE="false"
|
||||
|
||||
# turn off telemetry
|
||||
mkdir -p ${HOME}/.config/chectl
|
||||
|
|
@ -350,11 +351,6 @@ setServerExposureStrategy() {
|
|||
yq -rSY '.spec.server.serverExposureStrategy = "'${2}'"' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file}
|
||||
}
|
||||
|
||||
enableDevWorkspace() {
|
||||
local file="${1}/che-operator/crds/org_v1_che_cr.yaml"
|
||||
yq -rSY '.spec.devWorkspace.enable = '${2}'' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file}
|
||||
}
|
||||
|
||||
setSingleHostExposureType() {
|
||||
local file="${1}/che-operator/crds/org_v1_che_cr.yaml"
|
||||
yq -rSY '.spec.k8s.singleHostExposureType = "'${2}'"' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file}
|
||||
|
|
@ -371,6 +367,10 @@ setCustomOperatorImage() {
|
|||
yq -rSY '.spec.template.spec.containers[0].imagePullPolicy = "IfNotPresent"' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file}
|
||||
}
|
||||
|
||||
enableImagePuller() {
|
||||
kubectl patch checluster/eclipse-che -n ${NAMESPACE} --type=merge -p '{"spec":{"imagePuller":{"enable": true}}}'
|
||||
}
|
||||
|
||||
insecurePrivateDockerRegistry() {
|
||||
IMAGE_REGISTRY_HOST="127.0.0.1:5000"
|
||||
export IMAGE_REGISTRY_HOST
|
||||
|
|
@ -405,6 +405,7 @@ applyOlmCR() {
|
|||
CR=$(yq -r '.metadata.annotations["alm-examples"]' "${OPENSHIFT_NIGHTLY_CSV_FILE}" | yq -r ".[0]")
|
||||
CR=$(echo "$CR" | yq -r ".spec.server.serverExposureStrategy = \"${CHE_EXPOSURE_STRATEGY}\"")
|
||||
CR=$(echo "$CR" | yq -r ".spec.devWorkspace.enable = ${DEV_WORKSPACE_ENABLE:-false}")
|
||||
CR=$(echo "$CR" | yq -r ".spec.imagePuller.enable = ${IMAGE_PULLER_ENABLE:-false}")
|
||||
|
||||
echo -e "$CR"
|
||||
echo "$CR" | oc apply -n "${NAMESPACE}" -f -
|
||||
|
|
@ -531,3 +532,23 @@ deployCertManager() {
|
|||
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=webhook -n cert-manager --timeout=60s
|
||||
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=cainjector -n cert-manager --timeout=60s
|
||||
}
|
||||
|
||||
deployCommunityCatalog() {
|
||||
oc create -f - -o jsonpath='{.metadata.name}' <<EOF
|
||||
apiVersion: operators.coreos.com/v1alpha1
|
||||
kind: CatalogSource
|
||||
metadata:
|
||||
name: community-catalog
|
||||
namespace: openshift-marketplace
|
||||
spec:
|
||||
sourceType: grpc
|
||||
image: registry.redhat.io/redhat/community-operator-index:v4.7
|
||||
displayName: Eclipse Che Catalog
|
||||
publisher: Eclipse Che
|
||||
updateStrategy:
|
||||
registryPoll:
|
||||
interval: 30m
|
||||
EOF
|
||||
sleep 10s
|
||||
kubectl wait --for=condition=ready pod -l olm.catalogSource=community-catalog -n openshift-marketplace --timeout=120s
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,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-kubernetes.v7.34.0-268.nightly
|
||||
name: eclipse-che-preview-kubernetes.v7.34.0-269.nightly
|
||||
namespace: placeholder
|
||||
spec:
|
||||
apiservicedefinitions: {}
|
||||
|
|
@ -979,7 +979,7 @@ spec:
|
|||
- name: RELATED_IMAGE_che_tls_secrets_creation_job
|
||||
value: quay.io/eclipse/che-tls-secret-creator:alpine-d1ed4ad
|
||||
- name: RELATED_IMAGE_pvc_jobs
|
||||
value: registry.access.redhat.com/ubi8-minimal:8.4-205
|
||||
value: registry.access.redhat.com/ubi8-minimal:8.4-205.1626828526
|
||||
- name: RELATED_IMAGE_postgres
|
||||
value: quay.io/eclipse/che--centos--postgresql-96-centos7:9.6-b681d78125361519180a6ac05242c296f8906c11eab7e207b5ca9a89b6344392
|
||||
- name: RELATED_IMAGE_keycloak
|
||||
|
|
@ -1300,4 +1300,4 @@ spec:
|
|||
maturity: stable
|
||||
provider:
|
||||
name: Eclipse Foundation
|
||||
version: 7.34.0-268.nightly
|
||||
version: 7.34.0-269.nightly
|
||||
|
|
|
|||
|
|
@ -74,7 +74,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.34.0-268.nightly
|
||||
name: eclipse-che-preview-openshift.v7.34.0-269.nightly
|
||||
namespace: placeholder
|
||||
spec:
|
||||
apiservicedefinitions: {}
|
||||
|
|
@ -1032,7 +1032,7 @@ spec:
|
|||
- name: RELATED_IMAGE_devfile_registry
|
||||
value: quay.io/eclipse/che-devfile-registry:next
|
||||
- name: RELATED_IMAGE_pvc_jobs
|
||||
value: registry.access.redhat.com/ubi8-minimal:8.4-205
|
||||
value: registry.access.redhat.com/ubi8-minimal:8.4-205.1626828526
|
||||
- name: RELATED_IMAGE_postgres
|
||||
value: quay.io/eclipse/che--centos--postgresql-96-centos7:9.6-b681d78125361519180a6ac05242c296f8906c11eab7e207b5ca9a89b6344392
|
||||
- name: RELATED_IMAGE_keycloak
|
||||
|
|
@ -1364,4 +1364,4 @@ spec:
|
|||
maturity: stable
|
||||
provider:
|
||||
name: Eclipse Foundation
|
||||
version: 7.34.0-268.nightly
|
||||
version: 7.34.0-269.nightly
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ spec:
|
|||
- name: RELATED_IMAGE_che_tls_secrets_creation_job
|
||||
value: quay.io/eclipse/che-tls-secret-creator:alpine-d1ed4ad
|
||||
- name: RELATED_IMAGE_pvc_jobs
|
||||
value: registry.access.redhat.com/ubi8-minimal:8.4-205
|
||||
value: registry.access.redhat.com/ubi8-minimal:8.4-205.1626828526
|
||||
- name: RELATED_IMAGE_postgres
|
||||
value: quay.io/eclipse/che--centos--postgresql-96-centos7:9.6-b681d78125361519180a6ac05242c296f8906c11eab7e207b5ca9a89b6344392
|
||||
- name: RELATED_IMAGE_keycloak
|
||||
|
|
|
|||
|
|
@ -401,6 +401,7 @@ applyCRCheCluster() {
|
|||
CR=$(echo "$CRs" | yq -r ".[0]")
|
||||
CR=$(echo "$CR" | yq -r ".spec.devWorkspace.enable = ${DEV_WORKSPACE_ENABLE:-false}")
|
||||
CR=$(echo "$CR" | yq -r ".spec.server.serverExposureStrategy = \"${CHE_EXPOSURE_STRATEGY:-multi-host}\"")
|
||||
CR=$(echo "$CR" | yq -r ".spec.server.imagePuller.enable = ${IMAGE_PULLER_ENABLE:-false}")
|
||||
if [ "${platform}" == "kubernetes" ]
|
||||
then
|
||||
CR=$(echo "$CR" | yq -r ".spec.k8s.ingressDomain = \"$(minikube ip).nip.io\"")
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ func ReconcileImagePuller(ctx *DeployContext) (reconcile.Result, error) {
|
|||
// If the image puller should be installed but the APIServer doesn't know about PackageManifests/Subscriptions, log a warning and requeue
|
||||
if ctx.CheCluster.Spec.ImagePuller.Enable && (!foundPackagesAPI || !foundOperatorsAPI) {
|
||||
logrus.Infof("Couldn't find Operator Lifecycle Manager types to install the Kubernetes Image Puller Operator. Please install Operator Lifecycle Manager to install the operator or disable the image puller by setting spec.imagePuller.enable to false.")
|
||||
return reconcile.Result{Requeue: true}, nil
|
||||
return reconcile.Result{RequeueAfter: time.Second}, nil
|
||||
}
|
||||
|
||||
if ctx.CheCluster.Spec.ImagePuller.Enable {
|
||||
|
|
@ -63,7 +63,7 @@ func ReconcileImagePuller(ctx *DeployContext) (reconcile.Result, error) {
|
|||
if err != nil {
|
||||
if errors.IsNotFound(err) {
|
||||
logrus.Infof("There is no PackageManifest for the Kubernetes Image Puller Operator. Install the Operator Lifecycle Manager and the Community Operators Catalog")
|
||||
return reconcile.Result{Requeue: true}, nil
|
||||
return reconcile.Result{RequeueAfter: time.Second}, nil
|
||||
}
|
||||
logrus.Errorf("Error getting packagemanifest: %v", err)
|
||||
return reconcile.Result{}, err
|
||||
|
|
@ -75,7 +75,7 @@ func ReconcileImagePuller(ctx *DeployContext) (reconcile.Result, error) {
|
|||
return reconcile.Result{}, err
|
||||
}
|
||||
if createdOperatorGroup {
|
||||
return reconcile.Result{Requeue: true}, nil
|
||||
return reconcile.Result{RequeueAfter: time.Second}, nil
|
||||
}
|
||||
createdOperatorSubscription, err := CreateImagePullerSubscription(ctx, packageManifest)
|
||||
if err != nil {
|
||||
|
|
@ -83,30 +83,15 @@ func ReconcileImagePuller(ctx *DeployContext) (reconcile.Result, error) {
|
|||
return reconcile.Result{}, err
|
||||
}
|
||||
if createdOperatorSubscription {
|
||||
return reconcile.Result{Requeue: true}, nil
|
||||
}
|
||||
subscriptionsAreEqual, err := CompareExpectedSubscription(ctx, packageManifest)
|
||||
if err != nil {
|
||||
logrus.Infof("Error checking Subscription equality: %v", err)
|
||||
return reconcile.Result{}, nil
|
||||
}
|
||||
// If the Subscription Spec changed for some reason, update it
|
||||
if !subscriptionsAreEqual {
|
||||
updatedOperatorSubscription := GetExpectedSubscription(ctx, packageManifest)
|
||||
logrus.Infof("Updating Subscription")
|
||||
err = ctx.ClusterAPI.NonCachedClient.Update(context.TODO(), updatedOperatorSubscription, &client.UpdateOptions{})
|
||||
if err != nil {
|
||||
logrus.Errorf("Error updating Subscription: %v", err)
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
return reconcile.Result{Requeue: true}, nil
|
||||
return reconcile.Result{RequeueAfter: time.Second}, nil
|
||||
}
|
||||
|
||||
// Add the image puller finalizer
|
||||
if !HasImagePullerFinalizer(ctx.CheCluster) {
|
||||
if err := ReconcileImagePullerFinalizer(ctx); err != nil {
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
return reconcile.Result{Requeue: true}, nil
|
||||
return reconcile.Result{RequeueAfter: time.Second}, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +118,7 @@ func ReconcileImagePuller(ctx *DeployContext) (reconcile.Result, error) {
|
|||
logrus.Errorf("Error updating CheCluster: %v", err)
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
return reconcile.Result{Requeue: true}, nil
|
||||
return reconcile.Result{RequeueAfter: time.Second}, nil
|
||||
}
|
||||
|
||||
if ctx.CheCluster.IsImagePullerImagesEmpty() {
|
||||
|
|
@ -177,7 +162,7 @@ func ReconcileImagePuller(ctx *DeployContext) (reconcile.Result, error) {
|
|||
logrus.Errorf("Error updating KubernetesImagePuller: %v", err)
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
return reconcile.Result{Requeue: true}, nil
|
||||
return reconcile.Result{RequeueAfter: time.Second}, nil
|
||||
}
|
||||
} else {
|
||||
logrus.Infof("Waiting 15 seconds for kubernetesimagepullers.che.eclipse.org API")
|
||||
|
|
@ -193,7 +178,7 @@ func ReconcileImagePuller(ctx *DeployContext) (reconcile.Result, error) {
|
|||
}
|
||||
|
||||
if removed {
|
||||
return reconcile.Result{Requeue: true}, nil
|
||||
return reconcile.Result{RequeueAfter: time.Second}, nil
|
||||
}
|
||||
|
||||
if HasImagePullerFinalizer(ctx.CheCluster) {
|
||||
|
|
@ -202,7 +187,7 @@ func ReconcileImagePuller(ctx *DeployContext) (reconcile.Result, error) {
|
|||
logrus.Errorf("Error deleting finalizer: %v", err)
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
return reconcile.Result{Requeue: true}, nil
|
||||
return reconcile.Result{RequeueAfter: time.Second}, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -381,14 +366,13 @@ func GetExpectedSubscription(ctx *DeployContext, packageManifest *packagesv1.Pac
|
|||
}
|
||||
}
|
||||
|
||||
func CompareExpectedSubscription(ctx *DeployContext, packageManifest *packagesv1.PackageManifest) (bool, error) {
|
||||
expected := GetExpectedSubscription(ctx, packageManifest)
|
||||
func GetActualSubscription(ctx *DeployContext) (*operatorsv1alpha1.Subscription, error) {
|
||||
actual := &operatorsv1alpha1.Subscription{}
|
||||
err := ctx.ClusterAPI.NonCachedClient.Get(context.TODO(), types.NamespacedName{Namespace: ctx.CheCluster.Namespace, Name: "kubernetes-imagepuller-operator"}, actual)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, err
|
||||
}
|
||||
return SubscriptionsAreEqual(expected, actual), nil
|
||||
return actual, nil
|
||||
}
|
||||
|
||||
// Update the CheCluster ImagePuller spec if the default values are not set
|
||||
|
|
|
|||
Loading…
Reference in New Issue