flux diff kustomization keeps running after reporting an error
Describe the bug
The diff worker keeps going after sending an error on errChan. It prints the output and tries to send again, but the caller only receives once. So we can end up writing output after the command returns, then blocking on a send nobody will receive.
Steps to reproduce
On dede56a8fdcd1e0edca28630a979a51415bb56f8, with the test prerequisites installed:
GOTOOLCHAIN=go1.27.1 make test \
TEST_ARGS='-run ^TestDiffKustomizationNewNamespaceAndConfigmap -race -count=3'This can report a race between executeCommand() reading the output buffer and the worker writing to it.
It doesn't necessarily trigger on every run. The ConfigMap error itself is expected, but continuing after reporting it isn't.
Expected behavior
Print the partial diff before returning the original error, then stop the worker.
I've moved cmd.Print(output) before the error handling and added a return after the send in this PR.
Screenshots and recordings
No response
OS / Distro
Ubuntu 26.04.1 LTS on WSL2, Go 1.27.1.
Flux version
N/A - source checkout at dede56a8fdcd1e0edca28630a979a51415bb56f8.
Flux check
N/A - reproduced with envtest, without a Flux installation.
Git provider
No response
Container Registry provider
No response
Additional context
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Source: fluxcd/flux2