@nrwl/nx-cloud 14.4.0 → 14.4.2-beta.2
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/bin/nx-cloud.js +3 -3
- package/bin/nx-cloud.js.map +1 -1
- package/lib/core/api/error-reporter.api.js +36 -1
- package/lib/core/api/run-group.api.d.ts +1 -1
- package/lib/core/api/run-group.api.js +68 -1
- package/lib/core/api/run-group.api.js.map +1 -1
- package/lib/core/commands/start-ci-run.js +7 -1
- package/lib/core/commands/start-ci-run.js.map +1 -1
- package/lib/core/models/distributed-agent/tasks-api-response.model.d.ts +1 -0
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +156 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +201 -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.js +166 -1
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +79 -1
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +263 -1
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js.map +1 -1
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +143 -1
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +220 -1
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js.map +1 -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 +77 -1
- package/lib/utilities/create-unchanged-value-timeout.d.ts +4 -0
- package/lib/utilities/{create-no-new-messages-timeout.js → create-unchanged-value-timeout.js} +6 -7
- package/lib/utilities/create-unchanged-value-timeout.js.map +1 -0
- package/lib/utilities/environment.d.ts +1 -0
- package/lib/utilities/environment.js +5 -1
- package/lib/utilities/environment.js.map +1 -1
- package/package.json +3 -2
- package/lib/utilities/create-no-new-messages-timeout.d.ts +0 -1
- package/lib/utilities/create-no-new-messages-timeout.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud-enabled.runner.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/lib/core/runners/cloud-enabled/cloud-enabled.runner.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,6EAAyE;AACzE,iFAA2E;AAC3E,+EAA2E;AAC3E,yEAAmE;AACnE,kEAA8D;AAC9D,sEAAkE;AAClE,gEAWwC;AACxC,6DAAwD;AACxD,mDAA8C;AAE9C,2BAAmC;AACnC,6BAA6B;AAC7B,oEAAoE;AACpE,qEAAgE;
|
|
1
|
+
{"version":3,"file":"cloud-enabled.runner.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-packages/nx-cloud/lib/core/runners/cloud-enabled/cloud-enabled.runner.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,6EAAyE;AACzE,iFAA2E;AAC3E,+EAA2E;AAC3E,yEAAmE;AACnE,kEAA8D;AAC9D,sEAAkE;AAClE,gEAWwC;AACxC,6DAAwD;AACxD,mDAA8C;AAE9C,2BAAmC;AACnC,6BAA6B;AAC7B,oEAAoE;AACpE,qEAAgE;AAChE,+BAA4B;AAC5B,uCAAsC;AAEtC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAEhF,SAAS,SAAS,CAChB,MAAuB,EACvB,OAA+B,EAC/B,UAAsB;IAEtB,MAAM,WAAW,GAAG,IAAA,4BAAc,EAAC,OAAO,CAAC,CAAC;IAC5C,OAAO,IAAI,2BAAW,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,eAAe,CACtB,cAA+B,EAC/B,SAAiB,EACjB,sBAA8B;IAE9B,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAC3B,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EA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gBACF,UAAU,CAAC,QAAQ,EAAE,CAAC;YACxB,CAAC,CAAA;SACF,CAAC,CAAC;QACH,OAAO,UAAU,CAAC;QAClB,UAAU;KACX;SAAM;QACL,OAAO,GAAG;aACP,IAAI,CAAC,CAAO,CAAC,EAAE,EAAE;YAChB,MAAM,UAAU,CACd,SAAS,EACT,OAAO,EACP,WAAW,EACX,GAAG,EACH,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,KAAK,CACN,CAAC;YACF,OAAO,CAAC,CAAC;QACX,CAAC,CAAA,CAAC;aACD,KAAK,CAAC,CAAO,CAAC,EAAE,EAAE;YACjB,MAAM,UAAU,CACd,SAAS,EACT,OAAO,EACP,WAAW,EACX,GAAG,EACH,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,KAAK,CACN,CAAC;YACF,MAAM,CAAC,CAAC;QACV,CAAC,CAAA,CAAC,CAAC;KACN;AACH,CAAC;AA9GD,0DA8GC"}
|
|
@@ -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
|
|
@@ -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,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
|