Skip to content

Commit 1539447

Browse files
committed
Merge branch 'master' of github.com:mongodb/mongodb-kubernetes into migrate-repo
2 parents 33e7ee0 + b90c986 commit 1539447

20 files changed

+183
-87
lines changed

.evergreen-functions.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,17 @@ functions:
541541
- ${workdir}/bin
542542
binary: scripts/evergreen/e2e/build_tests_image_ibm.sh
543543

544+
pipeline_migrate_agents:
545+
- *switch_context
546+
- command: subprocess.exec
547+
retry_on_failure: false
548+
type: setup
549+
params:
550+
shell: bash
551+
<<: *e2e_include_expansions_in_env
552+
working_dir: src/github.com/mongodb/mongodb-kubernetes
553+
binary: scripts/release/pipeline_migrate_agent.sh
554+
544555
pipeline:
545556
- *switch_context
546557
- command: subprocess.exec

.evergreen.yml

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,15 @@ tasks:
356356
image_name: agent
357357
build_scenario: --build-scenario manual_release
358358

359+
- name: migrate_all_agents
360+
# this enables us to run this variant manually to build all the agents for the new registry
361+
allowed_requesters: [ "patch" ]
362+
commands:
363+
- func: clone
364+
- func: setup_building_host
365+
- func: quay_login
366+
- func: pipeline_migrate_agents
367+
359368
- name: run_precommit_and_push
360369
tags: ["patch-run"]
361370
commands:
@@ -1375,7 +1384,7 @@ buildvariants:
13751384
display_name: e2e_om60_kind_ubi
13761385
tags: [ "e2e_test_suite" ]
13771386
run_on:
1378-
- ubuntu2204-large
1387+
- ubuntu2204-medium-high-memory
13791388
<<: *base_om6_dependency
13801389
tasks:
13811390
- name: e2e_ops_manager_kind_only_task_group
@@ -1387,7 +1396,7 @@ buildvariants:
13871396
display_name: e2e_static_om60_kind_ubi
13881397
tags: [ "e2e_test_suite" ]
13891398
run_on:
1390-
- ubuntu2204-large
1399+
- ubuntu2204-medium
13911400
<<: *base_om6_dependency
13921401
tasks:
13931402
- name: e2e_static_ops_manager_kind_only_task_group
@@ -1397,7 +1406,7 @@ buildvariants:
13971406
display_name: e2e_om70_kind_ubi
13981407
tags: [ "e2e_test_suite" ]
13991408
run_on:
1400-
- ubuntu2204-large
1409+
- ubuntu2204-medium-high-memory
14011410
<<: *base_om7_dependency
14021411
tasks:
14031412
- name: e2e_ops_manager_kind_only_task_group
@@ -1420,7 +1429,7 @@ buildvariants:
14201429
display_name: e2e_om80_kind_ubi
14211430
tags: [ "e2e_test_suite" ]
14221431
run_on:
1423-
- ubuntu2204-large
1432+
- ubuntu2204-medium-high-memory
14241433
<<: *base_om8_dependency
14251434
tasks:
14261435
- name: e2e_ops_manager_kind_only_task_group
@@ -1586,7 +1595,7 @@ buildvariants:
15861595

15871596
- name: e2e_multi_cluster_kind
15881597
display_name: e2e_multi_cluster_kind
1589-
tags: [ "e2e_test_suite" ]
1598+
tags: [ "e2e_test_suite", "cloudqa"]
15901599
run_on:
15911600
- ubuntu2204-large
15921601
<<: *base_om6_dependency
@@ -1595,7 +1604,7 @@ buildvariants:
15951604

15961605
- name: e2e_static_multi_cluster_kind
15971606
display_name: e2e_static_multi_cluster_kind
1598-
tags: [ "e2e_test_suite" ]
1607+
tags: [ "e2e_test_suite", "cloudqa"]
15991608
run_on:
16001609
- ubuntu2204-large
16011610
<<: *base_om6_dependency
@@ -1604,7 +1613,7 @@ buildvariants:
16041613

16051614
- name: e2e_multi_cluster_2_clusters
16061615
display_name: e2e_multi_cluster_2_clusters
1607-
tags: [ "e2e_test_suite" ]
1616+
tags: [ "e2e_test_suite", "cloudqa"]
16081617
run_on:
16091618
- ubuntu2204-large
16101619
<<: *base_om6_dependency
@@ -1613,7 +1622,7 @@ buildvariants:
16131622

16141623
- name: e2e_static_multi_cluster_2_clusters
16151624
display_name: e2e_static_multi_cluster_2_clusters
1616-
tags: [ "e2e_test_suite" ]
1625+
tags: [ "e2e_test_suite", "cloudqa"]
16171626
run_on:
16181627
- ubuntu2204-large
16191628
<<: *base_om6_dependency
@@ -2097,3 +2106,11 @@ buildvariants:
20972106
tasks:
20982107
- name: publish_ops_manager
20992108
- name: release_agent
2109+
2110+
- name: migrate_all_agents
2111+
display_name: migrate_all_agents
2112+
allowed_requesters: [ "patch" ]
2113+
run_on:
2114+
- ubuntu2204-large
2115+
tasks:
2116+
- name: migrate_all_agents

.githooks/pre-commit

Lines changed: 109 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ fi
1818

1919
mkdir -p "$(go env GOPATH)/bin"
2020

21-
function update_mco_tests() {
21+
update_mco_tests() {
2222
echo "Regenerating MCO evergreen tests configuration"
2323
python scripts/evergreen/e2e/mco/create_mco_tests.py >.evergreen-mco.yml
2424
git add .evergreen-mco.yml
2525
}
2626

2727
# Generates a yaml file to install the operator from the helm sources.
28-
function generate_standalone_yaml() {
28+
generate_standalone_yaml() {
2929
HELM_OPTS=$@
3030

3131
charttmpdir=$(mktemp -d 2>/dev/null || mktemp -d -t 'charttmpdir')
@@ -73,7 +73,7 @@ function generate_standalone_yaml() {
7373

7474
}
7575

76-
function python_formatting() {
76+
python_formatting() {
7777
# installing Black
7878
if ! command -v "black" >/dev/null; then
7979
pip install -r requirements.txt
@@ -85,15 +85,15 @@ function python_formatting() {
8585
black .
8686
}
8787

88-
function generate_manifests() {
88+
generate_manifests() {
8989
make manifests
9090

9191
git add config/crd/bases
9292
git add helm_chart/crds
9393
git add public/crds.yaml
9494
}
9595

96-
function update_values_yaml_files() {
96+
update_values_yaml_files() {
9797
# ensure that all helm values files are up to date.
9898
# shellcheck disable=SC2154
9999
python scripts/evergreen/release/update_helm_values_files.py
@@ -107,7 +107,7 @@ function update_values_yaml_files() {
107107
git add go.sum
108108
}
109109

110-
function update_release_json() {
110+
update_release_json() {
111111
# ensure that release.json is up 2 date
112112
# shellcheck disable=SC2154
113113
python scripts/evergreen/release/update_release.py
@@ -116,7 +116,7 @@ function update_release_json() {
116116
git add release.json
117117
}
118118

119-
function regenerate_public_rbac_multi_cluster() {
119+
regenerate_public_rbac_multi_cluster() {
120120
if echo "$git_last_changed" | grep -q -e 'cmd/kubectl-mongodb' -e 'pkg/kubectl-mongodb'; then
121121
echo 'regenerating multicluster RBAC public example'
122122
pushd pkg/kubectl-mongodb/common/
@@ -126,78 +126,135 @@ function regenerate_public_rbac_multi_cluster() {
126126
fi
127127
}
128128

129-
function update_licenses() {
130-
echo 'regenerating licenses'
131-
time scripts/evergreen/update_licenses.sh 2>&1 | prepend "update_licenses"
132-
git add LICENSE-THIRD-PARTY
129+
update_licenses() {
130+
if [[ "${MDB_UPDATE_LICENSES:-""}" == "true" ]]; then
131+
echo 'regenerating licenses'
132+
time scripts/evergreen/update_licenses.sh 2>&1 | prepend "update_licenses"
133+
git add LICENSE-THIRD-PARTY
134+
fi
133135
}
134136

135-
function check_erroneous_kubebuilder_annotations() {
137+
check_erroneous_kubebuilder_annotations() {
136138
# Makes sure there are not erroneous kubebuilder annotations that can
137139
# end up in CRDs as descriptions.
138140
if grep "// kubebuilder" ./* -r --exclude-dir=vendor --include=\*.go; then
139-
echo "Found an erroneous kubebuilder annotation"
141+
echo -e "${RED}Found an erroneous kubebuilder annotation${NO_COLOR}"
140142
exit 1
141143
fi
142144
}
143145

144-
function check_incorrect_makefile_variable_brackets() {
146+
check_incorrect_makefile_variable_brackets() {
145147
if find . -name "Makefile" | grep -v vendor | xargs grep "\${"; then
146-
echo 'ERROR: Makefiles should NEVER contain curly brackets variables'
148+
echo -e "${RED}ERROR: Makefiles should NEVER contain curly brackets variables${NO_COLOR}"
147149
exit 1
148150
fi
149151
}
150152

151-
function pre_commit() {
152-
if [[ "${MDB_UPDATE_LICENSES:-""}" == "true" ]]; then
153-
( (time update_licenses) 2>&1 | prepend "update_licenses" ) &
154-
fi
155-
( (time scripts/evergreen/lint_code.sh) 2>&1 | prepend "lint_code.sh" ) &
156-
( (time start_shellcheck) 2>&1 | prepend "shellcheck" ) &
153+
update_jobs() {
154+
# Update release.json first in case there is a newer version
155+
time update_release_json
156+
# We need to generate the values files first
157+
time update_values_yaml_files
158+
# The values files are used for generating the standalone yaml
159+
time generate_standalone_yaml
160+
}
157161

158-
# Update release.json first in case there is a newer version
159-
(time update_release_json) 2>&1 | prepend "update_release_json"
160-
# We need to generate the values files first
161-
(time update_values_yaml_files) 2>&1 | prepend "update_values_yaml_files"
162-
# The values files are used for generating the standalone yaml
163-
(time generate_standalone_yaml) 2>&1 | prepend "generate_standalone_yaml"
162+
lint_code() {
163+
scripts/evergreen/lint_code.sh
164+
}
164165

165-
( (time regenerate_public_rbac_multi_cluster) 2>&1 | prepend "regenerate_public_rbac_multi_cluster" ) &
166+
# bg_job_ vars are global; run_job_in_background function is appending to them on each call
167+
bg_job_pids=()
168+
bg_job_pids_with_names=()
166169

167-
# Run black and isort on python files that have changed
168-
( (time python_formatting) 2>&1 | prepend "python_formatting") &
170+
get_job_name() {
171+
local search_pid="$1"
172+
local match
173+
match=$(printf '%s\n' "${bg_job_pids_with_names[@]}" | grep "^${search_pid}:")
174+
echo "${match#*:}" # Remove everything up to and including the colon
175+
}
169176

170-
( (time check_erroneous_kubebuilder_annotations) 2>&1 | prepend "check_erroneous_kubebuilder_annotations" ) &
177+
# Executes function given on the first argument as background job.
178+
# It's ensuring logs are properly prefixed by the name and
179+
# the job's pid is captured in bg_jobs array in order to wait for completion.
180+
run_job_in_background() {
181+
job_name=$1
182+
time ${job_name} 2>&1 | prepend "${job_name}" &
183+
184+
local job_pid=$!
185+
bg_job_pids+=("${job_pid}")
186+
bg_job_pids_with_names+=("${job_pid}:${job_name}")
187+
echo "Started ${job_name} with PID: ${job_pid}"
188+
}
189+
190+
# Waits for all background jobs stored in bg_job_pids and check their exit codes.
191+
wait_for_all_background_jobs() {
192+
failures=()
193+
for pid in "${bg_job_pids[@]}"; do
194+
wait "${pid}" || {
195+
job_name=$(get_job_name "${pid}")
196+
failures+=(" ${RED}${job_name} (PID ${pid})${NO_COLOR}")
197+
}
198+
done
199+
200+
if [[ ${#failures[@]} -gt 0 ]]; then
201+
echo -e "${RED}Some checks have failed:${NO_COLOR}"
202+
for failure in "${failures[@]}"; do
203+
echo -e "$failure"
204+
done
205+
echo -e "${RED}To see the details look/filter for the job's logs by it's prefixed name (e.g. \"start_shellcheck:\", \"lint_code:\", \"shellcheck failed\").${NO_COLOR}"
206+
return 1
207+
fi
171208

172-
wait
209+
return 0
210+
}
211+
212+
pre_commit() {
213+
run_job_in_background "update_jobs"
214+
run_job_in_background "update_licenses"
215+
run_job_in_background "lint_code"
216+
run_job_in_background "start_shellcheck"
217+
run_job_in_background "regenerate_public_rbac_multi_cluster"
218+
run_job_in_background "python_formatting"
219+
run_job_in_background "check_erroneous_kubebuilder_annotations"
220+
221+
if wait_for_all_background_jobs; then
222+
echo -e "${GREEN}pre-commit: All checks passed!${NO_COLOR}"
223+
return 0
224+
else
225+
return 1
226+
fi
173227
}
174228

175229
# Function to run shellcheck on a single file
176230
run_shellcheck() {
177231
local file="$1"
178-
echo "Running shellcheck on $file"
179-
if ! shellcheck --color=always -x "$file" -e SC2154 -e SC1091 -e SC1090 -e SC2148 -o require-variable-braces -P "scripts"; then
180-
echo "shellcheck failed on $file"
181-
exit 1
232+
233+
local diff_output
234+
diff_output=$(shellcheck -f diff "$file" -e SC2154 -e SC1091 -e SC1090 -e SC2148 -o require-variable-braces -P "scripts" 2>&1)
235+
236+
if [[ -n "$diff_output" && "$diff_output" != *"Issues were detected, but none were auto-fixable"* ]]; then
237+
echo "$diff_output" | git apply
238+
echo "Applied auto-fixes for $file"
239+
elif [[ "$diff_output" == *"Issues were detected, but none were auto-fixable"* ]]; then
240+
echo -e "${RED}shellcheck failed on $file${NO_COLOR}"
241+
shellcheck --color=always -x "$file" -e SC2154 -e SC1091 -e SC1090 -e SC2148 -o require-variable-braces -P "scripts"
242+
return 1
182243
fi
183244
}
184245

185-
start_shellcheck() {
186-
files_1=$(find scripts -type f -name "*.sh")
187-
files_2=$(find scripts/dev/contexts -type f | grep -v private-context)
188-
files_3=$(find scripts/funcs -type f)
189-
files_4=$(find public/architectures -type f -name "*.sh")
190-
files=$(echo -e "$files_1\n$files_2\n$files_3\n$files_4")
191-
# Process each file in parallel
192-
for file in $files; do
193-
run_shellcheck "$file" &
194-
done
195-
196-
# Wait for all background jobs
197-
for job in $(jobs -p); do
198-
wait "$job" || exit 1
199-
done
246+
# Export function so it's available in subshells (for xargs)
247+
export -f run_shellcheck
200248

249+
start_shellcheck() {
250+
# shellcheck disable=SC2016
251+
{
252+
find scripts -type f -name "*.sh"
253+
find scripts/dev/contexts -type f | grep -v private-context
254+
find scripts/funcs -type f
255+
find public/architectures -type f -name "*.sh"
256+
find docs/ -type f -name "*.sh"
257+
} | xargs -I {} -P 20 bash -c 'run_shellcheck "$1"' _ {}
201258
}
202259

203260
cmd=${1:-"pre-commit"}
@@ -210,5 +267,5 @@ elif [[ "${cmd}" == "pre-commit" ]]; then
210267
elif [[ "${cmd}" == "shellcheck" ]]; then
211268
start_shellcheck
212269
elif [[ "${cmd}" == "lint" ]]; then
213-
source scripts/evergreen/lint_code.sh
270+
lint_code
214271
fi

config/manager/manager.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ spec:
130130
value: "quay.io/mongodb/mongodb-kubernetes-init-ops-manager:1.2.0"
131131
- name: RELATED_IMAGE_INIT_APPDB_IMAGE_REPOSITORY_1_2_0
132132
value: "quay.io/mongodb/mongodb-kubernetes-init-appdb:1.2.0"
133-
- name: RELATED_IMAGE_AGENT_IMAGE_107_0_11_8645_1
134-
value: "quay.io/mongodb/mongodb-agent:107.0.11.8645-1"
135133
- name: RELATED_IMAGE_AGENT_IMAGE_107_0_12_8669_1
136134
value: "quay.io/mongodb/mongodb-agent:107.0.12.8669-1"
137135
- name: RELATED_IMAGE_AGENT_IMAGE_107_0_13_8702_1

helm_chart/values-openshift.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ relatedImages:
9999
- 8.0.0-ubi8
100100
- 8.0.0-ubi9
101101
agent:
102-
- 107.0.11.8645-1
103102
- 107.0.12.8669-1
104103
- 107.0.13.8702-1
105104
- 107.0.15.8741-1

public/mongodb-kubernetes-openshift.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,6 @@ spec:
434434
value: "quay.io/mongodb/mongodb-kubernetes-init-ops-manager:1.2.0"
435435
- name: RELATED_IMAGE_INIT_APPDB_IMAGE_REPOSITORY_1_2_0
436436
value: "quay.io/mongodb/mongodb-kubernetes-init-appdb:1.2.0"
437-
- name: RELATED_IMAGE_AGENT_IMAGE_107_0_11_8645_1
438-
value: "quay.io/mongodb/mongodb-agent:107.0.11.8645-1"
439437
- name: RELATED_IMAGE_AGENT_IMAGE_107_0_12_8669_1
440438
value: "quay.io/mongodb/mongodb-agent:107.0.12.8669-1"
441439
- name: RELATED_IMAGE_AGENT_IMAGE_107_0_13_8702_1

0 commit comments

Comments
 (0)