[Fleet] Change log level when fleet server host is not found in the policy (#145005)

This commit is contained in:
Nicolas Chaulet 2022-11-10 13:02:58 -05:00 committed by GitHub
parent 38251947e3
commit 6963f577b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 5 deletions

View file

@ -4263,6 +4263,7 @@
"type": "boolean"
},
"fleet_server_hosts": {
"deprecated": true,
"type": "array",
"items": {
"type": "string"

View file

@ -2659,6 +2659,7 @@ components:
has_seen_add_data_notice:
type: boolean
fleet_server_hosts:
deprecated: true
type: array
items:
type: string

View file

@ -6,11 +6,12 @@ properties:
has_seen_add_data_notice:
type: boolean
fleet_server_hosts:
deprecated: true
type: array
items:
type: string
prerelease_integrations_enabled:
type: boolean
prerelease_integrations_enabled:
type: boolean
required:
- fleet_server_hosts
- id

View file

@ -8,7 +8,13 @@
import type { SavedObjectsClientContract } from '@kbn/core/server';
import { safeLoad } from 'js-yaml';
import type { FullAgentPolicy, PackagePolicy, Output, FullAgentPolicyOutput } from '../../types';
import type {
FullAgentPolicy,
AgentPolicy,
PackagePolicy,
Output,
FullAgentPolicyOutput,
} from '../../types';
import { agentPolicyService } from '../agent_policy';
import { outputService } from '../output';
import { dataTypes, outputType } from '../../../common/constants';
@ -34,7 +40,7 @@ export async function getFullAgentPolicy(
id: string,
options?: { standalone: boolean }
): Promise<FullAgentPolicy | null> {
let agentPolicy;
let agentPolicy: AgentPolicy | null | undefined;
const standalone = options?.standalone ?? false;
try {
@ -187,7 +193,9 @@ export async function getFullAgentPolicy(
if (!standalone) {
const fleetServerHost = await getFleetServerHostsForAgentPolicy(soClient, agentPolicy).catch(
(err) => {
appContextService.getLogger()?.error(err);
appContextService
.getLogger()
?.warn(`Unable to get fleet server hosts for policy ${agentPolicy?.id}: ${err.message}`);
return;
}