@nrwl/nx-cloud 14.0.5 → 14.0.6-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.d.ts +6 -0
- package/lib/core/api/error-reporter.api.js +36 -0
- package/lib/core/api/error-reporter.api.js.map +1 -0
- package/lib/core/api/run-group.api.js +65 -1
- package/lib/core/file-storage/file-storage.d.ts +4 -1
- package/lib/core/file-storage/file-storage.js +23 -5
- package/lib/core/file-storage/file-storage.js.map +1 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +141 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +169 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js.map +1 -1
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +113 -1
- package/lib/core/runners/cloud-enabled/cloud-run.api.d.ts +1 -0
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +166 -1
- package/lib/core/runners/cloud-enabled/cloud-run.api.js.map +1 -1
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +79 -1
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +240 -1
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +130 -1
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +309 -1
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1,113 @@
|
|
|
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) {
|
|
17
|
+
this.messages = messages;
|
|
18
|
+
this.api = api;
|
|
19
|
+
this.runContext = runContext;
|
|
20
|
+
this.fileStorage = fileStorage;
|
|
21
|
+
this.storeRequests = [];
|
|
22
|
+
}
|
|
23
|
+
retrieve(hash, cacheDirectory) {
|
|
24
|
+
var _a;
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
if (this.messages.cacheError)
|
|
27
|
+
return false;
|
|
28
|
+
const hashUrls = yield this.hashUrls(hash);
|
|
29
|
+
if (!hashUrls || !hashUrls.get) {
|
|
30
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
31
|
+
output.note({ title: `Nx Cloud: Cache miss ${hash}.` });
|
|
32
|
+
}
|
|
33
|
+
this.runContext.statuses[hash] = 'cache-miss';
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
yield this.fileStorage.retrieve(hash, hashUrls.get, cacheDirectory);
|
|
38
|
+
this.runContext.statuses[hash] = 'remote-cache-hit';
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
catch (ee) {
|
|
42
|
+
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
|
|
43
|
+
if (e.response && e.response.status === 404) {
|
|
44
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
45
|
+
output.note({ title: `Nx Cloud: Cache miss ${hash}. Status 404.` });
|
|
46
|
+
}
|
|
47
|
+
// cache miss. print nothing
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
|
|
51
|
+
}
|
|
52
|
+
this.runContext.statuses[hash] = 'cache-miss';
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
store(hash, cacheDirectory) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
if (this.messages.cacheError)
|
|
60
|
+
return false;
|
|
61
|
+
const res = Promise.resolve().then(() => __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
var _a;
|
|
63
|
+
const hashUrls = yield this.hashUrls(hash);
|
|
64
|
+
if (!hashUrls)
|
|
65
|
+
return false;
|
|
66
|
+
if (!hashUrls.put) {
|
|
67
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
68
|
+
output.note({
|
|
69
|
+
title: `Nx Cloud: Skipping storing ${hash}. Read only token is used.`,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
yield this.fileStorage.store(hash, hashUrls.put, cacheDirectory);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
catch (ee) {
|
|
79
|
+
const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
|
|
80
|
+
this.messages.cacheError = this.messages.extractErrorMessage(e, 'storage');
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}));
|
|
84
|
+
this.storeRequests.push(res);
|
|
85
|
+
return res;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
hashUrls(hash) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
if (hash in this.runContext.requests) {
|
|
91
|
+
return (yield this.runContext.requests[hash])[hash];
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
const scheduledTaskHashesWithoutRequests = this.runContext.scheduledTasks
|
|
95
|
+
.filter((t) => !this.runContext.requests[t.hash])
|
|
96
|
+
.map((t) => t.hash);
|
|
97
|
+
if (scheduledTaskHashesWithoutRequests.indexOf(hash) === -1) {
|
|
98
|
+
scheduledTaskHashesWithoutRequests.push(hash);
|
|
99
|
+
}
|
|
100
|
+
const request = this.api.startRun(environment_1.NX_CLOUD_DISTRIBUTED_EXECUTION_ID, scheduledTaskHashesWithoutRequests);
|
|
101
|
+
scheduledTaskHashesWithoutRequests.forEach((taskHash) => {
|
|
102
|
+
this.runContext.requests[taskHash] = request;
|
|
103
|
+
});
|
|
104
|
+
return (yield request)[hash];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
waitForStoreRequestsToComplete() {
|
|
109
|
+
return Promise.all(this.storeRequests).then((r) => r.reduce((a, b) => a && b, true));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.CloudRemoteCache = CloudRemoteCache;
|
|
113
|
+
//# sourceMappingURL=cloud-remote-cache.js.map
|
|
@@ -12,6 +12,7 @@ export declare class CloudRunApi {
|
|
|
12
12
|
private apiAxiosInstance;
|
|
13
13
|
constructor(messages: MessageReporter, runContext: RunContext, options: CloudTaskRunnerOptions, machineInfo: MachineInfo);
|
|
14
14
|
startRun(distributedExecutionId: string | undefined, hashes: string[]): Promise<CacheUrls>;
|
|
15
|
+
private createReqBody;
|
|
15
16
|
endRun(run: RunData, tasks: TaskExecution[]): Promise<boolean>;
|
|
16
17
|
private nxCloudVersion;
|
|
17
18
|
}
|
|
@@ -1 +1,166 @@
|
|
|
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 { output } = require('../../../utilities/nx-imports');
|
|
20
|
+
class CloudRunApi {
|
|
21
|
+
constructor(messages, runContext, options, machineInfo) {
|
|
22
|
+
this.messages = messages;
|
|
23
|
+
this.runContext = runContext;
|
|
24
|
+
this.machineInfo = machineInfo;
|
|
25
|
+
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
|
|
26
|
+
}
|
|
27
|
+
startRun(distributedExecutionId, hashes) {
|
|
28
|
+
var _a;
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const recorder = (0, metric_logger_1.createMetricRecorder)('startRun');
|
|
31
|
+
try {
|
|
32
|
+
const request = {
|
|
33
|
+
meta: {
|
|
34
|
+
nxCloudVersion: this.nxCloudVersion(),
|
|
35
|
+
},
|
|
36
|
+
branch: (0, environment_1.getBranch)(),
|
|
37
|
+
runGroup: (0, environment_1.getRunGroup)(),
|
|
38
|
+
distributedExecutionId,
|
|
39
|
+
hashes,
|
|
40
|
+
};
|
|
41
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
42
|
+
output.note({
|
|
43
|
+
title: 'RunStart',
|
|
44
|
+
bodyLines: ['\n' + JSON.stringify(request, null, 2)],
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/start', request));
|
|
48
|
+
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
49
|
+
if (resp.data && resp.data.message) {
|
|
50
|
+
this.messages.message = resp.data.message;
|
|
51
|
+
}
|
|
52
|
+
if (!resp.data || !resp.data.urls) {
|
|
53
|
+
this.messages.apiError = `Invalid Nx Cloud response: ${JSON.stringify(resp.data)}`;
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
return resp.data.urls;
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
60
|
+
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
61
|
+
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
62
|
+
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
createReqBody(run, tasks) {
|
|
68
|
+
const uncompressedReqBody = {
|
|
69
|
+
meta: {
|
|
70
|
+
nxCloudVersion: this.nxCloudVersion(),
|
|
71
|
+
},
|
|
72
|
+
tasks,
|
|
73
|
+
run: run,
|
|
74
|
+
machineInfo: this.machineInfo,
|
|
75
|
+
};
|
|
76
|
+
return JSON.stringify(uncompressedReqBody);
|
|
77
|
+
}
|
|
78
|
+
endRun(run, tasks) {
|
|
79
|
+
var _a, _b;
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
// API is not working, don't make the end request
|
|
82
|
+
if (this.messages.apiError)
|
|
83
|
+
return false;
|
|
84
|
+
let uncompressedBodyString = this.createReqBody(run, tasks);
|
|
85
|
+
// if the req body is > 20mb, remove hashDetails
|
|
86
|
+
if (uncompressedBodyString.length > 20 * 1000 * 1000) {
|
|
87
|
+
uncompressedBodyString = this.createReqBody(run, tasks.map((t) => (Object.assign(Object.assign({}, t), { hashDetails: undefined }))));
|
|
88
|
+
}
|
|
89
|
+
const uncompressedBuffer = Buffer.from(uncompressedBodyString);
|
|
90
|
+
const compressedBuffer = yield (0, util_1.promisify)(zlib_1.gzip)(uncompressedBuffer);
|
|
91
|
+
const recorder = (0, metric_logger_1.createMetricRecorder)('endRun');
|
|
92
|
+
try {
|
|
93
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
94
|
+
const t = tasks.map((tt) => {
|
|
95
|
+
return Object.assign(Object.assign({}, tt), { terminalOutput: tt.terminalOutput
|
|
96
|
+
? `${tt.terminalOutput.slice(0, 20)}...`
|
|
97
|
+
: undefined });
|
|
98
|
+
});
|
|
99
|
+
output.note({
|
|
100
|
+
title: 'RunEnd. Completed tasks',
|
|
101
|
+
bodyLines: ['\n' + JSON.stringify(t, null, 2)],
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/end', compressedBuffer, {
|
|
105
|
+
headers: Object.assign(Object.assign({}, this.apiAxiosInstance.defaults.headers), { 'Content-Encoding': 'gzip', 'Content-Type': 'application/octet-stream' }),
|
|
106
|
+
}));
|
|
107
|
+
if (resp) {
|
|
108
|
+
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
109
|
+
if (resp.data && resp.data.runUrl && resp.data.status === 'success') {
|
|
110
|
+
this.runContext.runUrl = resp.data.runUrl;
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
if (resp.data && resp.data.status) {
|
|
114
|
+
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data.message)}`;
|
|
115
|
+
}
|
|
116
|
+
else if (resp.data && typeof resp.data === 'string') {
|
|
117
|
+
if (resp.data !== 'success') {
|
|
118
|
+
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
|
|
123
|
+
}
|
|
124
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
125
|
+
output.note({
|
|
126
|
+
title: 'Invalid end run response',
|
|
127
|
+
bodyLines: [JSON.stringify(resp.data, null, 2)],
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
output.error({
|
|
133
|
+
title: 'Nx Cloud: Unknown Error Occurred',
|
|
134
|
+
bodyLines: [
|
|
135
|
+
'Run completion responded with `undefined`.',
|
|
136
|
+
'Run Details:',
|
|
137
|
+
JSON.stringify(run, null, 2),
|
|
138
|
+
'Stack Trace:',
|
|
139
|
+
JSON.stringify(new Error().stack, null, 2),
|
|
140
|
+
],
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
catch (ee) {
|
|
146
|
+
recorder.recordMetric(((_a = ee === null || ee === void 0 ? void 0 : ee.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
147
|
+
? (0, metric_logger_1.mapRespToPerfEntry)(ee.axiosException.response)
|
|
148
|
+
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
149
|
+
const e = (_b = ee.axiosException) !== null && _b !== void 0 ? _b : ee;
|
|
150
|
+
this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
nxCloudVersion() {
|
|
156
|
+
try {
|
|
157
|
+
const v = JSON.parse((0, fs_1.readFileSync)(`package.json`).toString());
|
|
158
|
+
return v.devDependencies['@nrwl/nx-cloud'];
|
|
159
|
+
}
|
|
160
|
+
catch (e) {
|
|
161
|
+
return 'unknown';
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.CloudRunApi = CloudRunApi;
|
|
166
|
+
//# sourceMappingURL=cloud-run.api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud-run.api.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/lib/core/runners/cloud-enabled/cloud-run.api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,oDAGkC;AAClC,gEAIwC;AAIxC,2BAAkC;AAClC,+BAA4B;AAC5B,+BAAiC;AACjC,oEAI0C;
|
|
1
|
+
{"version":3,"file":"cloud-run.api.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/lib/core/runners/cloud-enabled/cloud-run.api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,oDAGkC;AAClC,gEAIwC;AAIxC,2BAAkC;AAClC,+BAA4B;AAC5B,+BAAiC;AACjC,oEAI0C;AAE1C,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAE5D,MAAa,WAAW;IAGtB,YACmB,QAAyB,EACzB,UAAsB,EACvC,OAA+B,EACd,WAAwB;QAHxB,aAAQ,GAAR,QAAQ,CAAiB;QACzB,eAAU,GAAV,UAAU,CAAY;QAEtB,gBAAW,GAAX,WAAW,CAAa;QAEzC,IAAI,CAAC,gBAAgB,GAAG,IAAA,8BAAsB,EAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;IAEK,QAAQ,CACZ,sBAA0C,EAC1C,MAAgB;;;YAEhB,MAAM,QAAQ,GAAG,IAAA,oCAAoB,EAAC,UAAU,CAAC,CAAC;YAElD,IAAI;gBACF,MAAM,OAAO,GAAG;oBACd,IAAI,EAAE;wBACJ,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE;qBACtC;oBACD,MAAM,EAAE,IAAA,uBAAS,GAAE;oBACnB,QAAQ,EAAE,IAAA,yBAAW,GAAE;oBACvB,sBAAsB;oBACtB,MAAM;iBACP,CAAC;gBACF,IAAI,6BAAe,EAAE;oBACnB,MAAM,CAAC,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,KAAK,CAAC;aACd;;KACF;IAEO,cAAc;QACpB,IAAI;YACF,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC9D,OAAO,CAAC,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;SAC5C;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,SAAS,CAAC;SAClB;IACH,CAAC;CACF;AAtLD,kCAsLC"}
|
|
@@ -1 +1,79 @@
|
|
|
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, runGroup, agentName) {
|
|
19
|
+
this.runGroup = runGroup;
|
|
20
|
+
this.agentName = agentName;
|
|
21
|
+
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
|
|
22
|
+
}
|
|
23
|
+
tasks(executionId, statusCode, completedTasks) {
|
|
24
|
+
var _a;
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const recorder = (0, metric_logger_1.createMetricRecorder)('dtePollTasks');
|
|
27
|
+
try {
|
|
28
|
+
const res = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/tasks', {
|
|
29
|
+
runGroup: this.runGroup,
|
|
30
|
+
agentName: this.agentName,
|
|
31
|
+
executionId,
|
|
32
|
+
statusCode,
|
|
33
|
+
completedTasks,
|
|
34
|
+
}));
|
|
35
|
+
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(res));
|
|
36
|
+
return res.data;
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
40
|
+
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
41
|
+
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
42
|
+
throw e;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
completeRunGroupWithError(error) {
|
|
47
|
+
var _a;
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
50
|
+
output.note({
|
|
51
|
+
title: 'Completing run group with an error',
|
|
52
|
+
bodyLines: [`runGroup: ${this.runGroup}`, `error: ${error}`],
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup');
|
|
56
|
+
try {
|
|
57
|
+
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
|
|
58
|
+
runGroup: this.runGroup,
|
|
59
|
+
agentName: this.agentName,
|
|
60
|
+
criticalErrorMessage: error,
|
|
61
|
+
}));
|
|
62
|
+
if (environment_1.VERBOSE_LOGGING) {
|
|
63
|
+
output.note({
|
|
64
|
+
title: 'Completed run group with an error',
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
71
|
+
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
72
|
+
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
73
|
+
console.error(e);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.DistributedAgentApi = DistributedAgentApi;
|
|
79
|
+
//# sourceMappingURL=distributed-agent.api.js.map
|