Remove --sample-config flag from amazon-cloudwatch-agent executable

Open Beginner friendly
#615 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
62/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
go
Domain
cli

Research direction

Start in cmd/amazon-cloudwatch-agent/amazon-cloudwatch-agent.go, where --sample-config and the related filter flags are defined and handled. Trace their references and remove the flag handling so the executable no longer exposes these options or reaches the panicking sample-configuration path. Done means the obsolete flags and their uses are gone without affecting normal agent startup.

Written by the indexing model from the issue text.

Description

enhancement good first issue

The --sample-config flag is useless, it prints out a TOML config which is not relevant for a CWAgent customer. Not to mention it panics because it tries to print the config for one of the container processors, which expects /rootfs to exist - see below. The existence of this flag is confusing to customers because they might think it could show them a sample JSON config.

This flag should be removed, along with the --section-filter, --input-filter, --output-filter, --aggregator-filter, and --processor-filter flags which are only used in conjunction with --sample-config.

Panic output:

2022-10-19T13:56:51Z E! /rootfs/proc does not exist
panic: E! /rootfs/proc does not exist

goroutine 1 [running]:
log.Panic({0xc0009bf738?, 0xc00050f500?, 0x3ad4dc0?})
        /usr/lib/golang/src/log/log.go:385 +0x65
github.com/aws/amazon-cloudwatch-agent/internal/containerinsightscommon.NewNodeCapacity()
        /builddir/build/BUILD/amazon-cloudwatch-agent-1.247354.0b251981/amazon-cloudwatch-agent/internal/containerinsightscommon/nodeCapacity.go:21 +0x7c
github.com/aws/amazon-cloudwatch-agent/plugins/processors/ecsdecorator.init.0.func1()
        /builddir/build/BUILD/amazon-cloudwatch-agent-1.247354.0b251981/amazon-cloudwatch-agent/plugins/processors/ecsdecorator/ecsdecorator.go:166 +0x19
github.com/influxdata/telegraf/plugins/processors.upgradeToStreamingProcessor.func1()
        /builddir/build/BUILD/amazon-cloudwatch-agent-1.247354.0b251981/amazon-cloudwatch-agent/vendor/github.com/influxdata/telegraf/plugins/processors/registry.go:24 +0x1d
github.com/influxdata/telegraf/config.printFilteredProcessors({0xc0006da180, 0x5, 0x8?}, 0x1?)
        /builddir/build/BUILD/amazon-cloudwatch-agent-1.247354.0b251981/amazon-cloudwatch-agent/vendor/github.com/influxdata/telegraf/config/config.go:577 +0x266
github.com/influxdata/telegraf/config.PrintSampleConfig({0xc0009bfcf0, 0x0, 0x0}, {0x560d170?, 0x0, 0x0}, {0x560d170?, 0x0, 0x0}, {0xc0009bfcf0, ...}, ...)
        /builddir/build/BUILD/amazon-cloudwatch-agent-1.247354.0b251981/amazon-cloudwatch-agent/vendor/github.com/influxdata/telegraf/config/config.go:519 +0x6a5
main.main()
        /builddir/build/BUILD/amazon-cloudwatch-agent-1.247354.0b251981/amazon-cloudwatch-agent/cmd/amazon-cloudwatch-agent/amazon-cloudwatch-agent.go:473 +0xb9a
Dominant language
Go
Stars
550
Forks
275
Avg merge
1d 11h
Merged PRs (30d)
15

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aws/amazon-cloudwatch-agent

All issues in aws/amazon-cloudwatch-agent

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.