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

[8.11] [Fleet] Fix agent policy timeout to accept only integer (#172222) #172619

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 6 additions & 6 deletions x-pack/plugins/fleet/common/openapi/bundled.json
Original file line number Diff line number Diff line change
Expand Up @@ -6997,10 +6997,10 @@
"nullable": true
},
"unenroll_timeout": {
"type": "number"
"type": "integer"
},
"inactivity_timeout": {
"type": "number"
"type": "integer"
},
"package_policies": {
"description": "This field is present only when retrieving a single agent policy, or when retrieving a list of agent policies with the ?full=true parameter",
Expand Down Expand Up @@ -7100,10 +7100,10 @@
"nullable": true
},
"unenroll_timeout": {
"type": "number"
"type": "integer"
},
"inactivity_timeout": {
"type": "number"
"type": "integer"
},
"agent_features": {
"type": "array",
Expand Down Expand Up @@ -7172,10 +7172,10 @@
"nullable": true
},
"unenroll_timeout": {
"type": "number"
"type": "integer"
},
"inactivity_timeout": {
"type": "number"
"type": "integer"
},
"agent_features": {
"type": "array",
Expand Down
12 changes: 6 additions & 6 deletions x-pack/plugins/fleet/common/openapi/bundled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4472,9 +4472,9 @@ components:
type: string
nullable: true
unenroll_timeout:
type: number
type: integer
inactivity_timeout:
type: number
type: integer
package_policies:
description: >-
This field is present only when retrieving a single agent policy, or
Expand Down Expand Up @@ -4553,9 +4553,9 @@ components:
type: string
nullable: true
unenroll_timeout:
type: number
type: integer
inactivity_timeout:
type: number
type: integer
agent_features:
type: array
items:
Expand Down Expand Up @@ -4603,9 +4603,9 @@ components:
type: string
nullable: true
unenroll_timeout:
type: number
type: integer
inactivity_timeout:
type: number
type: integer
agent_features:
type: array
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ properties:
type: string
nullable: true
unenroll_timeout:
type: number
type: integer
inactivity_timeout:
type: number
type: integer
package_policies:
description: This field is present only when retrieving a single agent policy, or when retrieving a list of agent policies with the ?full=true parameter
type: array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ properties:
type: string
nullable: true
unenroll_timeout:
type: number
type: integer
inactivity_timeout:
type: number
type: integer
agent_features:
type: array
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ properties:
type: string
nullable: true
unenroll_timeout:
type: number
type: integer
inactivity_timeout:
type: number
type: integer
agent_features:
type: array
items:
Expand Down
14 changes: 12 additions & 2 deletions x-pack/plugins/fleet/server/types/models/agent_policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ function validateNonEmptyString(val: string) {

const TWO_WEEKS_SECONDS = 1209600;

function isInteger(n: number) {
if (!Number.isInteger(n)) {
return `${n} is not a valid integer`;
}
}

export const AgentPolicyBaseSchema = {
id: schema.maybe(schema.string()),
name: schema.string({ minLength: 1, validate: validateNonEmptyString }),
Expand All @@ -28,8 +34,12 @@ export const AgentPolicyBaseSchema = {
has_fleet_server: schema.maybe(schema.boolean()),
is_default: schema.maybe(schema.boolean()),
is_default_fleet_server: schema.maybe(schema.boolean()),
unenroll_timeout: schema.maybe(schema.number({ min: 0 })),
inactivity_timeout: schema.number({ min: 0, defaultValue: TWO_WEEKS_SECONDS }),
unenroll_timeout: schema.maybe(schema.number({ min: 0, validate: isInteger })),
inactivity_timeout: schema.number({
min: 0,
defaultValue: TWO_WEEKS_SECONDS,
validate: isInteger,
}),
monitoring_enabled: schema.maybe(
schema.arrayOf(
schema.oneOf([schema.literal(dataTypes.Logs), schema.literal(dataTypes.Metrics)])
Expand Down
Loading