Skip to content

Commit

Permalink
fix: Fix sync condition to cleanup IBM Cert Mgr
Browse files Browse the repository at this point in the history
Signed-off-by: Denilson Nastacio <[email protected]>
  • Loading branch information
nastacio committed Dec 9, 2023
1 parent cfa0c21 commit 594c5f4
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{{- $red_hat_cert_manager := .Values.red_hat_cert_manager | toString }}
{{- if eq ( default "false" $red_hat_cert_manager ) "false" }}
---
apiVersion: batch/v1
kind: Job
Expand All @@ -19,6 +17,8 @@ spec:
env:
- name: ARGOCD_NAMESPACE
value: "openshift-gitops"
- name: RED_HAT_CERT_MANAGER_ENABLED
value: "{{.Values.red_hat_cert_manager}}"
- name: IBM_CERT_MANAGER_NAMESPACE
value: {{.Values.metadata.cert_manager_namespace}}
- name: IBM_CERT_MANAGER_CHANNEL
Expand All @@ -31,6 +31,15 @@ spec:
set -x
result=0
if [ "${RED_HAT_CERT_MANAGER_ENABLED}" == "true" ]; then
oc delete Subscription.operators.coreos.com ibm-cert-manager-operator \
-n "${IBM_CERT_MANAGER_NAMESPACE:?}" \
--ignore-not-found=true
oc delete Namespace "${IBM_CERT_MANAGER_NAMESPACE:?}" \
--ignore-not-found=true
exit "${result}"
fi
ibm_cert_manager_count=$(oc get Subscription.operators.coreos.com \
-l operators.coreos.com/ibm-cert-manager-operator.ibm-cert-manager \
-A \
Expand Down Expand Up @@ -88,4 +97,3 @@ spec:
restartPolicy: Never
serviceAccountName: {{.Values.serviceaccount.argocd_application_controller}}
backoffLimit: 2
{{- end}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This is not actually used by CP4BA.
#
# ArgoCD cannot recognize changes to the content
# of sync hooks (such as an env variable for a container)
# so this config map contains the env variables
# referenced in sync hooks to ensure ArgoCD realizes
# a relevant config value has changed.
---
apiVersion: v1
kind: ConfigMap
metadata:
name: gitops-cp4a-dummy
namespace: {{.Values.metadata.argocd_app_namespace}}
data:
red_hat_cert_manager: "{{.Values.red_hat_cert_manager}}"
1 change: 1 addition & 0 deletions config/cloudpaks/cp4a/operators/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ metadata:
argocd_app_namespace: ibm-cloudpaks
cert_manager_namespace: ibm-cert-manager
cert_manager_channel: v4.2
red_hat_cert_manager: false
serviceaccount:
argocd_application_controller: openshift-gitops-argocd-application-controller
storageclass:
Expand Down
15 changes: 11 additions & 4 deletions tests/postbuild/gitops.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ source "${scriptdir}/common.sh"
#
# Clean up at end of task
#
# shellcheck disable=SC2317
cleanRun() {
cd "${original_dir}"
if [ -n "${WORKDIR}" ]; then
Expand Down Expand Up @@ -139,7 +140,9 @@ function create_secrets() {
--docker-username="${CP_ICR_IO_USERID}" \
--docker-password="${CP_ICR_IO_PASSWORD}" \
--docker-email="${registry_email}" \
--namespace="${GITOPS_NAMESPACE}"
--namespace="${GITOPS_NAMESPACE}" \
--dry-run='client' \
-o yaml | oc apply -f -

cat <<EOF | oc apply -f -
---
Expand Down Expand Up @@ -522,17 +525,21 @@ function setup_gitops_server() {
-n openshift-gitops-operator \
--for=jsonpath='{.status.phase}'=Succeeded \
--timeout 120s \
&& oc wait ArgoCD openshift-gitops \
-n openshift-gitops \
--for=jsonpath='{.status.phase}'=Available \
--timeout 120s \
&& {
log "INFO: GitOps CSVs in Succeeded state."
log "INFO: GitOps installation ready."
result=0
break
}
log "INFO: Waiting for GitOps CSVs to be ready."
log "INFO: Waiting for GitOps installation to be ready."
current_seconds=$(( $(date +%s) ))
done

if [ "${result}" -eq 1 ]; then
log "WARNING: Timed out waiting for GitOps operators to be ready."
log "WARNING: Timed out waiting for GitOps installation to be ready."
fi

create_secrets "${github_pat}" || \
Expand Down
1 change: 0 additions & 1 deletion tests/prebuild/yamllint-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ ignore: |
config/cloudpaks/cp-shared/operators/templates/0100-rh-cert-manager-operator-group.yaml
config/cloudpaks/cp-shared/operators/templates/0110-rh-cert-manager-subscription.yaml
config/cloudpaks/cp4a/operators/templates/0000-cp4ba-namespace.yaml
config/cloudpaks/cp4a/operators/templates/0050-sync-cluster-scoped-operators.yaml
config/cloudpaks/cp4a/operators/templates/0100-operator-group.yaml
config/cloudpaks/cp4i/install-prereqs/templates/0000-namespace.yaml
config/cloudpaks/cp4i/install-prereqs/templates/0100-operator-group.yaml
Expand Down

0 comments on commit 594c5f4

Please sign in to comment.