Skip to content

feat: add autoGomemlimit field to the Alertmanager CRD - #8978

Merged
simonpasquier merged 8 commits into
prometheus-operator:mainfrom
kubeservice-stack:change-auto-gomemlimit
Nov 20, 2026
Merged

simonpasquier merged 8 commits into
prometheus-operator:mainfrom
kubeservice-stack:change-auto-gomemlimit

Conversation

@dongjiang1989

@dongjiang1989 dongjiang1989 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Description

Alertmanager v0.35.0 promoted the auto-gomemlimit feature flag to a regular --auto-gomemlimit flag and added --auto-gomemlimit.refresh-interval (prometheus/alertmanager#5464).

This adds an autoGomemlimit field to the Alertmanager CRD so these flags can be configured directly:

spec:
  autoGomemlimit:
    enabled: true
    ratio: 0.7
    refreshInterval: 5m

The arguments are only added when enabled is true and the Alertmanager version is >= v0.35.0. ratio is a resource.Quantity, kept in the (0, 1] range by a CEL validation rule.

Need merge #8977 frist

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

Unit tests in pkg/alertmanager cover argument generation and version gating. Added an e2e test that deploys Alertmanager v0.35.0 and checks the StatefulSet arguments. make check-golang and make check-api pass.

Changelog entry

Add autoGomemlimit field to the Alertmanager CRD to configure the --auto-gomemlimit command-line flags. It requires Alertmanager >= v0.35.0.

Add a new `autoGomemlimit` field to the Alertmanager CRD to configure
the `--auto-gomemlimit`, `--auto-gomemlimit.ratio` and
`--auto-gomemlimit.refresh-interval` command-line flags promoted in
alertmanager#5464. The flags are only passed when `enabled` is true
and the Alertmanager version is >= v0.35.0.

The `ratio` field is a resource.Quantity validated by a CEL rule to be
greater than 0 and less than or equal to 1.

Signed-off-by: dongjiang1989 <[email protected]>
@dongjiang1989
dongjiang1989 requested a review from a team as a code owner November 11, 2026 11:53
dongjiang1989 and others added 5 commits November 11, 2026 20:09
Signed-off-by: dongjiang1989 <[email protected]>
Signed-off-by: dongjiang1989 <[email protected]>
Alertmanager parses its flags with kingpin which rejects
`--auto-gomemlimit=true` for boolean flags ("unexpected true"), so the
container would fail to start. Render the flag without a value instead.

Signed-off-by: dongjiang1989 <[email protected]>
The API server returns resource.Quantity values in canonical form, so a
ratio of 0.7 comes back as 700m and was rendered as
`--auto-gomemlimit.ratio=0.700`. Normalize the value to the shortest
decimal representation instead.

Signed-off-by: dongjiang1989 <[email protected]>
@dongjiang1989

Copy link
Copy Markdown
Member Author

cc @simonpasquier @slashpai PTAL

Comment thread test/e2e/alertmanager_test.go Resolved
Comment thread pkg/alertmanager/statefulset.go Resolved
* Pass --no-auto-gomemlimit when the enabled field is explicitly false.
* Use the GoDuration type for refreshInterval since the Alertmanager flag
  is parsed with time.ParseDuration().
* Make the e2e test verify the behavior via the Alertmanager container
  logs instead of the StatefulSet arguments.
* Move the Alertmanager version requirement to the struct documentation
  and simplify the field comments.

Signed-off-by: dongjiang1989 <[email protected]>
@dongjiang1989

Copy link
Copy Markdown
Member Author

Thx @simonpasquier Please re-check it

Comment thread test/e2e/alertmanager_test.go Resolved
Comment thread test/e2e/alertmanager_test.go Resolved
Don't assert on the Alertmanager log message since it comes from a
third-party library and the instance being ready already proves that
the flags are accepted. Don't pin the Alertmanager version so that the
test catches upstream breaking changes, and set a memory limit instead
so that the limit is detected from the cgroup.

Signed-off-by: dongjiang1989 <[email protected]>
@dongjiang1989

Copy link
Copy Markdown
Member Author

@simonpasquier Update e2e case done
Please re-check it

@simonpasquier
simonpasquier merged commit 7ae00f1 into prometheus-operator:main Nov 20, 2026
23 checks passed
nutmos added a commit to nutmos/prometheus-operator that referenced this pull request Nov 21, 2026
prometheus-operator#8978 added AutoGomemlimitSpecApplyConfiguration with files generated
by an older Go toolchain. Since the toolchain bump to Go 1.27, gofmt
keeps a trailing '//' line on field doc comments, so 'make generate'
produces a diff on main and fails the generated-files check for every
PR that rebases on it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JV7hff1NwMsAdWCKyJixNp
Signed-off-by: Nattapong Ekudomsuk <[email protected]>
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.

2 participants