Task health calculation never returns Error or Warning but logs the HealthStatus (#139274)

* Task health calculation never returns Error or Warning but logs the HealthStatus.
This commit is contained in:
Ersin Erdal 2022-08-25 17:24:28 +02:00 committed by GitHub
parent 8991e046a2
commit 7b4b2be2a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 9 deletions

View file

@ -362,18 +362,40 @@ describe('Task Run Statistics', () => {
// Success, Success, Success, Failed
{ Success: 75, RetryScheduled: 0, Failed: 25, status: 'OK' },
// Success, Success, Success, Failed, Failed
{ Success: 60, RetryScheduled: 0, Failed: 40, status: 'warn' },
{ Success: 60, RetryScheduled: 0, Failed: 40, status: 'OK' },
// Success, Success, Failed, Failed, Failed
{ Success: 40, RetryScheduled: 0, Failed: 60, status: 'error' },
{ Success: 40, RetryScheduled: 0, Failed: 60, status: 'OK' },
// Success, Failed, Failed, Failed, RetryScheduled
{ Success: 20, RetryScheduled: 20, Failed: 60, status: 'error' },
{ Success: 20, RetryScheduled: 20, Failed: 60, status: 'OK' },
// Failed, Failed, Failed, RetryScheduled, RetryScheduled
{ Success: 0, RetryScheduled: 40, Failed: 60, status: 'error' },
{ Success: 0, RetryScheduled: 40, Failed: 60, status: 'OK' },
// Failed, Failed, RetryScheduled, RetryScheduled, Success
{ Success: 20, RetryScheduled: 40, Failed: 40, status: 'warn' },
{ Success: 20, RetryScheduled: 40, Failed: 40, status: 'OK' },
// Failed, RetryScheduled, RetryScheduled, Success, Success
{ Success: 40, RetryScheduled: 40, Failed: 20, status: 'OK' },
]);
expect(logger.debug).toHaveBeenCalledTimes(5);
expect(logger.debug).toHaveBeenNthCalledWith(
1,
'Health Status warn threshold has been exceeded, resultFrequencySummary.Failed (40) is greater than warn_threshold (39)'
);
expect(logger.debug).toHaveBeenNthCalledWith(
2,
'Health Status error threshold has been exceeded, resultFrequencySummary.Failed (60) is greater than error_threshold (59)'
);
expect(logger.debug).toHaveBeenNthCalledWith(
3,
'Health Status error threshold has been exceeded, resultFrequencySummary.Failed (60) is greater than error_threshold (59)'
);
expect(logger.debug).toHaveBeenNthCalledWith(
4,
'Health Status error threshold has been exceeded, resultFrequencySummary.Failed (60) is greater than error_threshold (59)'
);
expect(logger.debug).toHaveBeenNthCalledWith(
5,
'Health Status warn threshold has been exceeded, resultFrequencySummary.Failed (40) is greater than warn_threshold (39)'
);
resolve();
} catch (e) {
reject(e);

View file

@ -434,14 +434,12 @@ function getHealthStatus(
if (resultFrequencySummary.Failed > executionErrorThreshold.warn_threshold) {
if (resultFrequencySummary.Failed > executionErrorThreshold.error_threshold) {
logger.debug(
`setting HealthStatus.Error because resultFrequencySummary.Failed (${resultFrequencySummary.Failed}) > error_threshold (${executionErrorThreshold.error_threshold})`
`Health Status error threshold has been exceeded, resultFrequencySummary.Failed (${resultFrequencySummary.Failed}) is greater than error_threshold (${executionErrorThreshold.error_threshold})`
);
return HealthStatus.Error;
} else {
logger.debug(
`setting HealthStatus.Warning because resultFrequencySummary.Failed (${resultFrequencySummary.Failed}) > warn_threshold (${executionErrorThreshold.warn_threshold})`
`Health Status warn threshold has been exceeded, resultFrequencySummary.Failed (${resultFrequencySummary.Failed}) is greater than warn_threshold (${executionErrorThreshold.warn_threshold})`
);
return HealthStatus.Warning;
}
}