Skip to content

Commit

Permalink
Merge branch 'main' into d/2021-12-30-significant-text-agg
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Jan 5, 2022
2 parents de0f9dc + cd0326c commit fbf583f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions x-pack/plugins/fleet/server/routes/agent_policy/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ import type {
import { defaultIngestErrorHandler } from '../../errors';
import { incrementPackageName } from '../../services/package_policy';

export const getAgentPoliciesHandler: RequestHandler<
export const getAgentPoliciesHandler: FleetRequestHandler<
undefined,
TypeOf<typeof GetAgentPoliciesRequestSchema.query>
> = async (context, request, response) => {
const soClient = context.core.savedObjects.client;
const soClient = context.fleet.epm.internalSoClient;
const esClient = context.core.elasticsearch.client.asInternalUser;
const { full: withPackagePolicies = false, ...restOfQuery } = request.query;
try {
Expand Down
24 changes: 13 additions & 11 deletions x-pack/plugins/fleet/server/services/agent_policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@
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';
import {
AGENT_POLICY_SAVED_OBJECT_TYPE,
AGENTS_PREFIX,
PRECONFIGURATION_DELETION_RECORD_SAVED_OBJECT_TYPE,
SO_SEARCH_LIMIT,
} from '../constants';
import type {
PackagePolicy,
Expand Down Expand Up @@ -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 = {
Expand All @@ -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;
Expand All @@ -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 = {
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({
<>
<p>
{i18n.translate('xpack.lens.editorFrame.emptyWorkspaceHeading', {
defaultMessage: 'Lens is a new tool for creating visualization',
defaultMessage: 'Lens is the recommended editor for creating visualizations',
})}
</p>
<p>
Expand Down

0 comments on commit fbf583f

Please sign in to comment.