Skip to content

feat(agent): enable service.profilesSupport feature gate by default - #2274

Open
royrajan13 wants to merge 1 commit into
aws:mainfrom
royrajan13:feat/enable-profiles-support-gate
Open

feat(agent): enable service.profilesSupport feature gate by default#2274
royrajan13 wants to merge 1 commit into
aws:mainfrom
royrajan13:feat/enable-profiles-support-gate

Conversation

@royrajan13

Copy link
Copy Markdown

Description of the issue

Issue: #2273

Configuring a profiles pipeline makes the agent fail to start, because the
collector's profiles signal is gated behind service.profilesSupport (alpha, off
by default in collector v0.124.0):

pipeline "profiles": profiling signal support is at alpha level, gated under the "service.profilesSupport" feature gate

The agent builds the collector's arguments itself and only ever passes
--config=, so an operator has no supported way to enable the gate.

Description of changes

The agent now appends --feature-gates=+service.profilesSupport to the arguments
it builds for the collector command, so profiles pipelines start without the
operator needing to know the gate exists.

The flag is only appended after checking the collector's feature-gate registry
for an enableable gate with that ID. featuregate.Registry.Set returns an error
for an unknown gate ID, which surfaces as a flag-parse failure and a fatal
startup error. Without the guard, the moment the gate graduates and is deleted
upstream, a routine collector dependency bump would produce an agent that
refuses to start. With it, graduation is a no-op.

The guard also treats StageDeprecated as not enableable, because Set rejects
enabling a deprecated gate with the same class of error, and deprecated is the
pre-deletion state of a graduating gate. A StageStable gate that is still
registered remains enableable, so the flag keeps being passed until the gate is
removed from the registry entirely.

New file cmd/amazon-cloudwatch-agent/featuregates.go holds
collectorFeatureGateArgs and the registry check. amazon-cloudwatch-agent.go
gains one line at the existing cmd.SetArgs site. featuregate moves from the
indirect to the direct require block in go.mod (no version change).

License

By submitting this pull request, I confirm that you can use, modify, copy, and
redistribute this contribution, under the terms of your choice.

Tests

New unit tests in cmd/amazon-cloudwatch-agent/featuregates_test.go cover all
four registry states: gate registered at alpha (flag passed), gate at stable
(flag still passed), gate absent (no flag, no error), and gate deprecated (no
flag, no error).

Rather than string-comparing the produced arguments, each case parses them
through a real featuregate registry flag set, and a separate test asserts the
gate actually flips to enabled -- so the tests validate the flag name and +
syntax against the library rather than against a hardcoded expectation.

  • go build ./... -- pass
  • go test ./cmd/amazon-cloudwatch-agent/ -- pass (whole package)
  • make fmt -- pass, no changes
  • make fmt-sh -- pass, no changes

Requirements

  1. make fmt and make fmt-sh -- run, both clean
  2. make lint -- run; it reports pre-existing repo-wide findings and exits
    non-zero on unmodified main as well. None of the findings are in the new
    file, and none are on either line added to amazon-cloudwatch-agent.go.

Profiles pipelines are gated behind the collector's alpha
service.profilesSupport feature gate, so a profiles pipeline currently fails
agent startup outright:

    pipeline "profiles": profiling signal support is at alpha level, gated
    under the "service.profilesSupport" feature gate

The agent builds the collector's argv itself and only passes --config, so an
operator has no supported way to enable the gate. It now requests the gate
when building those args, which is what makes profiles usable out of the box.

The request is guarded by a lookup in the collector's feature gate registry.
featuregate.Registry.Set rejects an unknown gate ID (and rejects enabling a
deprecated one), and that error surfaces as a cobra flag parse failure, i.e.
a fatal startup error. Since this gate is on a graduation path and will
eventually be deleted upstream, passing it unconditionally would turn a
routine collector dependency bump into an agent that refuses to start.
Consulting the registry first makes graduation a no-op instead.

Key files:
- cmd/amazon-cloudwatch-agent/featuregates.go: collectorFeatureGateArgs
  builds the --feature-gates arg, skipping any gate the registry cannot
  enable.
- cmd/amazon-cloudwatch-agent/amazon-cloudwatch-agent.go: appends those args
  alongside the existing --config args in runAgent.

Testing:
- New unit tests cover all four registry states: gate registered (arg
  emitted), absent (nil, no error), stable (still enableable, arg emitted),
  and deprecated (treated like absent). The produced args are parsed through
  the real featuregate flag set rather than string-compared, and one test
  asserts the gate ends up enabled after parsing.
- go build ./..., CGO_ENABLED=0 go test ./cmd/amazon-cloudwatch-agent/,
  make fmt and make fmt-sh all pass.

Closes aws#2273
@royrajan13
royrajan13 requested a review from a team as a code owner September 4, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant