Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[patch] Move MAS instance Mongo data wipe job to sync-jobs application #1144

Merged
merged 7 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions image/cli/mascli/functions/gitops_mas_config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
18 changes: 13 additions & 5 deletions image/cli/mascli/functions/gitops_suite
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: <path:{{ SECRETS_PATH }}:{{ SECRET_KEY_MONGO_USERNAME }}>
password: <path:{{ SECRETS_PATH }}:{{ SECRET_KEY_MONGO_PASSWORD }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
4 changes: 2 additions & 2 deletions tekton/src/pipelines/gitops/gitops-mas-instance.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions tekton/src/tasks/gitops/gitops-suite-config.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -109,7 +104,6 @@ spec:
--mas-config-type mongo \
--dir /tmp/init-mas-config-mongo \
--mongo-provider "$MONGODB_PROVIDER" \
--mas-wipe-mongo-data "$MAS_WIPE_MONGO_DATA" \
|| exit 1

mkdir -p /tmp/init-mas-config-sls
Expand Down
8 changes: 7 additions & 1 deletion tekton/src/tasks/gitops/gitops-suite.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down