mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Fleet] Fix namespaces property of created agent policies (#189199)
## Summary
I found a small bug while working on
https://github.com/elastic/kibana/issues/185040: when agent policies are
created, there should be a root-level `namespaces` property, which is
currently missing.
`GET .fleet-policies/_mapping` contains a `namespaces` property with
`keyword` type that was added in
https://github.com/elastic/elasticsearch.
Note: I was looking into removing the existing `data.namespaces`
property, however I don't see any issues with it. It is coming from
[here](f77e4d243f/x-pack/plugins/fleet/server/services/agent_policy.ts (L1140)
),
i.e. the `data` property is generated from the full agent policy which
already has a `namespaces` property.
### Checklist
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
This commit is contained in:
parent
e1f20116cb
commit
9bc57412bb
3 changed files with 13 additions and 1 deletions
|
@ -193,6 +193,10 @@ export interface FleetServerPolicy {
|
|||
* The coordinator index of the policy
|
||||
*/
|
||||
coordinator_idx: number;
|
||||
/**
|
||||
* The namespaces of the policy
|
||||
*/
|
||||
namespaces?: string[];
|
||||
/**
|
||||
* The opaque payload.
|
||||
*/
|
||||
|
|
|
@ -1230,6 +1230,7 @@ describe('Agent policy', () => {
|
|||
mockedGetFullAgentPolicy.mockResolvedValue({
|
||||
id: 'policy123',
|
||||
revision: 1,
|
||||
namespaces: ['mySpace'],
|
||||
inputs: [
|
||||
{
|
||||
id: 'input-123',
|
||||
|
@ -1282,10 +1283,16 @@ describe('Agent policy', () => {
|
|||
}),
|
||||
expect.objectContaining({
|
||||
'@timestamp': expect.anything(),
|
||||
data: { id: 'policy123', inputs: [{ id: 'input-123' }], revision: 1 },
|
||||
data: {
|
||||
id: 'policy123',
|
||||
inputs: [{ id: 'input-123' }],
|
||||
revision: 1,
|
||||
namespaces: ['mySpace'],
|
||||
},
|
||||
default_fleet_server: false,
|
||||
policy_id: 'policy123',
|
||||
revision_idx: 1,
|
||||
namespaces: ['mySpace'],
|
||||
}),
|
||||
],
|
||||
refresh: 'wait_for',
|
||||
|
|
|
@ -1137,6 +1137,7 @@ class AgentPolicyService {
|
|||
'@timestamp': new Date().toISOString(),
|
||||
revision_idx: fullPolicy.revision,
|
||||
coordinator_idx: 0,
|
||||
namespaces: fullPolicy.namespaces,
|
||||
data: fullPolicy as unknown as FleetServerPolicy['data'],
|
||||
policy_id: fullPolicy.id,
|
||||
default_fleet_server: policy.is_default_fleet_server === true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue