@nrwl/nx-cloud 15.3.5 → 15.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/api/error-reporter.api.js +36 -1
- package/lib/core/api/run-group.api.js +73 -1
- package/lib/core/file-storage/file-storage.js +4 -2
- package/lib/core/file-storage/file-storage.js.map +1 -1
- package/lib/core/models/cloud-task-runner-options.d.ts +1 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +93 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +320 -1
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +133 -1
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +174 -1
- package/lib/core/runners/cloud-enabled/id-generator.js +16 -1
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +93 -1
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +157 -1
- package/lib/core/runners/distributed-agent/execute-tasks.js +114 -1
- package/lib/core/runners/distributed-agent/invoke-tasks-using-nx-imperative-api.js +58 -1
- package/lib/core/runners/distributed-agent/invoke-tasks-using-run-many.js +97 -1
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +152 -1
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +118 -1
- package/lib/core/runners/distributed-execution/process-task.js +45 -1
- package/lib/core/runners/distributed-execution/process-tasks.js +67 -1
- package/lib/core/runners/distributed-execution/split-task-graph-into-stages.js +37 -1
- package/lib/core/runners/distributed-execution/task-graph-creator.js +100 -1
- package/lib/utilities/axios.js +8 -2
- package/lib/utilities/axios.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1,133 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CloudRemoteCache = void 0;
|
|
13
|
+
const environment_1 = require("../../../utilities/environment");
|
|
14
|
+
const { output } = require('../../../utilities/nx-imports');
|
|
15
|
+
class CloudRemoteCache {
|
|
16
|
+
constructor(messages, api, runContext, fileStorage, distributedExecutionId, storeInCurrentProcess) {
|
|
17
|
+
this.messages = messages;
|
|
18
|
+
this.api = api;
|
|
19
|
+
this.runContext = runContext;
|
|
20
|
+
this.fileStorage = fileStorage;
|
|
21
|
+
this.distributedExecutionId = distributedExecutionId;
|
|
22
|
+
this.storeInCurrentProcess = storeInCurrentProcess;
|
|
23
|
+
this.storeRequests = [];
|
|
24
|
+
this.delayedStoreRequests = [];
|
|
25
|
+
}
|
|
26
|
+
retrieve(hash, cacheDirectory) {
|
|
27
|
+
var _a;
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
if (this.messages.cacheError)
|
|
30
|
+
return false;
|
|
31
|
+
const hashUrls = yield this.hashUrls(hash);
|
|
32
|
+
if (!hashUrls || !hashUrls.get) {
|
|
33
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
34
|
+
output.note({ title: `Nx Cloud: Cache miss ${hash}.` });
|
|
35
|
+
}
|
|
36
|
+
this.runContext.statuses[hash] = 'cache-miss';
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
yield this.fileStorage.retrieve(hash, hashUrls.get, cacheDirectory);
|
|
41
|
+
this.runContext.statuses[hash] = 'remote-cache-hit';
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
catch (ee) {
|
|
45
|
+
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
|
|
46
|
+
// TODO: vsavkin remove this handling Oct 2023
|
|
47
|
+
// 404 indicates that something is broken, but older versions
|
|
48
|
+
// of the api can result in such errors
|
|
49
|
+
// we ignore them for now
|
|
50
|
+
if (e.response && e.response.status === 404) {
|
|
51
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
52
|
+
output.note({ title: `Nx Cloud: Cache miss ${hash}. Status 404.` });
|
|
53
|
+
}
|
|
54
|
+
// cache miss. print nothing
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
|
|
58
|
+
}
|
|
59
|
+
this.runContext.statuses[hash] = 'cache-miss';
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
store(hash, cacheDirectory) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
if (this.messages.cacheError)
|
|
67
|
+
return false;
|
|
68
|
+
const res = Promise.resolve().then(() => __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
var _a;
|
|
70
|
+
const hashUrls = yield this.hashUrls(hash);
|
|
71
|
+
if (!hashUrls)
|
|
72
|
+
return false;
|
|
73
|
+
if (!hashUrls.put) {
|
|
74
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
75
|
+
output.note({
|
|
76
|
+
title: `Nx Cloud: Skipping storing ${hash}.`,
|
|
77
|
+
bodyLines: [
|
|
78
|
+
`There are several reasons why this can happen.`,
|
|
79
|
+
`Maybe you are using a read-only token or the artifact has already being uploaded.`,
|
|
80
|
+
],
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
if (!this.storeInCurrentProcess) {
|
|
86
|
+
this.delayedStoreRequests.push({ hash: hash, url: hashUrls.put });
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
yield this.fileStorage.store(hash, hashUrls.put, cacheDirectory);
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
catch (ee) {
|
|
94
|
+
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
|
|
95
|
+
this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}));
|
|
99
|
+
this.storeRequests.push(res);
|
|
100
|
+
return res;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
hashUrls(hash) {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
if (hash in this.runContext.requests) {
|
|
106
|
+
return (yield this.runContext.requests[hash])[hash];
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
const scheduledTaskHashesWithoutRequests = this.runContext.scheduledTasks
|
|
110
|
+
.filter((t) => !this.runContext.requests[t.hash])
|
|
111
|
+
.map((t) => t.hash);
|
|
112
|
+
if (scheduledTaskHashesWithoutRequests.indexOf(hash) === -1) {
|
|
113
|
+
scheduledTaskHashesWithoutRequests.push(hash);
|
|
114
|
+
}
|
|
115
|
+
const request = this.api.startRun(this.distributedExecutionId, scheduledTaskHashesWithoutRequests);
|
|
116
|
+
scheduledTaskHashesWithoutRequests.forEach((taskHash) => {
|
|
117
|
+
this.runContext.requests[taskHash] = request;
|
|
118
|
+
});
|
|
119
|
+
return (yield request)[hash];
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
waitForStoreRequestsToComplete() {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
const res = yield Promise.all(this.storeRequests).then((r) => r.reduce((a, b) => a && b, true));
|
|
126
|
+
if (!res) {
|
|
127
|
+
throw new Error(`Error when storing artifacts`);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.CloudRemoteCache = CloudRemoteCache;
|
|
133
|
+
//# sourceMappingURL=cloud-remote-cache.js.map
|
|
@@ -1 +1,174 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CloudRunApi = void 0;
|
|
13
|
+
const axios_1 = require("../../../utilities/axios");
|
|
14
|
+
const environment_1 = require("../../../utilities/environment");
|
|
15
|
+
const fs_1 = require("fs");
|
|
16
|
+
const zlib_1 = require("zlib");
|
|
17
|
+
const util_1 = require("util");
|
|
18
|
+
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
19
|
+
const is_private_cloud_1 = require("../../../utilities/is-private-cloud");
|
|
20
|
+
const { output } = require('../../../utilities/nx-imports');
|
|
21
|
+
class CloudRunApi {
|
|
22
|
+
constructor(messages, runContext, options, machineInfo) {
|
|
23
|
+
this.messages = messages;
|
|
24
|
+
this.runContext = runContext;
|
|
25
|
+
this.machineInfo = machineInfo;
|
|
26
|
+
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
|
|
27
|
+
}
|
|
28
|
+
startRun(distributedExecutionId, hashes) {
|
|
29
|
+
var _a;
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
// API is not working, don't make the end request
|
|
32
|
+
if (this.messages.apiError)
|
|
33
|
+
return {};
|
|
34
|
+
const recorder = (0, metric_logger_1.createMetricRecorder)('startRun');
|
|
35
|
+
try {
|
|
36
|
+
const request = {
|
|
37
|
+
meta: {
|
|
38
|
+
nxCloudVersion: this.nxCloudVersion(),
|
|
39
|
+
},
|
|
40
|
+
branch: (0, environment_1.getBranch)(),
|
|
41
|
+
runGroup: (0, environment_1.getRunGroup)(),
|
|
42
|
+
ciExecutionId: (0, environment_1.getCIExecutionId)(),
|
|
43
|
+
ciExecutionEnv: (0, environment_1.getCIExecutionEnv)(),
|
|
44
|
+
distributedExecutionId,
|
|
45
|
+
hashes,
|
|
46
|
+
};
|
|
47
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
48
|
+
output.note({
|
|
49
|
+
title: 'RunStart',
|
|
50
|
+
bodyLines: ['\n' + JSON.stringify(request, null, 2)],
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const resp = yield (0, axios_1.printDuration)('RunStart duration', () => (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/start', request)));
|
|
54
|
+
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
55
|
+
if (resp.data && resp.data.message) {
|
|
56
|
+
this.messages.message = resp.data.message;
|
|
57
|
+
}
|
|
58
|
+
if (!resp.data || !resp.data.urls) {
|
|
59
|
+
this.messages.apiError = `Invalid Nx Cloud response: ${JSON.stringify(resp.data)}`;
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
return resp.data.urls;
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
66
|
+
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
67
|
+
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
68
|
+
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
|
|
69
|
+
return {};
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
createReqBody(run, tasks, ciExecutionContext, linkId) {
|
|
74
|
+
if ((0, is_private_cloud_1.isConnectedToPrivateCloud)()) {
|
|
75
|
+
for (let t of tasks) {
|
|
76
|
+
delete t.uploadedToStorage;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const uncompressedReqBody = Object.assign(Object.assign({ meta: {
|
|
80
|
+
nxCloudVersion: this.nxCloudVersion(),
|
|
81
|
+
}, tasks,
|
|
82
|
+
run,
|
|
83
|
+
linkId }, ((0, is_private_cloud_1.isConnectedToPrivateCloud)() ? {} : ciExecutionContext)), { machineInfo: this.machineInfo });
|
|
84
|
+
return JSON.stringify(uncompressedReqBody);
|
|
85
|
+
}
|
|
86
|
+
endRun(run, tasks, ciExecutionContext, linkId) {
|
|
87
|
+
var _a, _b;
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
// API is not working, don't make the end request
|
|
90
|
+
if (this.messages.apiError)
|
|
91
|
+
return false;
|
|
92
|
+
let uncompressedBodyString = this.createReqBody(run, tasks, ciExecutionContext, linkId);
|
|
93
|
+
// if the req body is > 20mb, remove hashDetails
|
|
94
|
+
if (uncompressedBodyString.length > 20 * 1000 * 1000) {
|
|
95
|
+
uncompressedBodyString = this.createReqBody(run, tasks.map((t) => (Object.assign(Object.assign({}, t), { hashDetails: undefined }))), ciExecutionContext, linkId);
|
|
96
|
+
}
|
|
97
|
+
const uncompressedBuffer = Buffer.from(uncompressedBodyString);
|
|
98
|
+
const compressedBuffer = yield (0, util_1.promisify)(zlib_1.gzip)(uncompressedBuffer);
|
|
99
|
+
const recorder = (0, metric_logger_1.createMetricRecorder)('endRun');
|
|
100
|
+
try {
|
|
101
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
102
|
+
const t = tasks.map((tt) => {
|
|
103
|
+
return Object.assign(Object.assign({}, tt), { terminalOutput: tt.terminalOutput
|
|
104
|
+
? `${tt.terminalOutput.slice(0, 20)}...`
|
|
105
|
+
: undefined });
|
|
106
|
+
});
|
|
107
|
+
output.note({
|
|
108
|
+
title: 'RunEnd. Completed tasks',
|
|
109
|
+
bodyLines: ['\n' + JSON.stringify(t, null, 2)],
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
const resp = yield (0, axios_1.printDuration)('RunEnd duration', () => (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/end', compressedBuffer, {
|
|
113
|
+
headers: Object.assign(Object.assign({}, this.apiAxiosInstance.defaults.headers), { 'Content-Encoding': 'gzip', 'Content-Type': 'application/octet-stream' }),
|
|
114
|
+
})));
|
|
115
|
+
if (resp) {
|
|
116
|
+
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
117
|
+
if (resp.data && resp.data.runUrl && resp.data.status === 'success') {
|
|
118
|
+
this.runContext.runUrl = resp.data.runUrl;
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
if (resp.data && resp.data.status) {
|
|
122
|
+
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data.message)}`;
|
|
123
|
+
}
|
|
124
|
+
else if (resp.data && typeof resp.data === 'string') {
|
|
125
|
+
if (resp.data !== 'success') {
|
|
126
|
+
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
|
|
131
|
+
}
|
|
132
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
133
|
+
output.note({
|
|
134
|
+
title: 'Invalid end run response',
|
|
135
|
+
bodyLines: [JSON.stringify(resp.data, null, 2)],
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
output.error({
|
|
141
|
+
title: 'Nx Cloud: Unknown Error Occurred',
|
|
142
|
+
bodyLines: [
|
|
143
|
+
'Run completion responded with `undefined`.',
|
|
144
|
+
'Run Details:',
|
|
145
|
+
JSON.stringify(run, null, 2),
|
|
146
|
+
'Stack Trace:',
|
|
147
|
+
JSON.stringify(new Error().stack, null, 2),
|
|
148
|
+
],
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
catch (ee) {
|
|
154
|
+
recorder.recordMetric(((_a = ee === null || ee === void 0 ? void 0 : ee.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
155
|
+
? (0, metric_logger_1.mapRespToPerfEntry)(ee.axiosException.response)
|
|
156
|
+
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
157
|
+
const e = (_b = ee.axiosException) !== null && _b !== void 0 ? _b : ee;
|
|
158
|
+
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
nxCloudVersion() {
|
|
164
|
+
try {
|
|
165
|
+
const v = JSON.parse((0, fs_1.readFileSync)(`package.json`).toString());
|
|
166
|
+
return v.devDependencies['@nrwl/nx-cloud'];
|
|
167
|
+
}
|
|
168
|
+
catch (e) {
|
|
169
|
+
return 'unknown';
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
exports.CloudRunApi = CloudRunApi;
|
|
174
|
+
//# sourceMappingURL=cloud-run.api.js.map
|
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateUniqueLinkId = void 0;
|
|
4
|
+
const upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
5
|
+
const digits = '0123456789';
|
|
6
|
+
const lower = upper.toLowerCase();
|
|
7
|
+
const alphanum = upper + lower + digits;
|
|
8
|
+
function generateUniqueLinkId() {
|
|
9
|
+
let res = '';
|
|
10
|
+
for (let i = 0; i < 10; ++i) {
|
|
11
|
+
res += alphanum[Math.floor(Math.random() * alphanum.length)];
|
|
12
|
+
}
|
|
13
|
+
return res;
|
|
14
|
+
}
|
|
15
|
+
exports.generateUniqueLinkId = generateUniqueLinkId;
|
|
16
|
+
//# sourceMappingURL=id-generator.js.map
|
|
@@ -1 +1,93 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DistributedAgentApi = void 0;
|
|
13
|
+
const axios_1 = require("../../../utilities/axios");
|
|
14
|
+
const environment_1 = require("../../../utilities/environment");
|
|
15
|
+
const metric_logger_1 = require("../../../utilities/metric-logger");
|
|
16
|
+
const { output } = require('../../../utilities/nx-imports');
|
|
17
|
+
class DistributedAgentApi {
|
|
18
|
+
constructor(options, branch, runGroup, ciExecutionId, ciExecutionEnv, agentName) {
|
|
19
|
+
this.branch = branch;
|
|
20
|
+
this.runGroup = runGroup;
|
|
21
|
+
this.ciExecutionId = ciExecutionId;
|
|
22
|
+
this.ciExecutionEnv = ciExecutionEnv;
|
|
23
|
+
this.agentName = agentName;
|
|
24
|
+
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
|
|
25
|
+
}
|
|
26
|
+
tasks(executionId, statusCode, completedTasks, targets) {
|
|
27
|
+
var _a;
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const recorder = (0, metric_logger_1.createMetricRecorder)('dtePollTasks');
|
|
30
|
+
try {
|
|
31
|
+
const res = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/tasks', {
|
|
32
|
+
runGroup: this.runGroup,
|
|
33
|
+
ciExecutionId: this.ciExecutionId,
|
|
34
|
+
ciExecutionEnv: this.ciExecutionEnv,
|
|
35
|
+
agentName: this.agentName,
|
|
36
|
+
executionId,
|
|
37
|
+
statusCode,
|
|
38
|
+
completedTasks,
|
|
39
|
+
targets,
|
|
40
|
+
}));
|
|
41
|
+
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(res));
|
|
42
|
+
return res.data;
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
46
|
+
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
47
|
+
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
48
|
+
throw e;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
completeRunGroupWithError(error) {
|
|
53
|
+
var _a;
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
56
|
+
output.note({
|
|
57
|
+
title: 'Completing with an error',
|
|
58
|
+
bodyLines: [
|
|
59
|
+
`ciExecutionId: ${this.ciExecutionId}`,
|
|
60
|
+
`ciExecutionEnv: ${this.ciExecutionEnv}`,
|
|
61
|
+
`runGroup: ${this.runGroup}`,
|
|
62
|
+
`error: ${error}`,
|
|
63
|
+
],
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup');
|
|
67
|
+
try {
|
|
68
|
+
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
|
|
69
|
+
branch: this.branch,
|
|
70
|
+
runGroup: this.runGroup,
|
|
71
|
+
ciExecutionId: this.ciExecutionId,
|
|
72
|
+
ciExecutionEnv: this.ciExecutionEnv,
|
|
73
|
+
agentName: this.agentName,
|
|
74
|
+
criticalErrorMessage: error,
|
|
75
|
+
}));
|
|
76
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
77
|
+
output.note({
|
|
78
|
+
title: 'Completed run group with an error',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
85
|
+
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
86
|
+
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
87
|
+
console.error(e);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.DistributedAgentApi = DistributedAgentApi;
|
|
93
|
+
//# sourceMappingURL=distributed-agent.api.js.map
|