-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Ingest Manager] Upgrade Agents in Fleet (#78810)
* add kibanaVersion context and hook, add upgrade available indications * add agent upgrade modals and action buttons * fix import * add bulk actions api and remove source_uri as required * add upgrading to AgentHealth status * buildKueryForUpgradingAgents * bulk actions UI * remove source_uri * add release type to agent details * don't allow upgrade of unenrolled/unenrolling agent * hide upgradeable button when not upgradeable * fix test * add udpating agent status * remove upgrade available filter button for now * update isUpgradeAvailable to use local_metadata upgradeable * add UPDATING to agent event subtype * use saved object for updating agent status * add updating badge type label * add upgrade available button and update agent list endpoint to accept showUpgradeable * add schema and type for UPDATING * fix type * dont try to upgrade local_metadata * exclude from AAD upgrade_started_at and upgraded_at Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
f490268
commit 53f22dc
Showing
35 changed files
with
901 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
x-pack/plugins/ingest_manager/common/services/is_agent_upgradeable.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import { isAgentUpgradeable } from './is_agent_upgradeable'; | ||
import { Agent } from '../types/models/agent'; | ||
|
||
const getAgent = (version: string, upgradeable: boolean): Agent => { | ||
const agent: Agent = { | ||
id: 'de9006e1-54a7-4320-b24e-927e6fe518a8', | ||
active: true, | ||
policy_id: '63a284b0-0334-11eb-a4e0-09883c57114b', | ||
type: 'PERMANENT', | ||
enrolled_at: '2020-09-30T20:24:08.347Z', | ||
user_provided_metadata: {}, | ||
local_metadata: { | ||
elastic: { | ||
agent: { | ||
id: 'de9006e1-54a7-4320-b24e-927e6fe518a8', | ||
version, | ||
snapshot: false, | ||
'build.original': | ||
'8.0.0 (build: e2ef4fc375a5ece83d5d38f57b2977d7866b5819 at 2020-09-30 20:21:35 +0000 UTC)', | ||
}, | ||
}, | ||
host: { | ||
architecture: 'x86_64', | ||
hostname: 'Sandras-MBP.fios-router.home', | ||
name: 'Sandras-MBP.fios-router.home', | ||
id: '1112D0AD-526D-5268-8E86-765D35A0F484', | ||
ip: [ | ||
'127.0.0.1/8', | ||
'::1/128', | ||
'fe80::1/64', | ||
'fe80::aede:48ff:fe00:1122/64', | ||
'fe80::4fc:2526:7d51:19cc/64', | ||
'192.168.1.161/24', | ||
'fe80::3083:5ff:fe30:4b00/64', | ||
'fe80::3083:5ff:fe30:4b00/64', | ||
'fe80::f7fb:518e:2c3c:7815/64', | ||
'fe80::2abd:20e3:9bc3:c054/64', | ||
'fe80::531a:20ab:1f38:7f9/64', | ||
], | ||
mac: [ | ||
'a6:83:e7:b0:1a:d2', | ||
'ac:de:48:00:11:22', | ||
'a4:83:e7:b0:1a:d2', | ||
'82:c5:c2:25:b0:01', | ||
'82:c5:c2:25:b0:00', | ||
'82:c5:c2:25:b0:05', | ||
'82:c5:c2:25:b0:04', | ||
'82:c5:c2:25:b0:01', | ||
'06:83:e7:b0:1a:d2', | ||
'32:83:05:30:4b:00', | ||
'32:83:05:30:4b:00', | ||
], | ||
}, | ||
os: { | ||
family: 'darwin', | ||
kernel: '19.4.0', | ||
platform: 'darwin', | ||
version: '10.15.4', | ||
name: 'Mac OS X', | ||
full: 'Mac OS X(10.15.4)', | ||
}, | ||
}, | ||
access_api_key_id: 'A_6v4HQBEEDXi-A9vxPE', | ||
default_api_key_id: 'BP6v4HQBEEDXi-A95xMk', | ||
policy_revision: 1, | ||
packages: ['system'], | ||
last_checkin: '2020-10-01T14:43:27.255Z', | ||
current_error_events: [], | ||
status: 'online', | ||
}; | ||
if (upgradeable) { | ||
agent.local_metadata.elastic.agent.upgradeable = true; | ||
} | ||
return agent; | ||
}; | ||
describe('Ingest Manager - isAgentUpgradeable', () => { | ||
it('returns false if agent reports not upgradeable with agent version < kibana version', () => { | ||
expect(isAgentUpgradeable(getAgent('7.9.0', false), '8.0.0')).toBe(false); | ||
}); | ||
it('returns false if agent reports not upgradeable with agent version > kibana version', () => { | ||
expect(isAgentUpgradeable(getAgent('8.0.0', false), '7.9.0')).toBe(false); | ||
}); | ||
it('returns false if agent reports not upgradeable with agent version === kibana version', () => { | ||
expect(isAgentUpgradeable(getAgent('8.0.0', false), '8.0.0')).toBe(false); | ||
}); | ||
it('returns false if agent reports upgradeable, with agent version === kibana version', () => { | ||
expect(isAgentUpgradeable(getAgent('8.0.0', true), '8.0.0')).toBe(false); | ||
}); | ||
it('returns false if agent reports upgradeable, with agent version > kibana version', () => { | ||
expect(isAgentUpgradeable(getAgent('8.0.0', true), '7.9.0')).toBe(false); | ||
}); | ||
it('returns true if agent reports upgradeable, with agent version < kibana version', () => { | ||
expect(isAgentUpgradeable(getAgent('7.9.0', true), '8.0.0')).toBe(true); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
x-pack/plugins/ingest_manager/common/services/is_agent_upgradeable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import semver from 'semver'; | ||
import { Agent } from '../types'; | ||
|
||
export function isAgentUpgradeable(agent: Agent, kibanaVersion: string) { | ||
let agentVersion: string; | ||
if (typeof agent?.local_metadata?.elastic?.agent?.version === 'string') { | ||
agentVersion = agent.local_metadata.elastic.agent.version; | ||
} else { | ||
return false; | ||
} | ||
const kibanaVersionParsed = semver.parse(kibanaVersion); | ||
const agentVersionParsed = semver.parse(agentVersion); | ||
if (!agentVersionParsed || !kibanaVersionParsed) return false; | ||
if (!agent.local_metadata.elastic.agent.upgradeable) return false; | ||
return semver.lt(agentVersionParsed, kibanaVersionParsed); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_kibana_version.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { useContext } from 'react'; | ||
|
||
export const KibanaVersionContext = React.createContext<string | null>(null); | ||
|
||
export function useKibanaVersion() { | ||
const version = useContext(KibanaVersionContext); | ||
if (version === null) { | ||
throw new Error('KibanaVersionContext is not initialized'); | ||
} | ||
return version; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.