forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fleet] fix stuck in updating logic when agent is scheduled for upgra…
…ding (elastic#202126) ## Summary Closes elastic#194460 Fixed the logic that calculates if agent is stuck in updating. Agents shouldn't be considered stuck in updating if they are in `UPG_SCHEDULED` or any other upgrade state apart from `UPG_FAILED`. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
- Loading branch information
1 parent
debe02b
commit 4784022
Showing
2 changed files
with
88 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { Agent } from '../types'; | ||
|
||
import { isStuckInUpdating } from './agent_status'; | ||
|
||
describe('isStuckInUpdating', () => { | ||
it('should return true if agent is active and in failed upgrade state', () => { | ||
const agent = { | ||
active: true, | ||
status: 'online', | ||
upgrade_details: { | ||
state: 'UPG_FAILED', | ||
}, | ||
} as Agent; | ||
|
||
expect(isStuckInUpdating(agent)).toBe(true); | ||
}); | ||
|
||
it('should return false if agent is active and in watching upgrade state', () => { | ||
const agent = { | ||
active: true, | ||
status: 'online', | ||
upgrade_details: { | ||
state: 'UPG_WATCHING', | ||
}, | ||
} as Agent; | ||
|
||
expect(isStuckInUpdating(agent)).toBe(false); | ||
}); | ||
|
||
it('should return false if agent is active and in rollback upgrade state', () => { | ||
const agent = { | ||
active: true, | ||
status: 'online', | ||
upgrade_details: { | ||
state: 'UPG_ROLLBACK', | ||
}, | ||
} as Agent; | ||
|
||
expect(isStuckInUpdating(agent)).toBe(false); | ||
}); | ||
|
||
it('should return false if agent is updating and in schedule upgrade state', () => { | ||
const agent = { | ||
active: true, | ||
status: 'updating', | ||
upgrade_started_at: '2022-11-21T12:27:24Z', | ||
upgrade_details: { | ||
state: 'UPG_SCHEDULED', | ||
}, | ||
} as Agent; | ||
|
||
expect(isStuckInUpdating(agent)).toBe(false); | ||
}); | ||
|
||
it('should return false if agent is updating and in downloading upgrade state', () => { | ||
const agent = { | ||
active: true, | ||
status: 'updating', | ||
upgrade_started_at: '2022-11-21T12:27:24Z', | ||
upgrade_details: { | ||
state: 'UPG_DOWNLOADING', | ||
}, | ||
} as Agent; | ||
|
||
expect(isStuckInUpdating(agent)).toBe(false); | ||
}); | ||
|
||
it('should return true if agent is updating no upgrade details state', () => { | ||
const agent = { | ||
active: true, | ||
status: 'updating', | ||
upgrade_started_at: '2022-11-21T12:27:24Z', | ||
} as Agent; | ||
|
||
expect(isStuckInUpdating(agent)).toBe(true); | ||
}); | ||
}); |
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