mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
# Backport This will backport the following commits from `main` to `8.18`: - [Upgrade axios 1.8.3 in buildkite (#215656)](https://github.com/elastic/kibana/pull/215656) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Alex Szabo","email":"alex.szabo@elastic.co"},"sourceCommit":{"committedDate":"2025-03-25T14:05:37Z","message":"Upgrade axios 1.8.3 in buildkite (#215656)\n\n## Summary\nAccording to:\n\nhttps://buildkite.com/elastic/kibana-on-merge/builds/65027#0195ca29-b10a-4e20-b00f-c4fbe43689fa\n\n```\n\nAnnotate test failures error Request failed with status code 404 AxiosError: Request failed with status code 404\n--\n | at settle (/opt/buildkite-agent/builds/bk-agent-prod-gcp-1742853500882456889/elastic/kibana-on-merge/kibana/.buildkite/node_modules/axios/lib/core/settle.js:19:12)\n...\n | at async /opt/buildkite-agent/builds/bk-agent-prod-gcp-1742853500882456889/elastic/kibana-on-merge/kibana/.buildkite/scripts/lifecycle/annotate_test_failures.ts:14:5\n | HTTP Error 404/Not Found (https://api.buildkite.com/v2/organizations/elastic/pipelines/kibana-on-merge/builds/65027/artifacts?page=2&per_page=100) { message: 'Not Found' }\n\n```\nThis points to the client collecting all artifacts through traversing\nthe `next` links from Buildkite's API responses. It appears, Axios is\nnot happy about these absolute paths, even if the origin is the same.\n\nThis PR adjusts the next link parsing to relativize compared to a base\nurl.","sha":"115ec32eec93fde71632f34f914b222d44eb1bbe","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Operations","release_note:skip","backport:all-open","v9.1.0"],"title":"Upgrade axios 1.8.3 in buildkite","number":215656,"url":"https://github.com/elastic/kibana/pull/215656","mergeCommit":{"message":"Upgrade axios 1.8.3 in buildkite (#215656)\n\n## Summary\nAccording to:\n\nhttps://buildkite.com/elastic/kibana-on-merge/builds/65027#0195ca29-b10a-4e20-b00f-c4fbe43689fa\n\n```\n\nAnnotate test failures error Request failed with status code 404 AxiosError: Request failed with status code 404\n--\n | at settle (/opt/buildkite-agent/builds/bk-agent-prod-gcp-1742853500882456889/elastic/kibana-on-merge/kibana/.buildkite/node_modules/axios/lib/core/settle.js:19:12)\n...\n | at async /opt/buildkite-agent/builds/bk-agent-prod-gcp-1742853500882456889/elastic/kibana-on-merge/kibana/.buildkite/scripts/lifecycle/annotate_test_failures.ts:14:5\n | HTTP Error 404/Not Found (https://api.buildkite.com/v2/organizations/elastic/pipelines/kibana-on-merge/builds/65027/artifacts?page=2&per_page=100) { message: 'Not Found' }\n\n```\nThis points to the client collecting all artifacts through traversing\nthe `next` links from Buildkite's API responses. It appears, Axios is\nnot happy about these absolute paths, even if the origin is the same.\n\nThis PR adjusts the next link parsing to relativize compared to a base\nurl.","sha":"115ec32eec93fde71632f34f914b222d44eb1bbe"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/215656","number":215656,"mergeCommit":{"message":"Upgrade axios 1.8.3 in buildkite (#215656)\n\n## Summary\nAccording to:\n\nhttps://buildkite.com/elastic/kibana-on-merge/builds/65027#0195ca29-b10a-4e20-b00f-c4fbe43689fa\n\n```\n\nAnnotate test failures error Request failed with status code 404 AxiosError: Request failed with status code 404\n--\n | at settle (/opt/buildkite-agent/builds/bk-agent-prod-gcp-1742853500882456889/elastic/kibana-on-merge/kibana/.buildkite/node_modules/axios/lib/core/settle.js:19:12)\n...\n | at async /opt/buildkite-agent/builds/bk-agent-prod-gcp-1742853500882456889/elastic/kibana-on-merge/kibana/.buildkite/scripts/lifecycle/annotate_test_failures.ts:14:5\n | HTTP Error 404/Not Found (https://api.buildkite.com/v2/organizations/elastic/pipelines/kibana-on-merge/builds/65027/artifacts?page=2&per_page=100) { message: 'Not Found' }\n\n```\nThis points to the client collecting all artifacts through traversing\nthe `next` links from Buildkite's API responses. It appears, Axios is\nnot happy about these absolute paths, even if the origin is the same.\n\nThis PR adjusts the next link parsing to relativize compared to a base\nurl.","sha":"115ec32eec93fde71632f34f914b222d44eb1bbe"}}]}] BACKPORT--> Co-authored-by: Alex Szabo <alex.szabo@elastic.co>
This commit is contained in:
parent
3974859832
commit
7e32f9c6cc
3 changed files with 33 additions and 7 deletions
|
@ -161,18 +161,19 @@ export interface BuildkiteWaitStep {
|
|||
export class BuildkiteClient {
|
||||
http: AxiosInstance;
|
||||
exec: ExecType;
|
||||
baseUrl: string;
|
||||
|
||||
constructor(config: BuildkiteClientConfig = {}) {
|
||||
const BUILDKITE_BASE_URL =
|
||||
config.baseUrl ?? process.env.BUILDKITE_BASE_URL ?? 'https://api.buildkite.com';
|
||||
const BUILDKITE_TOKEN = config.token ?? process.env.BUILDKITE_TOKEN;
|
||||
|
||||
this.baseUrl = config.baseUrl ?? process.env.BUILDKITE_BASE_URL ?? 'https://api.buildkite.com';
|
||||
|
||||
// const BUILDKITE_AGENT_BASE_URL =
|
||||
// process.env.BUILDKITE_AGENT_BASE_URL || 'https://agent.buildkite.com/v3';
|
||||
// const BUILDKITE_AGENT_TOKEN = process.env.BUILDKITE_AGENT_TOKEN;
|
||||
|
||||
this.http = axios.create({
|
||||
baseURL: BUILDKITE_BASE_URL,
|
||||
baseURL: this.baseUrl,
|
||||
headers: {
|
||||
Authorization: `Bearer ${BUILDKITE_TOKEN}`,
|
||||
},
|
||||
|
@ -327,10 +328,10 @@ export class BuildkiteClient {
|
|||
const resp = await this.http.get(link);
|
||||
link = '';
|
||||
|
||||
artifacts.push(await resp.data);
|
||||
artifacts.push(resp.data);
|
||||
|
||||
if (resp.headers.link) {
|
||||
const result = parseLinkHeader(resp.headers.link as string);
|
||||
const result = parseLinkHeader(resp.headers.link as string, this.baseUrl);
|
||||
if (result?.next) {
|
||||
link = result.next;
|
||||
}
|
||||
|
|
|
@ -21,4 +21,16 @@ describe('parseLinkHeader', () => {
|
|||
next: 'https://api.buildkite.com/v2/organizations/elastic/agents?page=2&per_page=1',
|
||||
});
|
||||
});
|
||||
|
||||
it('should relativize url if a base is given', () => {
|
||||
const result = parseLinkHeader(
|
||||
'<https://api.buildkite.com/v2/organizations/elastic/agents?page=2&per_page=1>; rel="next", <https://api.buildkite.com/v2/organizations/elastic/agents?page=5&per_page=1>; rel="last"',
|
||||
'https://api.buildkite.com'
|
||||
);
|
||||
|
||||
expect(result).to.eql({
|
||||
last: '/v2/organizations/elastic/agents?page=5&per_page=1',
|
||||
next: '/v2/organizations/elastic/agents?page=2&per_page=1',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,7 +7,10 @@
|
|||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
export function parseLinkHeader(header: string): null | Record<string, string> {
|
||||
export function parseLinkHeader(
|
||||
header: string,
|
||||
relativeToBase?: string
|
||||
): null | Record<string, string> {
|
||||
if (!header) {
|
||||
return null;
|
||||
}
|
||||
|
@ -19,7 +22,17 @@ export function parseLinkHeader(header: string): null | Record<string, string> {
|
|||
const parts = entry.split(';', 2).map((p) => p.trim());
|
||||
const url = parts[0].slice(1, -1);
|
||||
const rel = parts[1].replace(/rel="?([^"]+)"?$/, '$1');
|
||||
parsed[rel] = url;
|
||||
|
||||
if (relativeToBase) {
|
||||
const urlObj = new URL(url);
|
||||
if (urlObj.origin === relativeToBase) {
|
||||
parsed[rel] = urlObj.pathname + urlObj.search;
|
||||
} else {
|
||||
parsed[rel] = url;
|
||||
}
|
||||
} else {
|
||||
parsed[rel] = url;
|
||||
}
|
||||
}
|
||||
|
||||
return parsed;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue