mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Fleet] Fix bumpAllPolicy to fetch all policies (#122277)
This commit is contained in:
parent
eb9001d184
commit
d0d50bf9bd
1 changed files with 13 additions and 11 deletions
|
@ -8,14 +8,14 @@
|
|||
import { uniq, omit } from 'lodash';
|
||||
import uuid from 'uuid/v4';
|
||||
import uuidv5 from 'uuid/v5';
|
||||
import { safeDump } from 'js-yaml';
|
||||
import pMap from 'p-map';
|
||||
import type {
|
||||
ElasticsearchClient,
|
||||
SavedObjectsClientContract,
|
||||
SavedObjectsBulkUpdateResponse,
|
||||
} from 'src/core/server';
|
||||
|
||||
import { safeDump } from 'js-yaml';
|
||||
|
||||
import { SavedObjectsErrorHelpers } from '../../../../../src/core/server';
|
||||
|
||||
import type { AuthenticatedUser } from '../../../security/server';
|
||||
|
@ -23,6 +23,7 @@ import {
|
|||
AGENT_POLICY_SAVED_OBJECT_TYPE,
|
||||
AGENTS_PREFIX,
|
||||
PRECONFIGURATION_DELETION_RECORD_SAVED_OBJECT_TYPE,
|
||||
SO_SEARCH_LIMIT,
|
||||
} from '../constants';
|
||||
import type {
|
||||
PackagePolicy,
|
||||
|
@ -477,6 +478,7 @@ class AgentPolicyService {
|
|||
fields: ['revision', 'data_output_id', 'monitoring_output_id'],
|
||||
searchFields: ['data_output_id', 'monitoring_output_id'],
|
||||
search: escapeSearchQueryPhrase(outputId),
|
||||
perPage: SO_SEARCH_LIMIT,
|
||||
});
|
||||
const bumpedPolicies = currentPolicies.saved_objects.map((policy) => {
|
||||
policy.attributes = {
|
||||
|
@ -488,11 +490,10 @@ class AgentPolicyService {
|
|||
return policy;
|
||||
});
|
||||
const res = await soClient.bulkUpdate<AgentPolicySOAttributes>(bumpedPolicies);
|
||||
|
||||
await Promise.all(
|
||||
currentPolicies.saved_objects.map((policy) =>
|
||||
this.triggerAgentPolicyUpdatedEvent(soClient, esClient, 'updated', policy.id)
|
||||
)
|
||||
await pMap(
|
||||
currentPolicies.saved_objects,
|
||||
(policy) => this.triggerAgentPolicyUpdatedEvent(soClient, esClient, 'updated', policy.id),
|
||||
{ concurrency: 50 }
|
||||
);
|
||||
|
||||
return res;
|
||||
|
@ -506,6 +507,7 @@ class AgentPolicyService {
|
|||
const currentPolicies = await soClient.find<AgentPolicySOAttributes>({
|
||||
type: SAVED_OBJECT_TYPE,
|
||||
fields: ['revision'],
|
||||
perPage: SO_SEARCH_LIMIT,
|
||||
});
|
||||
const bumpedPolicies = currentPolicies.saved_objects.map((policy) => {
|
||||
policy.attributes = {
|
||||
|
@ -518,10 +520,10 @@ class AgentPolicyService {
|
|||
});
|
||||
const res = await soClient.bulkUpdate<AgentPolicySOAttributes>(bumpedPolicies);
|
||||
|
||||
await Promise.all(
|
||||
currentPolicies.saved_objects.map((policy) =>
|
||||
this.triggerAgentPolicyUpdatedEvent(soClient, esClient, 'updated', policy.id)
|
||||
)
|
||||
await pMap(
|
||||
currentPolicies.saved_objects,
|
||||
(policy) => this.triggerAgentPolicyUpdatedEvent(soClient, esClient, 'updated', policy.id),
|
||||
{ concurrency: 50 }
|
||||
);
|
||||
|
||||
return res;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue