Skip to content

Commit

Permalink
Add additional_parameters to diagnostics action
Browse files Browse the repository at this point in the history
  • Loading branch information
michel-laterman committed Mar 11, 2024
1 parent 950eb52 commit a442ea9
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 7 deletions.
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: https://github.com/owner/repo/1234

# 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:
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.

0 comments on commit a442ea9

Please sign in to comment.