Skip to content

Commit

Permalink
[8.x] [DataUsage][Serverless] Fix AutoOps error message to drop &quot…
Browse files Browse the repository at this point in the history
…;agent" reference (#202996) (#203190)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[DataUsage][Serverless] Fix AutoOps error message to drop
"agent" reference
(#202996)](#202996)

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

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

<!--BACKPORT [{"author":{"name":"Chris
Earle","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-05T21:43:29Z","message":"[DataUsage][Serverless]
Fix AutoOps error message to drop \"agent\" reference (#202996)\n\n##
Summary\r\n\r\nThis removes the references to \"autoops agent\" in the
error message if\r\nthe request fails, as it has nothing to do with any
agent.\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies following
conditions. \r\n\r\nReviewers should verify this PR satisfies this list
as well.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] This was checked for breaking HTTP API changes, and any
breaking\r\nchanges have been approved by the breaking-change committee.
The\r\n`release_note:breaking` label should be applied in these
situations.\r\n- [x] The PR description includes the appropriate Release
Notes section,\r\nand the correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n###
Identify risks\r\n\r\nNo. None of the error messages are exported, so
they cannot be misused\r\nin other
places.","sha":"82301e7454c43392d3aac04f9f3d8f64d52c6622","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","ci:build-serverless-image","backport:version","v8.18.0"],"title":"[DataUsage][Serverless]
Fix AutoOps error message to drop \"agent\" reference
","number":202996,"url":"https://github.com/elastic/kibana/pull/202996","mergeCommit":{"message":"[DataUsage][Serverless]
Fix AutoOps error message to drop \"agent\" reference (#202996)\n\n##
Summary\r\n\r\nThis removes the references to \"autoops agent\" in the
error message if\r\nthe request fails, as it has nothing to do with any
agent.\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies following
conditions. \r\n\r\nReviewers should verify this PR satisfies this list
as well.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] This was checked for breaking HTTP API changes, and any
breaking\r\nchanges have been approved by the breaking-change committee.
The\r\n`release_note:breaking` label should be applied in these
situations.\r\n- [x] The PR description includes the appropriate Release
Notes section,\r\nand the correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n###
Identify risks\r\n\r\nNo. None of the error messages are exported, so
they cannot be misused\r\nin other
places.","sha":"82301e7454c43392d3aac04f9f3d8f64d52c6622"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/202996","number":202996,"mergeCommit":{"message":"[DataUsage][Serverless]
Fix AutoOps error message to drop \"agent\" reference (#202996)\n\n##
Summary\r\n\r\nThis removes the references to \"autoops agent\" in the
error message if\r\nthe request fails, as it has nothing to do with any
agent.\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies following
conditions. \r\n\r\nReviewers should verify this PR satisfies this list
as well.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] This was checked for breaking HTTP API changes, and any
breaking\r\nchanges have been approved by the breaking-change committee.
The\r\n`release_note:breaking` label should be applied in these
situations.\r\n- [x] The PR description includes the appropriate Release
Notes section,\r\nand the correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n###
Identify risks\r\n\r\nNo. None of the error messages are exported, so
they cannot be misused\r\nin other
places.","sha":"82301e7454c43392d3aac04f9f3d8f64d52c6622"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Chris Earle <[email protected]>
  • Loading branch information
kibanamachine and pickypg authored Dec 5, 2024
1 parent e3f51cd commit e128dfc
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions x-pack/plugins/data_usage/server/services/autoops_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import { AutoOpsConfig } from '../types';
import { AutoOpsError } from './errors';
import { appContextService } from './app_context';

const AGENT_CREATION_FAILED_ERROR = 'AutoOps API could not create the autoops agent';
const AUTO_OPS_AGENT_CREATION_PREFIX = '[AutoOps API] Creating autoops agent failed';
const AUTO_OPS_REQUEST_FAILED_PREFIX = '[AutoOps API] Request failed';
const AUTO_OPS_MISSING_CONFIG_ERROR = 'Missing autoops configuration';

const getAutoOpsAPIRequestUrl = (url?: string, projectId?: string): string =>
Expand Down Expand Up @@ -120,7 +119,7 @@ export class AutoOpsAPIService {
(error: Error | AxiosError) => {
if (!axios.isAxiosError(error)) {
this.logger.error(
`${AUTO_OPS_AGENT_CREATION_PREFIX} with an error ${error} ${requestConfigDebugStatus}`,
`${AUTO_OPS_REQUEST_FAILED_PREFIX} with an error ${error}, request config: ${requestConfigDebugStatus}`,
errorMetadataWithRequestConfig
);
throw new AutoOpsError(withRequestIdMessage(error.message));
Expand All @@ -131,9 +130,11 @@ export class AutoOpsAPIService {
if (error.response) {
// The request was made and the server responded with a status code and error data
this.logger.error(
`${AUTO_OPS_AGENT_CREATION_PREFIX} because the AutoOps API responded with a status code that falls out of the range of 2xx: ${JSON.stringify(
`${AUTO_OPS_REQUEST_FAILED_PREFIX} because the AutoOps API responded with a status code that falls out of the range of 2xx: ${JSON.stringify(
error.response.status
)}} ${JSON.stringify(error.response.data)}} ${requestConfigDebugStatus}`,
)}} ${JSON.stringify(
error.response.data
)}}, request config: ${requestConfigDebugStatus}`,
{
...errorMetadataWithRequestConfig,
http: {
Expand All @@ -145,22 +146,22 @@ export class AutoOpsAPIService {
},
}
);
throw new AutoOpsError(withRequestIdMessage(AGENT_CREATION_FAILED_ERROR));
throw new AutoOpsError(withRequestIdMessage(AUTO_OPS_REQUEST_FAILED_PREFIX));
} else if (error.request) {
// The request was made but no response was received
this.logger.error(
`${AUTO_OPS_AGENT_CREATION_PREFIX} while sending the request to the AutoOps API: ${errorLogCodeCause} ${requestConfigDebugStatus}`,
`${AUTO_OPS_REQUEST_FAILED_PREFIX} while sending the request to the AutoOps API: ${errorLogCodeCause}, request config: ${requestConfigDebugStatus}`,
errorMetadataWithRequestConfig
);
throw new AutoOpsError(withRequestIdMessage(`no response received from the AutoOps API`));
} else {
// Something happened in setting up the request that triggered an Error
this.logger.error(
`${AUTO_OPS_AGENT_CREATION_PREFIX} to be created ${errorLogCodeCause} ${requestConfigDebugStatus} ${error.toJSON()}`,
`${AUTO_OPS_REQUEST_FAILED_PREFIX} with ${errorLogCodeCause}, request config: ${requestConfigDebugStatus}, error: ${error.toJSON()}`,
errorMetadataWithRequestConfig
);
throw new AutoOpsError(
withRequestIdMessage(`${AGENT_CREATION_FAILED_ERROR}, ${error.message}`)
withRequestIdMessage(`${AUTO_OPS_REQUEST_FAILED_PREFIX}, ${error.message}`)
);
}
}
Expand Down

0 comments on commit e128dfc

Please sign in to comment.