Skip to content

Feat/silence crd proposal - #8872

Open
coffeegoesincodecomesout wants to merge 36 commits into
prometheus-operator:mainfrom
coffeegoesincodecomesout:feat/silence-crd-proposal
Open

coffeegoesincodecomesout wants to merge 36 commits into
prometheus-operator:mainfrom
coffeegoesincodecomesout:feat/silence-crd-proposal

Conversation

@coffeegoesincodecomesout

@coffeegoesincodecomesout coffeegoesincodecomesout commented Oct 8, 2026 •

Copy link
Copy Markdown

Description

Proposes a Silence CRD for prometheus-operator, so that Alertmanager silences can be managed as Kubernetes resources.

This supersedes #7798 and builds on #5485 and the API review in
#7806. Both earlier authors are credited in the proposal header.

Myself @danielmellado and @simonpasquier have had an initial discussion around this PR after I raised concerns about the drift detection section. specifically with regards to:

"the UUID recorded in .status.bindings[].silenceID is always the one the POST returned, never the one it sent"

which caused me to question if UUID is the correct field to anchor everything around. Daniel suggested falling back to comment or createdby, Simon suggested adding a goal of preventing comment and createdby being updated via the UI, or to follow the pattern of other objects and write status out to a file and read it in with a sidecar - removing the constraints around reusing configResourceCondition

We resolved to carry on the conversation here on the PR

No Closes: line: a design document does not close the feature requests, so the related issues are listed instead.

Related: #5452, #2398, #5836

Type of change

  • CHANGE (fix or feature that would cause existing functionality to not work as expected)
  • FEATURE (non-breaking change which adds functionality)
  • BUGFIX (non-breaking change which fixes an issue)
  • ENHANCEMENT (non-breaking change which improves existing functionality)
  • NONE (if none of the other choices apply. Example, tooling, build system, CI, docs, etc.)

Verification

Documentation only — one file added, no code changes. mdox formatting and the docs link check pass.

AI use disclosure

Per the project's AI use policy: this proposal was drafted with assistance from Claude (Anthropic) for codebase exploration, review of the earlier proposals and their comment threads, and prose drafting. I have
reviewed every section and can speak to the reasoning behind each design decision.

Changelog entry

NONE

@coffeegoesincodecomesout
coffeegoesincodecomesout requested a review from a team as a code owner October 8, 2026 17:45
@coffeegoesincodecomesout
coffeegoesincodecomesout marked this pull request as draft October 8, 2026 19:21
@coffeegoesincodecomesout
coffeegoesincodecomesout force-pushed the feat/silence-crd-proposal branch 2 times, most recently from b077aad to 1815dec Compare October 9, 2026 15:43
Proposes a Silence custom resource for prometheus-operator, so that
Alertmanager silences can be managed declaratively through the
Kubernetes API rather than only through the Alertmanager UI or REST API.

Supersedes the proposal in prometheus-operator#7798, and builds on the original in prometheus-operator#5485
and the API review in prometheus-operator#7806. The status subresource follows the accepted
configuration-resource convention, with the Alertmanager-assigned UUID
as its one addition: the silence API is not declarative, so the handle
it returns on creation is the only way to address a silence later, and
it cannot be re-derived.

Adds amtool and the two author handles to the spell-check dictionary,
following the existing convention for contributor names.

Related: prometheus-operator#5452, prometheus-operator#2398, prometheus-operator#5836

Co-authored-by: Mohamed Chiheb Ben Jemaa <[email protected]>
Co-authored-by: Daniel Mellado <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Signed-off-by: Nigel Smith <[email protected]>
The proposal was 5912 words, roughly 3x implemented/202411-zone-aware-sharding.md
(1965) — the longest comparable feature proposal in the repo — and 4x the
median. The excess was prose rather than substance: 3099 words of it against
zone-aware's 1337, where that proposal carries its weight in YAML and
pseudocode instead.

Reduce it to 4249 words, following the house style in zone-aware-sharding:

- Alternatives log decisions rather than arguing them down. Each of the five
  keeps its conclusion and its reason; the enumerated rebuttals go.
- Drop the Identity Tracking section. Every claim it made was already stated
  earlier: that the UUID in .status.bindings[].silenceID is the sole identity
  anchor, that it is written on creation and read on subsequent reconciles,
  and that identity is deliberately not encoded into comment or createdBy.
- Drop the prometheus-operator#8577 status archaeology from Authentication, which would be stale
  within months, keeping the three commitments and the CA handling.
- Reduce the SilenceMatcher justification from four paragraphs to one: the
  deprecated regex field on v1alpha1.Matcher is the whole reason.
- Turn the pitfalls list and the endpoint caveats into bullets.
- Remove hedging ("worth flagging", "worth stating precisely") and the
  paragraph justifying which metrics are not exposed.

Every table, code block, condition reason and decision is retained, and no
design choice changes.

Also reorder the action plan to put the feature gate first, as
zone-aware-sharding does, so each later step can merge incrementally without
being live for users. This splits the old combined item: the gate is a
standalone feature_gates.go entry that nothing reads yet, while the startup
pre-flight checks the CRD and the ClusterRole verbs and so has to follow both.

Co-Authored-By: Claude Opus 5 <[email protected]>
Signed-off-by: Nigel Smith <[email protected]>
…nippet

The excerpt had the if statement dedented to column zero but left its
body at one tab, so the two lines sat at inconsistent levels.

Quote SelectNamespacesFromCache verbatim instead, at its original
indentation and with the comment that states the convention the
surrounding paragraph describes. This matches both the source at
pkg/operator/operator.go:593 and the way accepted/202405-agent-daemonset.md
pastes Go excerpts.

Co-Authored-By: Claude Opus 5 <[email protected]>
Signed-off-by: Nigel Smith <[email protected]>
The previous commit quoted SelectNamespacesFromCache at its original
indentation inside the function, which left the whole excerpt indented
one level with no enclosing function visible.

Both proposals that embed Go start the snippet at column zero regardless
of where it sits in the source: accepted/202405-agent-daemonset.md opens
with an unindented if and a tab-indented body, and
implemented/202411-zone-aware-sharding.md does the same with spaces.
Follow agent-daemonset, which quotes real Go rather than pseudocode.

Co-Authored-By: Claude Opus 5 <[email protected]>
Signed-off-by: Nigel Smith <[email protected]>
The Drift Detection section claimed that re-posting a silence with its
existing ID always updates in place, preserving the UUID. Alertmanager
only does that when the change cannot alter the historic view of
silencing: canUpdate requires the matchers to be unchanged and the
silence to be active or pending. Otherwise Set expires the existing
silence and stores the replacement under a fresh UUID. Behaviour is
unchanged since alertmanager#796 (2017).

Describe what Alertmanager actually does, and state the rule the
controller needs as a consequence: the UUID recorded in
.status.bindings[].silenceID is always the one the POST returned, never
the one it sent. Treating the sent ID as authoritative would leave the
binding tracking an expired silence, with every later resync minting
another replacement.

Also note two comparisons that are write loops in their obvious form.
A past startsAt is clamped to the time Alertmanager accepted the
silence and then frozen, so comparing it against the declared value
reports drift forever once the silence is active -- and startsAt
defaults to the resource's creation timestamp, so this is the default
path, not an edge case. Matchers are compared as an ordered list, so
the injected namespace matcher needs a stable position.

Split the drift-correction e2e bullet by outcome, since it asserted the
same-silenceID behaviour for modifications that do not preserve it, and
add a reconcile-stability test covering the startsAt loop.

Co-Authored-By: Claude Opus 5 <[email protected]>
Move the --controller-id subsection to sit under Alertmanager API
Translation, which is a more natural home given it affects how the
controller addresses Alertmanager resources.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Restore tab indent in Go snippet and remove trailing blank line,
both flagged by the docs formatter in CI.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@coffeegoesincodecomesout
coffeegoesincodecomesout marked this pull request as ready for review October 21, 2026 18:04
@simonpasquier
simonpasquier self-requested a review October 22, 2026 09:38

@simonpasquier simonpasquier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About tracking which silences are managed by the operator and their IDs:

  • I'd recommend using annotations (prometheus/alertmanager#4965) to encode information which is useful for the operator to reconcile the state (e.g. Silence resource UUID). I'm fine with the feature being dependent on a recent version of Alertmanager (>= 0.32.0).
  • Whatever reconciles the silences in Alertmanager can look up the annotation to determine if a given silence exists and if it matches the spec.
  • Users tampering the annotation are on their own. But we can have an option in Alertmanager telling the operator to delete silences without the annotation or without a matching UUID (orphaned silences).
  • If we do this, I'm not sure that we need to surface the silence ID in the status.

2. Resolves target Alertmanager resources via `silenceSelector` / `silenceNamespaceSelector`.
3. For each target Alertmanager resource:
- Looks up the existing silence by `.status.bindings[].silenceID` if present.
- Creates or updates the silence via Alertmanager REST API v2.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO this is still to be decided. I've always been concerned that the controller performs synchronous API calls to a remote service (other than Kube API of course). We've discussed offline but I'd be interested to explore a design where the controller reconciles the silence resources into a Secret then processed locally by each Alertmanager pod (similar to the config-reloader sidecar).

The downside with this approach is the time it takes for the updated secret to propagate but we could also consider the sidecar watching the secret for immediate action (though it would involve additional RBAC for the Alertmanager SA , we don't want the operator to handle this and it would be the responsibility of the user deploying Alertmanager to grant the proper permissions).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated proposal submitted, using annotations and a sidecar, it does resolve my previous concerns but does throw up a thought about scale: 1MB secret, limiting comment so a user could not write war and peace into the field would still mean json for single silence being 400-800 bytes - that's 1000-2500 silences per secret... which should be enough for most.. but watching the secret might be better at scale when more immediate action might be required - noted in the updated alternatives section.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can still gzip the payload which would buy us some slack. Another option is to split the data across multiple secrets (like we do for prometheus rules).

…itecture

Incorporate Simon's review direction from PR prometheus-operator#8872:

- Architecture pivot: replace direct operator→Alertmanager REST calls with
  a Secret-backed sidecar pattern analogous to config-reloader. The operator
  reconciles Silence CRs into per-Alertmanager Secrets; a new silence-sidecar
  on each Alertmanager pod reads the Secret and applies changes via the local
  AM API.

- Identity tracking: use Alertmanager silence annotations
  (monitoring.coreos.com/silence-uid) introduced in prometheus/alertmanager#4965
  instead of .status.bindings[].silenceID. Requires Alertmanager >= 0.32.0.

- Remove silenceID from .status bindings; status now reflects Secret-write
  success rather than AM API outcomes.

- No finalizers: the sidecar handles orphan cleanup via the annotation UID
  orphan pass; the operator simply removes entries from the Secret on deletion.

- Remove controller-id section: --controller-id is a workload-resource
  concept and does not apply to Silence resources.

- Add missing namespace isolation modes: OnNamespaceExceptForAlertmanagerNamespace
  and None, alongside the existing OnNamespace default.

- Observability: note that sidecar convergence failures require sidecar-side
  instrumentation and alerting; the operator's metrics cover only Secret writes.

- Clustered Alertmanager: sidecar-per-pod model reconciles each replica
  independently, which is robust to gossip replication failures.

- Failure handling table updated to reflect Secret-write failures (operator)
  vs AM API failures (sidecar).

- Alternatives: add sections documenting the rejected direct-API and
  silenceID-in-status approaches and why the sidecar/annotation design
  was chosen.

- Action plan restructured: tests inline per task (not a separate item);
  reconciler split into Secret-write and namespace-injection tasks; sidecar
  binary and StatefulSet wiring added as explicit tasks; Alertmanager
  version pre-flight added.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…posal

Address feedback from first review of the updated proposal:

- Fix self-contradicting framing: replace "unlike other configuration
  resources" with a description that positions Silence as consistent with
  the existing Secret + sidecar pattern used by config-reloader. Call out
  the one real distinction: config-reloader triggers a passive file reload
  whereas the silence-sidecar makes active CRUD API calls to Alertmanager.

- Rewrite the Authentication section: sidecar calls localhost:9093 (no
  network auth in the default case); if spec.web.httpConfig auth is set,
  the operator injects credentials into the sidecar container; Kubernetes
  Secret-read RBAC is added to the existing Alertmanager service account
  by the operator when the gate is enabled — no user action required.

- Add Secret capacity note in the Secret Format section: 1 MiB limit
  supports ~1,000–2,500 silences at typical entry sizes; field-length
  limits protect the budget; sharding is the mitigation path if needed.

- Add MaxLength column to the spec fields table: comment and
  matchers[].value capped at 1024 chars, createdBy and matchers[].name
  at 256 chars — enforced at admission via CRD schema validation.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…hitecture

The auth goal and Authentication section were inconsistent with the sidecar
design: the goal referenced "a single integration point" without clarifying
what that meant, and the section didn't explain how 401/403 failures would
be surfaced given the operator no longer calls the Alertmanager API directly.

Goals section: replace the vague "single integration point" goal with a
precise statement — credentials belong to the Alertmanager resource
(spec.web.httpConfig), not individual Silence CRs; auth failures (401/403)
must be distinguishable from connectivity failures in sidecar metrics.

Authentication section: add two explicit commitments —
- Credentials live on the Alertmanager resource, not per-Silence CRs, so
  credential surface area scales with Alertmanager instances rather than
  Silence count.
- The sidecar must classify API failures: 401/403 exposed as a distinct
  metric label/reason so operators can distinguish a credential problem
  from a connectivity problem.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…er Simon

Previous commit incorrectly stated that the operator manages the Alertmanager
service account's RBAC for reading the silence Secret. Simon's review comment
explicitly states: "we don't want the operator to handle this and it would be
the responsibility of the user deploying Alertmanager to grant the proper
permissions."

Revert to Simon's position: the sidecar needs get (and optionally watch for
immediate Secret-change reconciliation) on the silence Secret; granting these
permissions to the Alertmanager SA is the user's deployment responsibility.
The operator injects the sidecar container but does not take ownership of the
Alertmanager SA's permissions.

The operator's own RBAC (writing the Secret from the operator SA) is
unaffected — that remains operator-managed and is shown in the Feature Gate
table.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
The Feature Gate section previously said the startup pre-flight should
verify the Alertmanager version "where discoverable." Since prometheus-
operator manages the Alertmanager StatefulSet and always knows the version
(from spec.image or its built-in default), the "where discoverable" caveat
was misleading.

The version check is not a startup concern — at startup there are no
specific Alertmanager instances to check. It belongs in the per-Alertmanager
reconcile loop where the version is determined from spec.image or the
operator default, and the binding condition AlertmanagerVersionTooOld is set
if the version is below 0.32.0.

Update the Feature Gate section to explain this and reference the
compatibility matrix as the canonical home for the >= 0.32.0 requirement.

Split the action plan preflight item into two:
- Startup pre-flight: CRD presence + operator SA RBAC (global, static)
- Per-AM version check: reconcile loop, per-Alertmanager, with binding
  condition on failure and compatibility matrix update

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
The sidecar does not need to call the Kubernetes API to read the silence
Secret. The operator already manages the Alertmanager StatefulSet and can
mount the silence Secret as a volume (the same pattern used for the
generated config Secret in makeStatefulSetSpec). The sidecar then watches
the mounted file at /etc/alertmanager/silences/silences.json; the kubelet
handles propagation when the operator updates the Secret.

This eliminates the Alertmanager SA RBAC concern entirely: the kubelet
reads the Secret on behalf of the pod without requiring the pod's service
account to have get/watch on Secrets. The k8s API watch path remains
available as an opt-in for deployments that need immediate propagation,
with the user responsible for granting the watch permission.

Update the controller diagram and the Authentication section accordingly.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Adds a ### silence-sidecar section covering deployment (operator-injected
StatefulSet container, like config-reloader), configuration flags
(--silence-file, --alertmanager-url, --web.listen-address), the reconcile
loop (file-watch trigger + orphan pass), observability metrics
(silence_sidecar_reconcile_total, silence_sidecar_sync_errors_total with
reason labels, silence_sidecar_last_sync_timestamp_seconds), and shipping
strategy.

The section is positioned between Failure handling and Drift Detection,
giving the sidecar first-class presence in the proposal rather than
appearing only in passing references.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Alertmanager normalises startsAt to now() when a silence is posted with
a start time in the past (the common case). The sidecar must not compare
startsAt when deciding whether to update, or it triggers a spurious
update on every reconcile. Document this under API Translation so the
implementation constraint is captured in the proposal.

Validated during prototype lab testing on feat/silence-crd-implementation.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- Rewrite the auth goal: credentials belong to the Alertmanager resource
  not individual Silence CRs; 401/403 must be a distinct metric from
  connectivity failures.
- Clarify that the operator does a full Secret rebuild from the informer
  cache per reconcile (not a read-modify-write), and explain why: avoids
  concurrent-write races when two Silence CRs target the same Alertmanager.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…ection

The numbered create/update/orphan list in Drift Detection was a full
repeat of the silence-sidecar Reconcile loop section. Replace it with
a cross-reference; keep the unique content: annotation format, coexistence
guarantee, tampering note, UUID replacement, and expiry two-phase behaviour.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…tives

At 10,000+ namespaces the single-Secret-per-AM ceiling is a real
constraint. Document two sharding approaches (per-namespace and
index-based), explain why both are deferred (StatefulSet restart on
shard addition, RBAC trade-off on the API-watch alternative), and note
that the sidecar's directory-merge design is compatible with either
without changing its reconcile contract.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
AM exposes --silences.max-silences (default: no limit) and
--silences.max-silence-size-bytes (default: no limit). The operator has
no visibility into these settings; rejection surfaces via the sidecar as
reason="rejected". Note that max-silences counts expired silences until
the retention window clears them.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Good to know, but too much detail for a design proposal.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…ernative

10,000 is the tested maximum, not a routine figure. Adjust wording
accordingly.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@pull-request-size pull-request-size Bot added size/XL and removed size/L labels Nov 2, 2026
Replace British spellings (normalisation, normalises, behaviours,
synchronised) with US equivalents, and rephrase auth-distinguishability
to auth-classification to avoid the unknown word.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Add missing blank line before heading, normalise table column widths,
and replace pipe characters inside table cells with prose equivalents
to avoid the markdown formatter splitting cells at escaped pipes.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Widen the Labels separator column to match the longest cell content
and pad all cells consistently so the formatter accepts the table.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
1. Remove informer resync claim - informer resyncs don't trigger
   reconciliation in prometheus-operator controllers.

2. Add generation field to Secret entries - prevents stale writes when
   multiple sidecars race in clustered Alertmanager. Sidecar checks
   generation before updating to avoid overwriting with outdated content.

3. Remove result label from silence_sidecar_reconcile_total - error
   ratio is computable from sync_errors_total without needing a label.

4. Update e2e test description - focus on user-visible artifacts
   (silence presence in AM) rather than implementation details (Secret
   content).

5. Remove AlertmanagerNotAddressable failure case - sidecar runs in the
   same pod as Alertmanager and can always reach localhost:9093
   regardless of spec.listenLocal setting. This was a leftover from the
   old direct-API design.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Address Simon's question about distributing silences across Alertmanager
pods rather than having all sidecars reconcile all silences. Document
why the brute-force approach was chosen:

- Distribution requires gossip to work (fallback adds complexity)
- Pod churn requires reassignment coordination
- Generation tracking makes brute-force safe
- Redundant API calls are cheap vs distributed ownership complexity

The current design leans into Alertmanager's concurrent-write model
rather than working around it.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
After writing the silence Secret, the operator updates a pod annotation
to trigger kubelet reconciliation and force immediate Secret remount.
This avoids the ~1 minute default sync period delay without requiring
the sidecar to watch the k8s API (which would need RBAC).

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
The reconcile loop involves many Kubernetes component interactions
(informers, selectors, API writes, status updates) and should be tested
at the e2e/integration level, not as unit tests. Unit tests cover only
the pure helper functions (matcher injection, timing resolution, JSON
serialization).

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…eus-operator

Resolve conflict in cspell.json by combining word additions from both
branches: our additions (amtool, coffeegoesincodecomesout, mcbenjemaa)
and upstream addition (distroless).
Empty commit to force GitHub to re-evaluate merge conflicts after
resolving cspell.json conflict with upstream main.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Narrow the reason column after removing AlertmanagerNotAddressable -
the remaining values are shorter so the formatter wants less padding.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Two changes to align with the immediate propagation via pod nudge
mechanism:

1. Alternatives section (line 445): Update generation tracking rationale
   to reflect that pod nudge delivers synchronized propagation, not
   skewed. Generation tracking now protects against edge cases (pod
   restarts, brief watch lag) rather than routine propagation delays.

2. Action Plan (line 523): Add pod annotation update responsibility to
   SilenceReconciler task - after writing the Secret, the reconciler
   must update pod annotations to trigger immediate kubelet remount.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@wpessers

Copy link
Copy Markdown

Hi, trying to see if I can help move this along. I've looked through the CRD thoroughly and got some findings that may help ease some of the review load. But let me know if I'm overstepping here, or if there's anything else that I can do to help get this moving again.

| `resource` | Resource type of the bound workload (`alertmanagers`) |
| `name` | Name of the Alertmanager resource |
| `namespace` | Namespace of the Alertmanager resource |
| `lastSyncTime` | When the operator last successfully wrote the Secret for this AM |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it stands today, WorkloadBinding has no lastSyncTime. only group, resource, name, namespace and conditions. See:

type WorkloadBinding struct {
// group defines the group of the referenced resource.
// +kubebuilder:validation:Enum=monitoring.coreos.com
// +required
Group string `json:"group"`
// resource defines the type of resource being referenced (e.g. Prometheus, PrometheusAgent, ThanosRuler or Alertmanager).
// +kubebuilder:validation:Enum=prometheuses;prometheusagents;thanosrulers;alertmanagers
// +required
Resource string `json:"resource"`
// name defines the name of the referenced object.
// +kubebuilder:validation:MinLength=1
// +required
Name string `json:"name"`
// namespace defines the namespace of the referenced object.
// +kubebuilder:validation:MinLength=1
// +required
Namespace string `json:"namespace"`
// conditions defines the current state of the configuration resource when bound to the referenced Workload object.
// +listType=map
// +listMapKey=type
// +optional
Conditions []ConfigResourceCondition `json:"conditions,omitempty"`
}

Is the plan to add it to the shared type (so ServiceMonitor, PodMonitor,... also get it) or to a Silence-specific binding?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wpessers Thanking you for the review. I have address two of the three issue you raised. I think this one needs some further thought and discussion.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! And I had a thought about this issue, just wondering if we really need lastSyncTime... The Accepted condition already has the observedGeneration field. So by that you can already tell if the current version was written. If that's enough, we could drop lastSyncTime and that would mean WorkloadBinding can just be reused as-is.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was feeling indecisive as to whether that was enough....
I was thinking lastSyncTime provides the means to confirm a sync without a modification...
but ill remove lastSyncTime

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to argue though, or we can wait for actual maintainers to chime in. I'm just a mere guy with an opinion and an interest in moving the proposal forward 😄

Comment on lines +275 to +276
- If **absent**: create a new silence, setting the annotation to the entry's `uid` and storing the entry's `generation` in the silence's comment metadata.
- If **present but different**: check the generation. If the AM silence was created from a newer generation than the file entry, skip the update (stale Secret content). Otherwise, update the silence.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 2 bullet points are contradicting other parts of the proposal.

The first states generation goes into the silence's comment, but earlier the proposal says comment is "passed through verbatim": L118

The second says generation has to be checked, to it needs to read it back from the comment (?) But then down below, L461 says the comment is never read back.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing line 118 - generation is not to be stored in the comment. generation is to be stored in the secret JSON and in a second annotation on the silence object.

Address two technical inconsistencies identified by wpessers in PR prometheus-operator#8872:

Issue 2 (Generation metadata contradiction):
- Clarify that generation is stored as AM annotation, not in comment
- Document both monitoring.coreos.com/silence-uid and
  monitoring.coreos.com/silence-generation annotations
- Explain stale-write detection mechanism using generation annotation

Issue 3 (Resync behavior):
- Remove misleading "ordinary resync" language
- Explicitly state reconciliation is triggered by resource changes
  or controller restart, not by informer periodic resync
- Change "recovers" to "eventually recovers" for accuracy

Issue 1 (lastSyncTime field) is pending design decision discussion
with maintainers.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Address wpessers' third review comment on PR prometheus-operator#8872 by removing the
lastSyncTime field from the status binding specification.

wpessers pointed out that the existing observedGeneration field in
ConfigResourceCondition already provides the necessary information
to determine if the latest version of a Silence has been processed.
Comparing .metadata.generation to .status.conditions[].observedGeneration
tells you whether the current spec has been applied.

Benefits of using observedGeneration instead of adding lastSyncTime:
- No API changes needed - WorkloadBinding can be reused as-is
- Maintains consistency with ServiceMonitor, PodMonitor, PrometheusRule,
  ScrapeConfig, and AlertmanagerConfig
- Aligns with declarative system principles - version tracking is more
  meaningful than timestamp tracking for detecting staleness
- Simplifies the proposal

In declarative systems, the key question is "has the latest version
been processed?" not "when did we last sync?". The observedGeneration
field answers this directly.

Removed:
- Line 87: lastSyncTime from status example
- Line 128: lastSyncTime from status fields table

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Run mdox formatter to fix table column width alignment.
No content changes, only formatting adjustment.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants