Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional_parameters to diagnostics action #3333

Merged
merged 5 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Kind can be one of:
# - breaking-change: a change to previously-documented behavior
# - deprecation: functionality that is being removed in a later release
# - bug-fix: fixes a problem in a previous version
# - enhancement: extends functionality but does not break or fix existing behavior
# - feature: new functionality
# - known-issue: problems that we are aware of in a given version
# - security: impacts on the security of a product or a user’s deployment.
# - upgrade: important information for someone upgrading from a prior version
# - other: does not fit into any of the other categories
kind: enchancement

# Change summary; a 80ish characters long description of the change.
summary: Add additional_parameters to diagnostics actions

# Long description; in case the summary is not enough to describe the change
# this field accommodate a description without length limits.
# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment.
#description:

# Affected component; a word indicating the component this changeset affects.
component:

# PR URL; optional; the PR number that added the changeset.
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
# Please provide it if you are adding a fragment for a different PR.
pr: 3333

# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
# If not present is automatically filled by the tooling with the issue linked to the PR number.
#issue: https://github.com/owner/repo/1234
10 changes: 9 additions & 1 deletion internal/pkg/api/handleCheckin.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,15 @@ func convertActionData(aType ActionType, raw json.RawMessage) (ad Action_Data, e
}
err = ad.FromActionUpgrade(d)
return
case REQUESTDIAGNOSTICS, UNENROLL: // Action types with no data
case REQUESTDIAGNOSTICS:
d := ActionRequestDiagnostics{}
err = json.Unmarshal(raw, &d)
if err != nil {
return
}
err = ad.FromActionRequestDiagnostics(d)
return
case UNENROLL: // Action types with no data
return ad, nil
default:
return ad, fmt.Errorf("data conversion unsupported action type: %s", aType)
Expand Down
6 changes: 6 additions & 0 deletions internal/pkg/api/handleCheckin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ func TestConvertActionData(t *testing.T) {
aType: REQUESTDIAGNOSTICS,
expect: Action_Data{},
hasErr: false,
}, {
name: "request diagnostics with additional cpu metric",
aType: REQUESTDIAGNOSTICS,
raw: json.RawMessage(`{"additional_metrics": ["CPU"]}`),
expect: Action_Data{json.RawMessage(`{"additional_metrics":["CPU"]}`)},
hasErr: false,
}, {
name: "unenroll action",
aType: UNENROLL,
Expand Down
13 changes: 12 additions & 1 deletion internal/pkg/api/openapi.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions model/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,14 @@ components:
download_rate:
description: The artifact download rate as bytes per second.
type: number
format: double
format: double
retry_error_msg:
description: The error message that is a result of a retryable upgrade download failure.
type: string
type: string
retry_until:
description: The RFC3339 timestamp of the deadline the upgrade download is retried until.
type: string
format: date-time
format: date-time
upgrade_metadata_failed:
description: Upgrade metadata for an upgrade that has failed.
required:
Expand Down Expand Up @@ -549,7 +549,14 @@ components:
# unenroll actions have no `data` attribute
actionRequestDiagnostics:
description: The REQUEST_DIAGNOSTICS action data.
# diagnostics actions have no `data` attribute
properties:
Copy link
Member

Choose a reason for hiding this comment

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

Just to double check, this is backwards compatible with older agents that don't understand this yet? They'll just ignore it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.
I ran another e2e test by enrolling an agent without the changes in elastic/elastic-agent#4394 to a fleet-server instance build with the changes in this PR and manually inserting an action with CPU in additional_metrics.
A diagnostics bundle was generated with no cpu.pprof as a part of it

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

additional_metrics:
description: list optional additional metrics.
type: array
items:
type: string
enum:
- CPU
actionPolicyReassign:
description: The POLICY_REASSIGN action data.
type: object
Expand Down
13 changes: 12 additions & 1 deletion pkg/api/types.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading