Skip to content

Commit 3ec0ca1

Browse files
Fix linting ct lint issue in helm chart (#487)
# Summary Update: Thanks to @MaciejKaras for the comment [here](#487 (review)) and it looks like we were trying to lint the helm chart in parallel to other jobs that were trying to update the helm chart. This PR tries to change that and runs the helm chart linting after the updates to helm chart are made by `update_jobs` job. **Old Desc:** The chart linting command that we run as part of lint_repo task ``` ct lint --charts="${PROJECT_DIR}/helm_chart/" \ --chart-yaml-schema "${PROJECT_DIR}/helm_chart/tests/schemas/chart_schema.yaml" \ --lint-conf "${PROJECT_DIR}/helm_chart/tests/schemas/lintconf.yaml" ``` seems to be flakey. It doesn't seem to fail regularly but we have seen issues that are [reported here](https://mongodb.slack.com/archives/CGLP6R2PQ/p1759148259540819). If we look into the error ``` [ERROR] templates/: template: mongodb-kubernetes/templates/secret-config.yaml:1:14: executing "mongodb-kubernetes/templates/secret-config.yaml" at <.Values.operator.vaultSecretBackend>: nil pointer evaluating interface ``` It looks like `.Values` object that is passed to the template file doesn't have the field `.Values.operator.vaultSecretBackend`. And the only places where the values.yaml doesn't have `vaultSecretBackend` defined are the files `values-openshift.yaml` and `values-multi-cluster.yaml`. And I suspect that - Either these values files are merged and then passed to `helm template`, and merge doesn't work properly and eventually `.Values.operator` has the value that is defined in either `values-openshift.yaml` or in `values-multi-cluster.yaml` (and it doesn't have `vaultSecretBackend`). - Or `helm template` is run using the other values.yaml files which doesn't have `operator.vaultSecretBackend`. This is less likely because this could have caused consistent failure in CI. One option that I considered to fix this is explicitly passing just the main values.yaml file to the `ct lint` command, using `--helm-extra-args` flag, but that didn't resolve the issues. I was able to reproduce it once if I ran 15 manual patches. The other option was to have the `vaultSecretBackend` field in the other values files as well. And this is what I have done in this PR. I am not really sure if this actually fixed the problem but I was not able to reproduce it in 20 manual patches. The other small change that this PR does is, running `helm template` before running `ct lint` so that if the test fails ever again we can check and see if `vaultSecretBackend` is eventually generated in the template. ## Proof of Work Output of successful run of `make precommit`: https://gist.github.com/viveksinghggits/45a6f80f2b5b85d26d7d21dcc3dfb56c Output of failed run of `make precommit`: https://gist.github.com/viveksinghggits/7bb5a35e8bfe3a9be93e668ee8e734b9 Ran 20 manual evg patches and all of them are successful. <img width="1451" height="1178" alt="image" src="https://github.com/user-attachments/assets/39a5f46a-8ade-44ad-aff3-425bc5891e60" /> ## Checklist - [x] Have you linked a jira ticket and/or is the ticket in the title? - [x] Have you checked whether your jira ticket required DOCSP changes? - [x] 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 b3ea899 commit 3ec0ca1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

.githooks/pre-commit

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,19 @@ pre_commit() {
226226
run_job_in_background "python_formatting"
227227
run_job_in_background "check_erroneous_kubebuilder_annotations"
228228
run_job_in_background "validate_snippets"
229-
run_job_in_background "lint_helm_chart"
230229

231230
if wait_for_all_background_jobs; then
232-
echo -e "${GREEN}pre-commit: All checks passed!${NO_COLOR}"
233-
return 0
231+
# lint_helm_chart must be run after all the background jobs are finished because one of the BG jobs (update_jobs)
232+
# updates the helm chart. And lint_helm_chart requires the helm chart to be updated already.
233+
lint_helm_chart
234+
235+
local lint_helm_chart_status=$?
236+
if [ "$lint_helm_chart_status" -eq 0 ]; then
237+
echo -e "${GREEN}pre-commit: All checks passed!${NO_COLOR}"
238+
return 0
239+
else
240+
return 1
241+
fi
234242
else
235243
return 1
236244
fi

0 commit comments

Comments
 (0)