diff --git a/changelog/fragments/1710149156-Add-additional_parameters-to-diagnostics-actions.yaml b/changelog/fragments/1710149156-Add-additional_parameters-to-diagnostics-actions.yaml new file mode 100644 index 0000000000..cc818da452 --- /dev/null +++ b/changelog/fragments/1710149156-Add-additional_parameters-to-diagnostics-actions.yaml @@ -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 diff --git a/internal/pkg/api/handleCheckin.go b/internal/pkg/api/handleCheckin.go index c2c462c2ff..35f89ee346 100644 --- a/internal/pkg/api/handleCheckin.go +++ b/internal/pkg/api/handleCheckin.go @@ -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) diff --git a/internal/pkg/api/handleCheckin_test.go b/internal/pkg/api/handleCheckin_test.go index f26f67daca..a80807f426 100644 --- a/internal/pkg/api/handleCheckin_test.go +++ b/internal/pkg/api/handleCheckin_test.go @@ -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, diff --git a/internal/pkg/api/openapi.gen.go b/internal/pkg/api/openapi.gen.go index 4cc53eee30..f7d91e0079 100644 --- a/internal/pkg/api/openapi.gen.go +++ b/internal/pkg/api/openapi.gen.go @@ -35,6 +35,11 @@ const ( UPGRADE ActionType = "UPGRADE" ) +// Defines values for ActionRequestDiagnosticsAdditionalMetrics. +const ( + CPU ActionRequestDiagnosticsAdditionalMetrics = "CPU" +) + // Defines values for ActionSettingsLogLevel. const ( ActionSettingsLogLevelDebug ActionSettingsLogLevel = "debug" @@ -217,7 +222,13 @@ type ActionPolicyReassign struct { } // ActionRequestDiagnostics The REQUEST_DIAGNOSTICS action data. -type ActionRequestDiagnostics = interface{} +type ActionRequestDiagnostics struct { + // AdditionalMetrics list optional additional metrics. + AdditionalMetrics *[]ActionRequestDiagnosticsAdditionalMetrics `json:"additional_metrics,omitempty"` +} + +// ActionRequestDiagnosticsAdditionalMetrics defines model for ActionRequestDiagnostics.AdditionalMetrics. +type ActionRequestDiagnosticsAdditionalMetrics string // ActionSettings The SETTINGS action data. type ActionSettings struct { diff --git a/model/openapi.yml b/model/openapi.yml index 6b7f5d53b2..efe6f35c88 100644 --- a/model/openapi.yml +++ b/model/openapi.yml @@ -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: @@ -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 diff --git a/pkg/api/types.gen.go b/pkg/api/types.gen.go index 57c5a879c6..2e436aa57d 100644 --- a/pkg/api/types.gen.go +++ b/pkg/api/types.gen.go @@ -32,6 +32,11 @@ const ( UPGRADE ActionType = "UPGRADE" ) +// Defines values for ActionRequestDiagnosticsAdditionalMetrics. +const ( + CPU ActionRequestDiagnosticsAdditionalMetrics = "CPU" +) + // Defines values for ActionSettingsLogLevel. const ( ActionSettingsLogLevelDebug ActionSettingsLogLevel = "debug" @@ -214,7 +219,13 @@ type ActionPolicyReassign struct { } // ActionRequestDiagnostics The REQUEST_DIAGNOSTICS action data. -type ActionRequestDiagnostics = interface{} +type ActionRequestDiagnostics struct { + // AdditionalMetrics list optional additional metrics. + AdditionalMetrics *[]ActionRequestDiagnosticsAdditionalMetrics `json:"additional_metrics,omitempty"` +} + +// ActionRequestDiagnosticsAdditionalMetrics defines model for ActionRequestDiagnostics.AdditionalMetrics. +type ActionRequestDiagnosticsAdditionalMetrics string // ActionSettings The SETTINGS action data. type ActionSettings struct {