Skip to content

Commit 7ceaa5e

Browse files
committed
chore: apply precommit changes
1 parent 0b8d1f6 commit 7ceaa5e

File tree

134 files changed

+718
-864
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+718
-864
lines changed

.pre-commit-config.yaml

Lines changed: 18 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -95,81 +95,33 @@ repos:
9595
^scripts/funcs/[^/]+$
9696
)
9797
98+
# Formatting hooks (these modify files)
99+
- repo: https://github.com/psf/black
100+
rev: 24.10.0
101+
hooks:
102+
- id: black
103+
language_version: python3
104+
105+
- repo: https://github.com/pycqa/isort
106+
rev: 5.13.2
107+
hooks:
108+
- id: isort
109+
args: ["--profile", "black"]
110+
111+
# Slow linting/generation hooks last
98112
- repo: https://github.com/golangci/golangci-lint
99113
rev: v1.62.2
100114
hooks:
101115
- id: golangci-lint
102116
args: [--timeout=10m]
103117

104118
# Local hooks for project-specific tasks
119+
# These run in parallel via scripts/dev/generate_files.sh
105120
- repo: local
106121
hooks:
107-
- id: update-release-json
108-
name: update-release-json
109-
entry: scripts/dev/generate_files.sh update_release
110-
language: system
111-
pass_filenames: false
112-
stages: [pre-commit]
113-
114-
- id: update-values-yaml
115-
name: update-values-yaml
116-
entry: scripts/dev/generate_files.sh update_values
117-
language: system
118-
pass_filenames: false
119-
stages: [pre-commit]
120-
121-
- id: generate-standalone-yaml
122-
name: generate-standalone-yaml
123-
entry: scripts/dev/generate_files.sh generate_standalone_yaml
124-
language: system
125-
pass_filenames: false
126-
stages: [pre-commit]
127-
128-
- id: generate-manifests
129-
name: generate-manifests
130-
entry: scripts/dev/generate_files.sh generate_manifests
131-
language: system
132-
pass_filenames: false
133-
stages: [pre-commit]
134-
135-
- id: regenerate-mco-tests
136-
name: regenerate-mco-tests
137-
entry: scripts/dev/generate_files.sh update_mco_tests
138-
language: system
139-
pass_filenames: false
140-
stages: [pre-commit]
141-
142-
- id: regenerate-multicluster-rbac
143-
name: regenerate-multicluster-rbac
144-
entry: scripts/dev/regenerate_multicluster_rbac.sh
145-
language: system
146-
pass_filenames: false
147-
stages: [pre-commit]
148-
149-
- id: update-licenses
150-
name: update-licenses
151-
entry: scripts/dev/generate_files.sh update_licenses
152-
language: system
153-
pass_filenames: false
154-
stages: [pre-commit]
155-
156-
- id: validate-snippets
157-
name: validate-snippets
158-
entry: scripts/code_snippets/validate_snippets.py
159-
language: system
160-
pass_filenames: false
161-
stages: [pre-commit]
162-
163-
- id: check-kubebuilder-annotations
164-
name: check-kubebuilder-annotations
165-
entry: bash -c 'if grep -r "// kubebuilder" --include="*.go" --exclude-dir=vendor .; then echo "Found erroneous kubebuilder annotation"; exit 1; fi'
166-
language: system
167-
pass_filenames: false
168-
stages: [pre-commit]
169-
170-
- id: helm-lint
171-
name: helm-lint
172-
entry: scripts/dev/lint_helm_chart.sh
122+
- id: generate-and-validate
123+
name: generate-and-validate (parallel)
124+
entry: scripts/dev/generate_files.sh generate_all
173125
language: system
174126
pass_filenames: false
175127
stages: [pre-commit]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
kind: other
3+
date: 2025-12-10
4+
---
5+
6+
* **Operator configuration**: Removed the unused `MDB_IMAGE_TYPE` environment variable and the corresponding `mongodb.imageType` Helm value. This variable was deprecated in v1.28.0 of the MongoDB Enterprise Kubernetes Operator when it switched to architecture-based image selection (ubi9 for static, ubi8 for non-static). This is a cleanup change with no functional impact.

config/manager/manager.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ spec:
9494
value: mongodb-enterprise-server
9595
- name: MONGODB_REPO_URL
9696
value: quay.io/mongodb
97-
- name: MDB_IMAGE_TYPE
98-
value: ubi8
9997
- name: PERFORM_FAILOVER
10098
value: 'true'
10199
- name: MDB_WEBHOOK_REGISTER_CONFIGURATION

docker/cluster-cleaner/scripts/clean-failed-namespaces.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ delete_resources_safely() {
77
resource_type="$1"
88
namespace="$2"
99

10-
echo "Attempting normal deletion of $resource_type in $namespace..."
10+
echo "Attempting normal deletion of ${resource_type} in ${namespace}..."
1111
kubectl delete "${resource_type}" --all -n "${namespace}" --wait=true --timeout=10s 2>error.log|| true
1212

1313
# Check if any resources are still stuck
1414
# Let's not fail here and continue deletion
15-
resources=$(kubectl get "$resource_type" -n "${namespace}" --no-headers -o custom-columns=":metadata.name" 2>error.log || true)
15+
resources=$(kubectl get "${resource_type}" -n "${namespace}" --no-headers -o custom-columns=":metadata.name" 2>error.log || true)
1616

1717
for resource in ${resources}; do
1818
echo "${resource_type}/${resource} is still present, force deleting..."
@@ -39,7 +39,7 @@ kubectl get namespace -l "${LABELS}" -o name
3939
for namespace in $(kubectl get namespace -l "${LABELS}" -o name 2>error.log); do
4040
creation_time=$(kubectl get "${namespace}" -o jsonpath='{.metadata.creationTimestamp}' 2>error.log || echo "")
4141

42-
if [ -z "$creation_time" ]; then
42+
if [ -z "${creation_time}" ]; then
4343
echo "Namespace ${namespace} does not exist or has no creation timestamp, skipping."
4444
continue
4545
fi

docker/delve-sidecar/attach-delve.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ while ! pgrep -f "mongodb-mms-automation-agent" > /dev/null; do
88
done
99

1010
APP_PID=$(pgrep -f "mongodb-mms-automation-agent")
11-
echo "Found app with PID: $APP_PID, attaching Delve..."
11+
echo "Found app with PID: ${APP_PID}, attaching Delve..."
1212

13-
dlv attach "$APP_PID" --headless --listen=:2345 --api-version=2 --accept-multiclient --continue
13+
dlv attach "${APP_PID}" --headless --listen=:2345 --api-version=2 --accept-multiclient --continue

docker/mongodb-agent/agent-launcher-shim.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ SCRIPTS_DIR="/opt/scripts"
99
# Function to start the agent launcher
1010
start_agent_launcher() {
1111
echo "Starting agent launcher..."
12-
echo "Final contents of $SCRIPTS_DIR:"
13-
ls -la "$SCRIPTS_DIR"
12+
echo "Final contents of ${SCRIPTS_DIR}:"
13+
ls -la "${SCRIPTS_DIR}"
1414

15-
if [[ -f "$SCRIPTS_DIR/agent-launcher.sh" ]]; then
15+
if [[ -f "${SCRIPTS_DIR}/agent-launcher.sh" ]]; then
1616
echo "Found agent-launcher.sh, executing..."
1717
echo "Note: agent-launcher.sh will become PID 1 and handle all signal processing including cleanup"
18-
exec "$SCRIPTS_DIR/agent-launcher.sh"
18+
exec "${SCRIPTS_DIR}/agent-launcher.sh"
1919
else
2020
echo "ERROR: agent-launcher.sh not found"
2121
exit 1

docker/mongodb-agent/dummy-probe.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,34 @@
44
find_init_container() {
55
local pid
66
pid=$(pgrep -f "agent-utilities-holder_marker" | head -n1)
7-
if [[ -n "$pid" && -d "/proc/$pid/root/probes" ]]; then
8-
echo "$pid"
7+
if [[ -n "${pid}" && -d "/proc/${pid}/root/probes" ]]; then
8+
echo "${pid}"
99
return 0
1010
fi
1111
return 1
1212
}
1313

1414
execute_liveness_probe() {
1515
local init_pid="$1"
16-
local init_probe_path="/proc/$init_pid/root/probes/probe.sh"
16+
local init_probe_path="/proc/${init_pid}/root/probes/probe.sh"
1717

18-
if [[ ! -f "$init_probe_path" ]]; then
19-
echo "ERROR: Liveness probe script not found at $init_probe_path"
18+
if [[ ! -f "${init_probe_path}" ]]; then
19+
echo "ERROR: Liveness probe script not found at ${init_probe_path}"
2020
exit 1
21-
elif [[ ! -x "$init_probe_path" ]]; then
22-
echo "ERROR: Liveness probe script not executable at $init_probe_path"
21+
elif [[ ! -x "${init_probe_path}" ]]; then
22+
echo "ERROR: Liveness probe script not executable at ${init_probe_path}"
2323
exit 1
2424
else
2525
# Execute the actual probe script from the init-database container
2626
# This works because of shared process namespace - the probe can see all processes
27-
exec "$init_probe_path"
27+
exec "${init_probe_path}"
2828
fi
2929
}
3030

3131
# Main execution
3232
if init_pid=$(find_init_container); then
33-
echo "Found init container with PID: $init_pid, executing liveness probe..."
34-
execute_liveness_probe "$init_pid"
33+
echo "Found init container with PID: ${init_pid}, executing liveness probe..."
34+
execute_liveness_probe "${init_pid}"
3535
else
3636
echo "WARNING: Init container not found, falling back to basic liveness check"
3737
# Fallback: if we can't find the init container, just check if this container is alive

docker/mongodb-agent/setup-agent-files.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ SCRIPTS_DIR="/opt/scripts"
88
# readiness always returns failure
99
setup_dummy_probes() {
1010
echo "Setting up dummy probe scripts..."
11-
cp --remove-destination /usr/local/bin/dummy-probe.sh "$SCRIPTS_DIR/probe.sh"
12-
cp --remove-destination /usr/local/bin/dummy-readinessprobe "$SCRIPTS_DIR/readinessprobe"
11+
cp --remove-destination /usr/local/bin/dummy-probe.sh "${SCRIPTS_DIR}/probe.sh"
12+
cp --remove-destination /usr/local/bin/dummy-readinessprobe "${SCRIPTS_DIR}/readinessprobe"
1313
echo "Dummy probe scripts ready"
1414
}
1515

@@ -18,11 +18,11 @@ find_init_container() {
1818
for i in {1..150}; do
1919
local pid
2020
pid=$(pgrep -f "agent-utilities-holder_marker" | head -n1)
21-
if [[ -n "$pid" && -d "/proc/$pid/root/scripts" ]]; then
22-
echo "$pid"
21+
if [[ -n "${pid}" && -d "/proc/${pid}/root/scripts" ]]; then
22+
echo "${pid}"
2323
return 0
2424
fi
25-
echo "Waiting for init container... (attempt $i)" >&2
25+
echo "Waiting for init container... (attempt ${i})" >&2
2626
sleep 2
2727
done
2828
return 1
@@ -33,8 +33,8 @@ link_agent_scripts() {
3333

3434
echo "Linking agent launcher scripts..."
3535
for script in agent-launcher.sh agent-launcher-lib.sh; do
36-
ln -sf "$init_scripts_dir/$script" "$SCRIPTS_DIR/$script"
37-
echo "Linked $script"
36+
ln -sf "${init_scripts_dir}/${script}" "${SCRIPTS_DIR}/${script}"
37+
echo "Linked ${script}"
3838
done
3939
}
4040

@@ -44,26 +44,26 @@ main() {
4444
setup_dummy_probes
4545

4646
if init_pid=$(find_init_container); then
47-
echo "Found init container with PID: $init_pid"
47+
echo "Found init container with PID: ${init_pid}"
4848

49-
init_root="/proc/$init_pid/root"
50-
init_scripts="$init_root/scripts"
51-
init_probes="$init_root/probes"
49+
init_root="/proc/${init_pid}/root"
50+
init_scripts="${init_root}/scripts"
51+
init_probes="${init_root}/probes"
5252

5353
# Verify scripts directory exists
54-
if [[ ! -d "$init_scripts" ]]; then
55-
echo "ERROR: Scripts directory $init_scripts not found"
54+
if [[ ! -d "${init_scripts}" ]]; then
55+
echo "ERROR: Scripts directory ${init_scripts} not found"
5656
exit 1
5757
fi
5858

5959
# Verify probes directory exists
60-
if [[ ! -d "$init_probes" ]]; then
61-
echo "ERROR: Probes directory $init_probes not found"
60+
if [[ ! -d "${init_probes}" ]]; then
61+
echo "ERROR: Probes directory ${init_probes} not found"
6262
exit 1
6363
fi
6464

6565
# Link scripts from init container
66-
link_agent_scripts "$init_scripts"
66+
link_agent_scripts "${init_scripts}"
6767

6868
echo "File setup completed successfully"
6969
exit 0

docker/mongodb-kubernetes-init-database/content/probe.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -Eeou pipefail
44
check_process() {
55
local check_process=$1
66
# shellcheck disable=SC2009
7-
ps -ax | grep -v " grep " | grep -v jq | grep -v tail | grep "$check_process"
7+
ps -ax | grep -v " grep " | grep -v jq | grep -v tail | grep "${check_process}"
88
return $?
99
}
1010

docker/mongodb-kubernetes-tests/kubetester/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111

1212
# Re-exports
1313
from .kubetester import fixture as find_fixture
14-
from .security_context import (
15-
assert_pod_container_security_context,
16-
assert_pod_security_context,
17-
)
14+
from .security_context import assert_pod_container_security_context, assert_pod_security_context
1815

1916

2017
def create_secret(

0 commit comments

Comments
 (0)