mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 11:05:39 -04:00
# Backport This will backport the following commits from `main` to `9.0`: - [[SDH][APM] Handle create anomaly detection jobs failures (#219364)](https://github.com/elastic/kibana/pull/219364) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Sergi Romeu","email":"sergi.romeu@elastic.co"},"sourceCommit":{"committedDate":"2025-04-30T08:49:04Z","message":"[SDH][APM] Handle create anomaly detection jobs failures (#219364)\n\n## Summary\n\nFixes #157704\n\nThis PR shows the error toast when you try to create an anomaly\ndetection job that throws an error.\n\n\nhttps://github.com/user-attachments/assets/0c3ca1a5-36a6-4385-8cf1-473e689e9afb\n\n## How to test\n1. Run kibana \n2. Modify\n[this](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-apm-synthtrace/src/lib/utils/get_synthtrace_environment.ts)\nto have a long environment name.\n3. Go to APM -> Settings -> Anomaly detection.\n4. Try to create a job after running the synthtrace scenario, it should\nfail.\n\n---------\n\nCo-authored-by: jennypavlova <dzheni.pavlova@elastic.co>","sha":"da434192989436d55292433ccd0543364af57f20","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","apm:ml","sdh-linked","Team:obs-ux-infra_services","backport:version","v9.1.0","v8.19.0","v8.18.1","v9.0.1","v8.17.6"],"title":"[SDH][APM] Handle create anomaly detection jobs failures","number":219364,"url":"https://github.com/elastic/kibana/pull/219364","mergeCommit":{"message":"[SDH][APM] Handle create anomaly detection jobs failures (#219364)\n\n## Summary\n\nFixes #157704\n\nThis PR shows the error toast when you try to create an anomaly\ndetection job that throws an error.\n\n\nhttps://github.com/user-attachments/assets/0c3ca1a5-36a6-4385-8cf1-473e689e9afb\n\n## How to test\n1. Run kibana \n2. Modify\n[this](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-apm-synthtrace/src/lib/utils/get_synthtrace_environment.ts)\nto have a long environment name.\n3. Go to APM -> Settings -> Anomaly detection.\n4. Try to create a job after running the synthtrace scenario, it should\nfail.\n\n---------\n\nCo-authored-by: jennypavlova <dzheni.pavlova@elastic.co>","sha":"da434192989436d55292433ccd0543364af57f20"}},"sourceBranch":"main","suggestedTargetBranches":["8.19","8.18","9.0","8.17"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/219364","number":219364,"mergeCommit":{"message":"[SDH][APM] Handle create anomaly detection jobs failures (#219364)\n\n## Summary\n\nFixes #157704\n\nThis PR shows the error toast when you try to create an anomaly\ndetection job that throws an error.\n\n\nhttps://github.com/user-attachments/assets/0c3ca1a5-36a6-4385-8cf1-473e689e9afb\n\n## How to test\n1. Run kibana \n2. Modify\n[this](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-apm-synthtrace/src/lib/utils/get_synthtrace_environment.ts)\nto have a long environment name.\n3. Go to APM -> Settings -> Anomaly detection.\n4. Try to create a job after running the synthtrace scenario, it should\nfail.\n\n---------\n\nCo-authored-by: jennypavlova <dzheni.pavlova@elastic.co>","sha":"da434192989436d55292433ccd0543364af57f20"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.17","label":"v8.17.6","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Sergi Romeu <sergi.romeu@elastic.co> Co-authored-by: jennypavlova <dzheni.pavlova@elastic.co>
This commit is contained in:
parent
1a550614f6
commit
0df588b1a3
2 changed files with 38 additions and 11 deletions
|
@ -51,7 +51,7 @@ function generateData({
|
||||||
const getAbleToModifyCase = () => {
|
const getAbleToModifyCase = () => {
|
||||||
it('should be able to modify settings', () => {
|
it('should be able to modify settings', () => {
|
||||||
const { rangeFrom, rangeTo } = timeRange;
|
const { rangeFrom, rangeTo } = timeRange;
|
||||||
const TEST_ENV = 'test environment ' + new Date().toISOString();
|
const TEST_ENV = 'test env ' + new Date().toISOString();
|
||||||
|
|
||||||
synthtrace.index(
|
synthtrace.index(
|
||||||
generateData({
|
generateData({
|
||||||
|
@ -66,13 +66,37 @@ const getAbleToModifyCase = () => {
|
||||||
const button = cy.get('button[data-test-subj="apmJobsListCreateJobButton"]');
|
const button = cy.get('button[data-test-subj="apmJobsListCreateJobButton"]');
|
||||||
button.should('not.be.disabled');
|
button.should('not.be.disabled');
|
||||||
button.click();
|
button.click();
|
||||||
cy.get('div[data-test-subj="comboBoxInput"]').click();
|
cy.get('div[data-test-subj="comboBoxInput"]').click({ force: true });
|
||||||
cy.get(`button[title="${TEST_ENV}"]`).click();
|
cy.get(`button[title="${TEST_ENV}"]`).click({ force: true });
|
||||||
cy.get('button[data-test-subj="apmAddEnvironmentsCreateJobsButton"]').click();
|
cy.get('button[data-test-subj="apmAddEnvironmentsCreateJobsButton"]').click();
|
||||||
cy.intercept('GET', '/internal/apm/settings/anomaly-detection/jobs*').as('internalApiRequest');
|
cy.intercept('GET', '/internal/apm/settings/anomaly-detection/jobs*').as('internalApiRequest');
|
||||||
cy.wait('@internalApiRequest');
|
cy.wait('@internalApiRequest', { timeout: 15000 });
|
||||||
cy.contains('Anomaly detection jobs created');
|
cy.contains('Anomaly detection jobs created');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should show error if api call crashes when modifying settings', () => {
|
||||||
|
const { rangeFrom, rangeTo } = timeRange;
|
||||||
|
const TEST_ENV =
|
||||||
|
'Synthtrace: case scenario TEST-with-a-really-long-name ' + new Date().toISOString();
|
||||||
|
|
||||||
|
synthtrace.index(
|
||||||
|
generateData({
|
||||||
|
from: new Date(rangeFrom).getTime(),
|
||||||
|
to: new Date(rangeTo).getTime(),
|
||||||
|
serviceName: 'opbeans-node',
|
||||||
|
environment: TEST_ENV,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
cy.visitKibana(basePath);
|
||||||
|
const button = cy.get('button[data-test-subj="apmJobsListCreateJobButton"]');
|
||||||
|
button.should('not.be.disabled');
|
||||||
|
button.click();
|
||||||
|
cy.get('div[data-test-subj="comboBoxInput"]').click({ force: true });
|
||||||
|
cy.get(`button[title="${TEST_ENV}"]`).click({ force: true });
|
||||||
|
cy.get('button[data-test-subj="apmAddEnvironmentsCreateJobsButton"]').click();
|
||||||
|
cy.contains('Anomaly detection jobs could not be created');
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUnableToModifyCase = () => {
|
const getUnableToModifyCase = () => {
|
||||||
|
|
|
@ -68,13 +68,16 @@ export async function createAnomalyDetectionJobs({
|
||||||
// https://github.com/elastic/elasticsearch/issues/36271
|
// https://github.com/elastic/elasticsearch/issues/36271
|
||||||
for (const environment of uniqueMlJobEnvs) {
|
for (const environment of uniqueMlJobEnvs) {
|
||||||
try {
|
try {
|
||||||
responses.push(
|
const response = await createAnomalyDetectionJob({
|
||||||
await createAnomalyDetectionJob({
|
mlClient,
|
||||||
mlClient,
|
environment,
|
||||||
environment,
|
apmMetricIndex,
|
||||||
apmMetricIndex,
|
});
|
||||||
})
|
if (response.jobs[0].success || !response.jobs[0].error) {
|
||||||
);
|
responses.push(response);
|
||||||
|
} else {
|
||||||
|
failedJobs.push({ id: response.jobs[0].id, error: response.jobs[0].error });
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!e.id || !e.error) {
|
if (!e.id || !e.error) {
|
||||||
throw e;
|
throw e;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue