mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Ingest Manager] Remove useless saved object update in agent checkin (#75586)
This commit is contained in:
parent
eee139295d
commit
2946e68581
1 changed files with 7 additions and 3 deletions
|
@ -4,6 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import deepEqual from 'fast-deep-equal';
|
||||
import { SavedObjectsClientContract, SavedObjectsBulkCreateObject } from 'src/core/server';
|
||||
import {
|
||||
Agent,
|
||||
|
@ -29,16 +30,19 @@ export async function agentCheckin(
|
|||
) {
|
||||
const updateData: Partial<AgentSOAttributes> = {};
|
||||
const { updatedErrorEvents } = await processEventsForCheckin(soClient, agent, data.events);
|
||||
if (updatedErrorEvents) {
|
||||
if (
|
||||
updatedErrorEvents &&
|
||||
!(updatedErrorEvents.length === 0 && agent.current_error_events.length === 0)
|
||||
) {
|
||||
updateData.current_error_events = JSON.stringify(updatedErrorEvents);
|
||||
}
|
||||
if (data.localMetadata) {
|
||||
if (data.localMetadata && !deepEqual(data.localMetadata, agent.local_metadata)) {
|
||||
updateData.local_metadata = data.localMetadata;
|
||||
}
|
||||
|
||||
if (data.status !== agent.last_checkin_status) {
|
||||
updateData.last_checkin_status = data.status;
|
||||
}
|
||||
// Update agent only if something changed
|
||||
if (Object.keys(updateData).length > 0) {
|
||||
await soClient.update<AgentSOAttributes>(AGENT_SAVED_OBJECT_TYPE, agent.id, updateData);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue