Repository navigation
[Process Agent] Add Version Command - #11230
Conversation
d783511 to
dca150b
Compare
robertjli
left a comment
There was a problem hiding this comment.
Just a few nits and questions (mostly for my own benefit) 🙂
| build_include=None, | ||
| build_exclude=None, | ||
| flavor=AgentFlavor.base.name, | ||
| go_version=None, |
There was a problem hiding this comment.
Just for my own understanding, why is this being removed?
There was a problem hiding this comment.
It's a bit redundant, since we can always just call runtime.Version() from the standard library and get the exact same data.
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| return WriteVersion(os.Stdout) | ||
| }, | ||
| SilenceUsage: true, |
There was a problem hiding this comment.
Is there a specific reason to use SilenceUsage here? Don't we want to show errors if they come up?
There was a problem hiding this comment.
SilenceUsage doesn't suppress errors, it just makes sure that the help text isn't displayed in addition to any errors that might occur, which adds a bunch of noise. However, upon testing I realize that it inherits this value from the parent command, so including it is a no-op.
| extraHeaders.Set(headers.TimestampHeader, strconv.Itoa(int(start.Unix()))) | ||
| extraHeaders.Set(headers.HostHeader, l.cfg.HostName) | ||
| extraHeaders.Set(headers.ProcessVersionHeader, Version) | ||
| extraHeaders.Set(headers.ProcessVersionHeader, agentVersion.GetNumber()) |
There was a problem hiding this comment.
Since we're changing all payloads header here, are we sure that agent.GetNumber() returns the same value as Version?
There was a problem hiding this comment.
They should be the same format. Both github.com/DataDog/datadog-agent/cmd/process-agent.Version and github.com/DataDog/datadog-agent/pkg/version.AgentVersion are sourced from the same get_version function in the python build script.
Lines 379 to 409 in 7993fe7
The only difference is that in non-release builds it will include the git hash since the last build, although that isn't included in GetNumber.
datadog-agent/pkg/version/version.go
Lines 84 to 86 in e081bed
…` builds (#59871) ### What does this PR do? Drop the `ld_vars` blocks of `security-agent.build` and `cws-instrumentation.build`, which pass `-X` ldflags for `main.Version`, `main.GoVersion`, `main.GitBranch`, `main.GitCommit` and `main.BuildDate`, along with `get_go_version`, their last caller. ### Motivation Neither `cmd/security-agent` nor `cmd/cws-instrumentation` has ever declared those variables, so **the linker drops the flags**, while the tasks still run `git` and `go version` for them at every build. The block originates from the process agent, whose `main` package declared those variables at the time: - #5440 copied it into the security agent's scaffold, - #11230 removed it from the process agent, along with those variables, in favor of `pkg/version`, which both binaries already report, - #18620 copied the security agent's block into `tasks/cws_instrumentation.py`, leaving these 2 copies as the last ones. ### Describe how you validated your changes Built `security-agent` and `cws-instrumentation` with and without the change, and checked that: - each kept its size and build settings, - `security-agent` (the only one not stripped) kept its symbols (none of which is one of those variables) as well as its `version` output. Co-authored-by: regis.desgroppes <[email protected]>
What does this PR do?
This PR migrates the process agent to the core agent's version package, and creates a brand new
versioncommand for the process agent. It also displays a deprecation message when the user uses the old--versionflag.Motivation
The goal of this PR is to make the process agent's cli more similar to the core agent's cli.
Additional Notes
Possible Drawbacks / Trade-offs
Describe how to test/QA your changes
Reviewer's Checklist
Triagemilestone is set.major_changelabel if your change either has a major impact on the code base, is impacting multiple teams or is changing important well-established internals of the Agent. This label will be use during QA to make sure each team pay extra attention to the changed behavior. For any customer facing change use a releasenote.changelog/no-changeloglabel has been applied.qa/skip-qalabel is not applied.team/..label has been applied, indicating the team(s) that should QA this change.need-change/operatorandneed-change/helmlabels have been applied.