Fix blackbox exporter Probe reconciliation flapping#4025
Conversation
The odf-blackbox-exporter Probe is continuously updated every reconcile
cycle because controllerutil.CreateOrUpdate detects a perpetual diff
between the desired state and the server-returned state.
Two CRD-defaulted fields cause the drift:
1. ProberSpec.Path: the Probe CRD defaults this to "/probe", but the
code never sets it. Each reconcile overwrites the server-returned
"/probe" with the zero value "", triggering an Update that the API
server re-defaults.
2. bearerTokenSecret: the API server materializes an empty
{key: "", name: ""} via CRD structural schema defaults for
SecretKeySelector. The desired spec has this field nil, creating a
constant diff. prometheus-operator then rejects the Probe with
"resource name may not be empty".
Fix by explicitly setting Path to "/probe" in the desired spec and
preserving the server-returned bearerTokenSecret in the mutate function
when the desired spec does not set one.
Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ygalblum The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @ygalblum. Thanks for your PR. I'm waiting for a red-hat-storage member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Summary
The
odf-blackbox-exporterProbe is continuously updated every reconcilecycle (generation 11550+ in ~48h) because
controllerutil.CreateOrUpdatedetects a perpetual diff between the desired state and the server-returned
state. Two CRD-defaulted fields cause the drift:
ProberSpec.Path: the Probe CRD defaults this to"/probe", butthe code never sets it. Each reconcile overwrites
"/probe"with"",triggering an Update that the API server re-defaults.
bearerTokenSecret: the API server materializes an empty{key: "", name: ""}via CRD structural schema defaults forSecretKeySelector. The desired spec has this field nil, creating aconstant diff. prometheus-operator then rejects the Probe with
"resource name may not be empty".Changes
ProberSpec.Path: "/probe"in the desired Probe spec tomatch the CRD default, eliminating the Path drift.
bearerTokenSecretin the mutate functionwhen the desired spec does not set one, preventing the nil-vs-empty diff
from triggering an Update.
Test plan
go build ./...— compilesgo test ./internal/controller/storagecluster/... -run TestCreateBlackboxProbe— passesgo vet ./...— no issuesProbe generation counter stabilizes (no longer climbs every reconcile)
"resource name may not be empty"for the Probe