[8.16] Fix bug in capacity warning logs when assumedAverageRecurringRequiredThroughputPerMinutePerKibana was sufficient (#200578) (#201444)

# Backport

This will backport the following commits from `main` to `8.16`:
- [Fix bug in capacity warning logs when
assumedAverageRecurringRequiredThroughputPerMinutePerKibana was
sufficient (#200578)](https://github.com/elastic/kibana/pull/200578)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Mike
Côté","email":"mikecote@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-11-22T17:33:43Z","message":"Fix
bug in capacity warning logs when
assumedAverageRecurringRequiredThroughputPerMinutePerKibana was
sufficient (#200578)\n\nIn this PR, I'm fixing a bug where the task
manager unhealthy logs were\r\nshowing the wrong reason. Because the if
condition was
checking\r\n`assumedAverageRecurringRequiredThroughputPerMinutePerKibana`
to be less\r\nthan `capacityPerMinutePerKibana`, it would log this as
the reason task\r\nmanager is healthy. However whenever the value is
less, it means task\r\nmanager is running fine from a recurring task
perspective. Changing the\r\nif condition allows the next step in the
code to log which then
logs\r\n`assumedRequiredThroughputPerMinutePerKibana` as the real reason
why\r\ntask manager is
unhealthy.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"9fa8ec71529faa31a44fe2eac0902fb0d4b98797","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Feature:Task
Manager","Team:ResponseOps","v9.0.0","backport:version","v8.17.0","v8.16.1"],"title":"Fix
bug in capacity warning logs when
assumedAverageRecurringRequiredThroughputPerMinutePerKibana was
sufficient","number":200578,"url":"https://github.com/elastic/kibana/pull/200578","mergeCommit":{"message":"Fix
bug in capacity warning logs when
assumedAverageRecurringRequiredThroughputPerMinutePerKibana was
sufficient (#200578)\n\nIn this PR, I'm fixing a bug where the task
manager unhealthy logs were\r\nshowing the wrong reason. Because the if
condition was
checking\r\n`assumedAverageRecurringRequiredThroughputPerMinutePerKibana`
to be less\r\nthan `capacityPerMinutePerKibana`, it would log this as
the reason task\r\nmanager is healthy. However whenever the value is
less, it means task\r\nmanager is running fine from a recurring task
perspective. Changing the\r\nif condition allows the next step in the
code to log which then
logs\r\n`assumedRequiredThroughputPerMinutePerKibana` as the real reason
why\r\ntask manager is
unhealthy.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"9fa8ec71529faa31a44fe2eac0902fb0d4b98797"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200578","number":200578,"mergeCommit":{"message":"Fix
bug in capacity warning logs when
assumedAverageRecurringRequiredThroughputPerMinutePerKibana was
sufficient (#200578)\n\nIn this PR, I'm fixing a bug where the task
manager unhealthy logs were\r\nshowing the wrong reason. Because the if
condition was
checking\r\n`assumedAverageRecurringRequiredThroughputPerMinutePerKibana`
to be less\r\nthan `capacityPerMinutePerKibana`, it would log this as
the reason task\r\nmanager is healthy. However whenever the value is
less, it means task\r\nmanager is running fine from a recurring task
perspective. Changing the\r\nif condition allows the next step in the
code to log which then
logs\r\n`assumedRequiredThroughputPerMinutePerKibana` as the real reason
why\r\ntask manager is
unhealthy.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"9fa8ec71529faa31a44fe2eac0902fb0d4b98797"}},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.16","label":"v8.16.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Mike Côté <mikecote@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2024-11-23 06:22:18 +11:00 committed by GitHub
parent b938b43a5f
commit dd31886ad7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View file

@ -644,7 +644,7 @@ describe('estimateCapacity', () => {
value: expect.any(Object),
});
expect(logger.warn).toHaveBeenCalledWith(
'Task Manager is unhealthy, the assumedAverageRecurringRequiredThroughputPerMinutePerKibana (175) < capacityPerMinutePerKibana (200)'
'Task Manager is unhealthy, the assumedRequiredThroughputPerMinutePerKibana (215) >= capacityPerMinutePerKibana (200)'
);
});
@ -710,7 +710,7 @@ describe('estimateCapacity', () => {
value: expect.any(Object),
});
expect(logger.warn).toHaveBeenCalledWith(
'Task Manager is unhealthy, the assumedRequiredThroughputPerMinutePerKibana (250) >= capacityPerMinutePerKibana (200) AND assumedAverageRecurringRequiredThroughputPerMinutePerKibana (210) >= capacityPerMinutePerKibana (200)'
'Task Manager is unhealthy, the assumedAverageRecurringRequiredThroughputPerMinutePerKibana (210) > capacityPerMinutePerKibana (200)'
);
});

View file

@ -248,13 +248,13 @@ function getHealthStatus(
return { status: HealthStatus.OK, reason };
}
if (assumedAverageRecurringRequiredThroughputPerMinutePerKibana < capacityPerMinutePerKibana) {
const reason = `Task Manager is unhealthy, the assumedAverageRecurringRequiredThroughputPerMinutePerKibana (${assumedAverageRecurringRequiredThroughputPerMinutePerKibana}) < capacityPerMinutePerKibana (${capacityPerMinutePerKibana})`;
if (assumedAverageRecurringRequiredThroughputPerMinutePerKibana > capacityPerMinutePerKibana) {
const reason = `Task Manager is unhealthy, the assumedAverageRecurringRequiredThroughputPerMinutePerKibana (${assumedAverageRecurringRequiredThroughputPerMinutePerKibana}) > capacityPerMinutePerKibana (${capacityPerMinutePerKibana})`;
logger.warn(reason);
return { status: HealthStatus.OK, reason };
}
const reason = `Task Manager is unhealthy, the assumedRequiredThroughputPerMinutePerKibana (${assumedRequiredThroughputPerMinutePerKibana}) >= capacityPerMinutePerKibana (${capacityPerMinutePerKibana}) AND assumedAverageRecurringRequiredThroughputPerMinutePerKibana (${assumedAverageRecurringRequiredThroughputPerMinutePerKibana}) >= capacityPerMinutePerKibana (${capacityPerMinutePerKibana})`;
const reason = `Task Manager is unhealthy, the assumedRequiredThroughputPerMinutePerKibana (${assumedRequiredThroughputPerMinutePerKibana}) >= capacityPerMinutePerKibana (${capacityPerMinutePerKibana})`;
logger.warn(reason);
return { status: HealthStatus.OK, reason };
}