Skip to content

Commit a712422

Browse files
authored
Fix private_gke_code_snippets + other small fixes (#477)
# Summary This PR fixes `private_gke_code_snippets` tests that could not properly set the context: >scripts/dev/contexts/private_gke_code_snippets: line 13: /data/mci/33f77d5e70bc4d8e19bb3f674e0743b1/src/github.com/mongodb/mongodb-kubernetes/scripts/dev/contexts/variables/funcs/gke: No such file or directory The reason was `om80` context file replaced the `script_dir` variable that was also set and used in `private_gke_code_snippets`. After that the `script_dir` pointed to `./scripts/dev/contexts/variables` instead of `./scripts/dev/contexts/` and the `gke` script could not be found. The solution was to replace `script_dir` usage in `om80` script with `PROJECT_DIR`. It was also replaced in other scripts which had long path based on `script_dir`. The other thing that was fixed is `switch_context` function. Previously because we concatenated result from multiple bash commands, we didn't consume the error code from actual command: ``` script: | echo "Switching context" scripts/dev/switch_context.sh "${build_variant}" echo "Finished switching context" ``` ## Proof of Work Passing CI + manual patch for [private_gke_code_snippets](https://spruce.mongodb.com/version/68d50ec1cafe8c000760009e) . ## Checklist - [ ] Have you linked a jira ticket and/or is the ticket in the title? - [ ] Have you checked whether your jira ticket required DOCSP changes? - [ ] Have you added changelog file? - use `skip-changelog` label if not needed - refer to [Changelog files and Release Notes](https://github.com/mongodb/mongodb-kubernetes/blob/master/CONTRIBUTING.md#changelog-files-and-release-notes) section in CONTRIBUTING.md for more details
1 parent 12f405a commit a712422

15 files changed

+22
-41
lines changed

.evergreen-functions.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,15 @@ functions:
7777
echo "Finished initializing to the root context"
7878
7979
switch_context: &switch_context
80-
command: shell.exec
80+
command: subprocess.exec
8181
type: setup
8282
params:
83-
shell: bash
8483
working_dir: src/github.com/mongodb/mongodb-kubernetes
8584
<<: *e2e_include_expansions_in_env
8685
add_to_path:
8786
- ${workdir}/bin
8887
- ${workdir}/google-cloud-sdk/bin
89-
script: |
90-
echo "Switching context"
91-
scripts/dev/switch_context.sh "${build_variant}"
92-
echo "Finished switching context"
88+
command: scripts/dev/switch_context.sh "${build_variant}"
9389

9490
python_venv: &python_venv
9591
command: subprocess.exec
@@ -249,7 +245,7 @@ functions:
249245
working_dir: src/github.com/mongodb/mongodb-kubernetes
250246
add_to_path:
251247
- ${workdir}/bin
252-
command: scripts/dev/setup_chart_testing_cli.sh
248+
command: scripts/dev/setup_chart_testing_cli.sh
253249

254250
lint_repo:
255251
- command: subprocess.exec
@@ -305,7 +301,6 @@ functions:
305301
# the task configures the set of tools necessary for any task working with K8 cluster:
306302
# installs kubectl, jq, kind (if necessary), configures docker authentication
307303
download_kube_tools:
308-
- *switch_context
309304
- *setup_kubectl
310305
- *setup_jq
311306
# we need aws to configure docker authentication

scripts/dev/contexts/e2e_mdb_kind_ubi_cloudqa

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export ops_manager_version="cloud_qa"
1111

1212
# This is required to be able to rebuild the om image and use that image which has been rebuilt
1313
export OPS_MANAGER_REGISTRY="${BASE_REPO_URL}"
14-
CUSTOM_OM_VERSION=$(grep -E "^\s*-\s*&ops_manager_70_latest\s+(\S+)\s+#" <"${script_dir}"/../../../.evergreen.yml | awk '{print $3}')
14+
CUSTOM_OM_VERSION=$(grep -E "^\s*-\s*&ops_manager_70_latest\s+(\S+)\s+#" <"${PROJECT_DIR}"/.evergreen.yml | awk '{print $3}')
1515
export CUSTOM_OM_VERSION
1616

1717
export CUSTOM_MDB_VERSION=6.0.5

scripts/dev/contexts/e2e_smoke_ibm_power

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ source "${script_dir}/variables/e2e_ibm_smoke_base"
1010

1111
# This is required to be able to rebuild the om image and use that image which has been rebuilt
1212
export OPS_MANAGER_REGISTRY=268558157000.dkr.ecr.us-east-1.amazonaws.com/dev
13-
CUSTOM_OM_VERSION=$(grep -E "^\s*-\s*&ops_manager_70_latest\s+(\S+)\s+#" <"${script_dir}"/../../../.evergreen.yml | awk '{print $3}')
13+
CUSTOM_OM_VERSION=$(grep -E "^\s*-\s*&ops_manager_70_latest\s+(\S+)\s+#" <"${PROJECT_DIR}"/.evergreen.yml | awk '{print $3}')
1414
export CUSTOM_OM_VERSION

scripts/dev/contexts/e2e_smoke_ibm_z

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ source "${script_dir}/variables/e2e_ibm_smoke_base"
1010

1111
# This is required to be able to rebuild the om image and use that image which has been rebuilt
1212
export OPS_MANAGER_REGISTRY=268558157000.dkr.ecr.us-east-1.amazonaws.com/dev
13-
CUSTOM_OM_VERSION=$(grep -E "^\s*-\s*&ops_manager_70_latest\s+(\S+)\s+#" <"${script_dir}"/../../../.evergreen.yml | awk '{print $3}')
13+
CUSTOM_OM_VERSION=$(grep -E "^\s*-\s*&ops_manager_70_latest\s+(\S+)\s+#" <"${PROJECT_DIR}"/.evergreen.yml | awk '{print $3}')
1414
export CUSTOM_OM_VERSION

scripts/dev/contexts/e2e_static_mdb_kind_ubi_cloudqa

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export MDB_DEFAULT_ARCHITECTURE=static
1212

1313
# This is required to be able to rebuild the om image and use that image which has been rebuilt
1414
export OPS_MANAGER_REGISTRY="${BASE_REPO_URL}"
15-
CUSTOM_OM_VERSION=$(grep -E "^\s*-\s*&ops_manager_70_latest\s+(\S+)\s+#" <"${script_dir}"/../../../.evergreen.yml | awk '{print $3}')
15+
CUSTOM_OM_VERSION=$(grep -E "^\s*-\s*&ops_manager_70_latest\s+(\S+)\s+#" <"${PROJECT_DIR}"/.evergreen.yml | awk '{print $3}')
1616
export CUSTOM_OM_VERSION
1717

1818
export CUSTOM_MDB_PREV_VERSION=6.0.16

scripts/dev/contexts/e2e_static_smoke_arm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export ops_manager_version="cloud_qa"
1111

1212
# This is required to be able to rebuild the om image and use that image which has been rebuilt
1313
export OPS_MANAGER_REGISTRY=268558157000.dkr.ecr.us-east-1.amazonaws.com/dev
14-
CUSTOM_OM_VERSION=$(grep -E "^\s*-\s*&ops_manager_70_latest\s+(\S+)\s+#" <"${script_dir}"/../../../.evergreen.yml | awk '{print $3}')
14+
CUSTOM_OM_VERSION=$(grep -E "^\s*-\s*&ops_manager_70_latest\s+(\S+)\s+#" <"${PROJECT_DIR}"/.evergreen.yml | awk '{print $3}')
1515
export CUSTOM_OM_VERSION
1616

1717
export CUSTOM_MDB_VERSION=7.0.22 # we only have ibm static images starting with 7.0.22

scripts/dev/contexts/e2e_static_smoke_ibm_power

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ source "${script_dir}/variables/e2e_ibm_smoke_base"
1010

1111
# This is required to be able to rebuild the om image and use that image which has been rebuilt
1212
export OPS_MANAGER_REGISTRY=268558157000.dkr.ecr.us-east-1.amazonaws.com/dev
13-
CUSTOM_OM_VERSION=$(grep -E "^\s*-\s*&ops_manager_70_latest\s+(\S+)\s+#" <"${script_dir}"/../../../.evergreen.yml | awk '{print $3}')
13+
CUSTOM_OM_VERSION=$(grep -E "^\s*-\s*&ops_manager_70_latest\s+(\S+)\s+#" <"${PROJECT_DIR}"/.evergreen.yml | awk '{print $3}')
1414
export CUSTOM_OM_VERSION
1515
export MDB_DEFAULT_ARCHITECTURE=static
1616
# MDB supports ppc64le on RHEL9 only from 8.0.12 onwards

scripts/dev/contexts/e2e_static_smoke_ibm_z

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ source "${script_dir}/variables/e2e_ibm_smoke_base"
1010

1111
# This is required to be able to rebuild the om image and use that image which has been rebuilt
1212
export OPS_MANAGER_REGISTRY=268558157000.dkr.ecr.us-east-1.amazonaws.com/dev
13-
CUSTOM_OM_VERSION=$(grep -E "^\s*-\s*&ops_manager_70_latest\s+(\S+)\s+#" <"${script_dir}"/../../../.evergreen.yml | awk '{print $3}')
13+
CUSTOM_OM_VERSION=$(grep -E "^\s*-\s*&ops_manager_70_latest\s+(\S+)\s+#" <"${PROJECT_DIR}"/.evergreen.yml | awk '{print $3}')
1414
export CUSTOM_OM_VERSION
1515
export MDB_DEFAULT_ARCHITECTURE=static
1616
# MDB supports s390x on RHEL9 only from 8.0.12 onwards

scripts/dev/contexts/funcs/gke

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -Eeou pipefail
4+
15
# Function to normalize identifier to contain only alphanumeric characters.
26
# It's also cutting the string in the middle if exceeds max_len.
37
# Example:

scripts/dev/contexts/variables/om60

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22

33
set -Eeou pipefail
44

5-
script_name=$(readlink -f "${BASH_SOURCE[0]}")
6-
script_dir=$(dirname "${script_name}")
7-
85
CUSTOM_OM_PREV_VERSION=6.0.0
96
export CUSTOM_OM_PREV_VERSION
10-
CUSTOM_OM_VERSION=$(grep -E "^\s*-\s*&ops_manager_60_latest\s+(\S+)\s+#" <"${script_dir}"/../../../../.evergreen.yml | awk '{print $3}')
7+
CUSTOM_OM_VERSION=$(grep -E "^\s*-\s*&ops_manager_60_latest\s+(\S+)\s+#" <"${PROJECT_DIR}"/.evergreen.yml | awk '{print $3}')
118
export CUSTOM_OM_VERSION
129

1310
export CUSTOM_MDB_VERSION=6.0.21

0 commit comments

Comments
 (0)