From a315a41721c14973241f5e9e72577cf4ea50b9e4 Mon Sep 17 00:00:00 2001 From: Tom Klapiscak Date: Thu, 25 Jul 2024 15:53:13 +0100 Subject: [PATCH 1/3] [patch] update openshift-gitops-operator 1.12 -> 1.13 MASCORE-2654 --- image/cli/mascli/templates/gitops/bootstrap/subscription.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/image/cli/mascli/templates/gitops/bootstrap/subscription.yaml b/image/cli/mascli/templates/gitops/bootstrap/subscription.yaml index ace2f1aa69..6fcefad354 100644 --- a/image/cli/mascli/templates/gitops/bootstrap/subscription.yaml +++ b/image/cli/mascli/templates/gitops/bootstrap/subscription.yaml @@ -5,7 +5,7 @@ metadata: name: openshift-gitops namespace: openshift-operators spec: - channel: gitops-1.12 + channel: gitops-1.13 installPlanApproval: Automatic name: openshift-gitops-operator source: redhat-operators From 441c2963954ec926fd4a3b41df7bcd5c316c3c96 Mon Sep 17 00:00:00 2001 From: Tom Klapiscak Date: Fri, 26 Jul 2024 13:41:07 +0100 Subject: [PATCH 2/3] move mas-wipe-mongo-data flag from mongocfg to instance-base (since the data wipe logic has been moved into the sync-jobs application, we need this flag to be available there) --- image/cli/mascli/functions/gitops_mas_config | 5 ++--- image/cli/mascli/functions/gitops_suite | 18 +++++++++++++----- .../configs/ibm-mas-mongo-config.yaml.j2 | 5 ----- .../instance/ibm-mas-instance-base.yaml.j2 | 6 ++++++ .../gitops/gitops-mas-instance.yml.j2 | 4 ++-- .../tasks/gitops/gitops-suite-config.yml.j2 | 8 +------- tekton/src/tasks/gitops/gitops-suite.yml.j2 | 8 +++++++- 7 files changed, 31 insertions(+), 23 deletions(-) diff --git a/image/cli/mascli/functions/gitops_mas_config b/image/cli/mascli/functions/gitops_mas_config index c98902042c..a6f71ca182 100644 --- a/image/cli/mascli/functions/gitops_mas_config +++ b/image/cli/mascli/functions/gitops_mas_config @@ -24,7 +24,6 @@ IBM Maximo Application Suite: -m, --mas-instance-id ${COLOR_YELLOW}MAS_INSTANCE_ID${TEXT_RESET} IBM Suite Maximo Application Suite Instance ID --mas-app-id ${COLOR_YELLOW}MAS_APP_ID${TEXT_RESET} MAS Application scope for this configuration (required if MAS_CONFIG_SCOPE is app or wsapp) --mas-workspace-id ${COLOR_YELLOW}MAS_WORKSPACE_ID${TEXT_RESET} MAS Workspace scope for this configuration (required if MAS_CONFIG_SCOPE is ws or wsapp) - --mas-wipe-mongo-data ${COLOR_YELLOW}MAS_WIPE_MONGO_DATA${TEXT_RESET} Flag to wipe mongo data on MAS uninstall AWS Secrets Manager Configuration (Required): --sm-aws-secret-region ${COLOR_YELLOW}SM_AWS_REGION${TEXT_RESET} Region of the AWS Secrets Manager to use @@ -117,7 +116,8 @@ function gitops_mas_config_noninteractive() { export MAS_WORKSPACE_ID=$1 && shift ;; --mas-wipe-mongo-data) - export MAS_WIPE_MONGO_DATA=$1 && shift + echo "WARNING: the --mas-wipe-mongo-data parameter is deprecated (it has been moved to the gitops-suite script) and will be ignored here." + shift ;; --mas-app-id) export MAS_APP_ID=$1 && shift @@ -508,7 +508,6 @@ function gitops_mas_config() { if [ "${MAS_CONFIG_TYPE}" == "mongo" ]; then echo "${TEXT_DIM}" echo_reset_dim "Mongo Provider ................ ${COLOR_MAGENTA}${MONGODB_PROVIDER}" - echo_reset_dim "MAS_WIPE_MONGO_DATA ............ ${COLOR_MAGENTA}${MAS_WIPE_MONGO_DATA}" reset_colors fi diff --git a/image/cli/mascli/functions/gitops_suite b/image/cli/mascli/functions/gitops_suite index 93e85318d7..888c4ded18 100644 --- a/image/cli/mascli/functions/gitops_suite +++ b/image/cli/mascli/functions/gitops_suite @@ -71,6 +71,9 @@ IBM Maximo Application Suite: --delete-wildcards ${COLOR_YELLOW}DELETE_WILDCARDS${TEXT_RESET} Set this to true to force deletion of wildcard dns entries in cis --override-edge-certs ${COLOR_YELLOW}OVERRIDE_EDGE_CERTS${TEXT_RESET} Set this to false to not override and delete any existing edge certificates in cis instance when creating new edge certificates + --mas-wipe-mongo-data ${COLOR_YELLOW}MAS_WIPE_MONGO_DATA${TEXT_RESET} Set to "true" to wipe all mongo data for this MAS instance on uninstall (optional, defaults to false) + + Target Cluster (Optional): --cluster-url ${COLOR_YELLOW}CLUSTER_URL${TEXT_RESET} Set to target a remote Kubernetes cluster (defaults to 'https://kubernetes.default.svc') @@ -196,6 +199,10 @@ function gitops_suite_noninteractive() { export MAS_POD_TEMPLATE_YAML=$1 && shift ;; + --mas-wipe-mongo-data) + export MAS_WIPE_MONGO_DATA=$1 && shift + ;; + # Target Cluster (Optional) --cluster-url) export CLUSTER_URL=$1 && shift @@ -302,13 +309,13 @@ function gitops_suite_noninteractive() { [[ -z "$ACCOUNT_ID" ]] && gitops_suite_help "ACCOUNT_ID is not set" [[ -z "$CLUSTER_ID" ]] && gitops_suite_help "CLUSTER_ID is not set" - [[ -z "$REGION_ID" && -z "$SM_AWS_REGION" ]] && gitops_cluster_help "REGION_ID or SM_AWS_REGION is not set" - [[ -z "$CLUSTER_URL" ]] && gitops_cluster_help "CLUSTER_URL is not set" - [[ -z "$MONGODB_PROVIDER" ]] && gitops_cluster_help "MONGODB_PROVIDER is not set" + [[ -z "$REGION_ID" && -z "$SM_AWS_REGION" ]] && gitops_suite_help "REGION_ID or SM_AWS_REGION is not set" + [[ -z "$CLUSTER_URL" ]] && gitops_suite_help "CLUSTER_URL is not set" + [[ -z "$MONGODB_PROVIDER" ]] && gitops_suite_help "MONGODB_PROVIDER is not set" if [ $MONGODB_PROVIDER == 'aws' ]; then - [[ -z "$USER_ACTION" ]] && gitops_cluster_help "USER_ACTION is not set" - [[ -z "$MAS_INSTANCE_ID" ]] && gitops_cluster_help "MAS_INSTANCE_ID is not set" + [[ -z "$USER_ACTION" ]] && gitops_suite_help "USER_ACTION is not set" + [[ -z "$MAS_INSTANCE_ID" ]] && gitops_suite_help "MAS_INSTANCE_ID is not set" if [ -z $SM_AWS_ACCESS_KEY_ID ] || [ -z $SM_AWS_SECRET_ACCESS_KEY ] || [ -z $SM_AWS_REGION ]; then echo 'Missing required params for AWS mongo provider, make sure to provide --aws-access-key, --aws-secret-key, --aws-region' exit 1 @@ -390,6 +397,7 @@ function gitops_suite() { echo "${TEXT_DIM}" echo_h4 "Mongo" " " echo_reset_dim "Mongo Provider ................ ${COLOR_MAGENTA}${MONGODB_PROVIDER}" + echo_reset_dim "MAS_WIPE_MONGO_DATA ............ ${COLOR_MAGENTA}${MAS_WIPE_MONGO_DATA}" reset_colors echo "${TEXT_DIM}" diff --git a/image/cli/mascli/templates/gitops/appset-configs/cluster/instance/configs/ibm-mas-mongo-config.yaml.j2 b/image/cli/mascli/templates/gitops/appset-configs/cluster/instance/configs/ibm-mas-mongo-config.yaml.j2 index a8c4eb74a0..a246b40ee6 100644 --- a/image/cli/mascli/templates/gitops/appset-configs/cluster/instance/configs/ibm-mas-mongo-config.yaml.j2 +++ b/image/cli/mascli/templates/gitops/appset-configs/cluster/instance/configs/ibm-mas-mongo-config.yaml.j2 @@ -6,11 +6,6 @@ mas_application_id: {{ MAS_APP_ID }} mas_config_kind: "mongocfgs" mas_config_api_version: "config.mas.ibm.com" use_postdelete_hooks: {{ USE_POSTDELETE_HOOKS }} -{% if MAS_WIPE_MONGO_DATA == 'true' %} -mas_wipe_mongo_data: true -{% else %} -mas_wipe_mongo_data: false -{% endif %} username: password: diff --git a/image/cli/mascli/templates/gitops/appset-configs/cluster/instance/ibm-mas-instance-base.yaml.j2 b/image/cli/mascli/templates/gitops/appset-configs/cluster/instance/ibm-mas-instance-base.yaml.j2 index 7d9cf2d9fe..32f8e9a236 100644 --- a/image/cli/mascli/templates/gitops/appset-configs/cluster/instance/ibm-mas-instance-base.yaml.j2 +++ b/image/cli/mascli/templates/gitops/appset-configs/cluster/instance/ibm-mas-instance-base.yaml.j2 @@ -20,3 +20,9 @@ sm: custom_labels: {{ CUSTOM_LABELS | indent(2) }} {% endif %} + +{% if MAS_WIPE_MONGO_DATA == 'true' %} +mas_wipe_mongo_data: true +{% else %} +mas_wipe_mongo_data: false +{% endif %} \ No newline at end of file diff --git a/tekton/src/pipelines/gitops/gitops-mas-instance.yml.j2 b/tekton/src/pipelines/gitops/gitops-mas-instance.yml.j2 index d4ceadffd3..00b7e58266 100644 --- a/tekton/src/pipelines/gitops/gitops-mas-instance.yml.j2 +++ b/tekton/src/pipelines/gitops/gitops-mas-instance.yml.j2 @@ -317,6 +317,8 @@ spec: value: $(params.mas_manual_certs_yaml) - name: mas_pod_template_yaml value: $(params.mas_pod_template_yaml) + - name: mas_wipe_mongo_data + value: $(params.mas_wipe_mongo_data) taskRef: kind: Task name: gitops-suite @@ -367,8 +369,6 @@ spec: value: $(params.dro_ca_certificate_file) - name: cluster_url value: $(params.cluster_url) - - name: mas_wipe_mongo_data - value: $(params.mas_wipe_mongo_data) workspaces: - name: configs workspace: configs diff --git a/tekton/src/tasks/gitops/gitops-suite-config.yml.j2 b/tekton/src/tasks/gitops/gitops-suite-config.yml.j2 index 010c9a45fc..2c18fe1dc0 100644 --- a/tekton/src/tasks/gitops/gitops-suite-config.yml.j2 +++ b/tekton/src/tasks/gitops/gitops-suite-config.yml.j2 @@ -38,9 +38,6 @@ spec: - name: cluster_url type: string default: "" - - name: mas_wipe_mongo_data - type: string - default: "false" stepTemplate: name: gitops-suite-config env: @@ -76,8 +73,6 @@ spec: value: $(params.dro_contact_lastname) - name: DRO_CA_CERTIFICATE_FILE value: $(params.dro_ca_certificate_file) - - name: MAS_WIPE_MONGO_DATA - value: $(params.mas_wipe_mongo_data) envFrom: - configMapRef: name: environment-properties @@ -108,8 +103,7 @@ spec: --mas-config-scope system \ --mas-config-type mongo \ --dir /tmp/init-mas-config-mongo \ - --mongo-provider "$MONGODB_PROVIDER" \ - --mas-wipe-mongo-data "$MAS_WIPE_MONGO_DATA" \ + --mongo-provider "$MONGODB_PROVIDER" || exit 1 mkdir -p /tmp/init-mas-config-sls diff --git a/tekton/src/tasks/gitops/gitops-suite.yml.j2 b/tekton/src/tasks/gitops/gitops-suite.yml.j2 index 636af79361..394e8a0df8 100644 --- a/tekton/src/tasks/gitops/gitops-suite.yml.j2 +++ b/tekton/src/tasks/gitops/gitops-suite.yml.j2 @@ -110,6 +110,9 @@ spec: - name: mas_pod_template_yaml type: string default: "" + - name: mas_wipe_mongo_data + type: string + default: "false" stepTemplate: name: gitops-suite env: @@ -197,6 +200,8 @@ spec: value: $(params.mas_manual_certs_yaml) - name: MAS_POD_TEMPLATE_YAML value: $(params.mas_pod_template_yaml) + - name: MAS_WIPE_MONGO_DATA + value: $(params.mas_wipe_mongo_data) envFrom: - configMapRef: name: environment-properties @@ -243,7 +248,8 @@ spec: --github-host $GITHUB_HOST \ --github-org $GITHUB_ORG \ --github-repo $GITHUB_REPO \ - --git-branch $GIT_BRANCH + --git-branch $GIT_BRANCH \ + --mas-wipe-mongo-data "$MAS_WIPE_MONGO_DATA" \ exit $? command: From 7d5d1f19d015c73fe9871eca11b45e018e414e69 Mon Sep 17 00:00:00 2001 From: Tom Klapiscak Date: Fri, 26 Jul 2024 16:58:33 +0100 Subject: [PATCH 3/3] fix --- tekton/src/tasks/gitops/gitops-suite-config.yml.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tekton/src/tasks/gitops/gitops-suite-config.yml.j2 b/tekton/src/tasks/gitops/gitops-suite-config.yml.j2 index 2c18fe1dc0..40d4159533 100644 --- a/tekton/src/tasks/gitops/gitops-suite-config.yml.j2 +++ b/tekton/src/tasks/gitops/gitops-suite-config.yml.j2 @@ -103,7 +103,7 @@ spec: --mas-config-scope system \ --mas-config-type mongo \ --dir /tmp/init-mas-config-mongo \ - --mongo-provider "$MONGODB_PROVIDER" + --mongo-provider "$MONGODB_PROVIDER" \ || exit 1 mkdir -p /tmp/init-mas-config-sls