teraslice 3.3.0 → 3.3.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.
Files changed (108) hide show
  1. package/LICENSE +202 -0
  2. package/package.json +25 -28
  3. package/dist/src/interfaces.js +0 -12
  4. package/dist/src/lib/cluster/cluster_master.js +0 -246
  5. package/dist/src/lib/cluster/node_master.js +0 -355
  6. package/dist/src/lib/cluster/services/api.js +0 -663
  7. package/dist/src/lib/cluster/services/assets.js +0 -224
  8. package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/index.js +0 -192
  9. package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/interfaces.js +0 -2
  10. package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/k8s.js +0 -419
  11. package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/k8sDeploymentResource.js +0 -60
  12. package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/k8sJobResource.js +0 -55
  13. package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/k8sResource.js +0 -357
  14. package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/k8sServiceResource.js +0 -37
  15. package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/k8sState.js +0 -60
  16. package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/utils.js +0 -170
  17. package/dist/src/lib/cluster/services/cluster/backends/native/dispatch.js +0 -13
  18. package/dist/src/lib/cluster/services/cluster/backends/native/index.js +0 -526
  19. package/dist/src/lib/cluster/services/cluster/backends/native/messaging.js +0 -548
  20. package/dist/src/lib/cluster/services/cluster/backends/state-utils.js +0 -26
  21. package/dist/src/lib/cluster/services/cluster/index.js +0 -13
  22. package/dist/src/lib/cluster/services/execution.js +0 -435
  23. package/dist/src/lib/cluster/services/index.js +0 -6
  24. package/dist/src/lib/cluster/services/interfaces.js +0 -2
  25. package/dist/src/lib/cluster/services/jobs.js +0 -458
  26. package/dist/src/lib/config/default-sysconfig.js +0 -25
  27. package/dist/src/lib/config/index.js +0 -20
  28. package/dist/src/lib/config/schemas/system.js +0 -360
  29. package/dist/src/lib/storage/analytics.js +0 -86
  30. package/dist/src/lib/storage/assets.js +0 -401
  31. package/dist/src/lib/storage/backends/elasticsearch_store.js +0 -496
  32. package/dist/src/lib/storage/backends/mappings/analytics.js +0 -20
  33. package/dist/src/lib/storage/backends/mappings/asset.js +0 -32
  34. package/dist/src/lib/storage/backends/mappings/ex.js +0 -53
  35. package/dist/src/lib/storage/backends/mappings/job.js +0 -42
  36. package/dist/src/lib/storage/backends/mappings/state.js +0 -16
  37. package/dist/src/lib/storage/backends/s3_store.js +0 -237
  38. package/dist/src/lib/storage/execution.js +0 -302
  39. package/dist/src/lib/storage/index.js +0 -7
  40. package/dist/src/lib/storage/jobs.js +0 -81
  41. package/dist/src/lib/storage/state.js +0 -254
  42. package/dist/src/lib/utils/api_utils.js +0 -128
  43. package/dist/src/lib/utils/asset_utils.js +0 -94
  44. package/dist/src/lib/utils/date_utils.js +0 -52
  45. package/dist/src/lib/utils/encoding_utils.js +0 -27
  46. package/dist/src/lib/utils/events.js +0 -4
  47. package/dist/src/lib/utils/file_utils.js +0 -124
  48. package/dist/src/lib/utils/id_utils.js +0 -15
  49. package/dist/src/lib/utils/port_utils.js +0 -32
  50. package/dist/src/lib/workers/assets/index.js +0 -3
  51. package/dist/src/lib/workers/assets/loader-executable.js +0 -40
  52. package/dist/src/lib/workers/assets/loader.js +0 -73
  53. package/dist/src/lib/workers/assets/spawn.js +0 -55
  54. package/dist/src/lib/workers/context/execution-context.js +0 -12
  55. package/dist/src/lib/workers/context/terafoundation-context.js +0 -8
  56. package/dist/src/lib/workers/execution-controller/execution-analytics.js +0 -188
  57. package/dist/src/lib/workers/execution-controller/index.js +0 -1024
  58. package/dist/src/lib/workers/execution-controller/recovery.js +0 -151
  59. package/dist/src/lib/workers/execution-controller/scheduler.js +0 -390
  60. package/dist/src/lib/workers/execution-controller/slice-analytics.js +0 -96
  61. package/dist/src/lib/workers/helpers/job.js +0 -80
  62. package/dist/src/lib/workers/helpers/op-analytics.js +0 -22
  63. package/dist/src/lib/workers/helpers/terafoundation.js +0 -34
  64. package/dist/src/lib/workers/helpers/worker-shutdown.js +0 -147
  65. package/dist/src/lib/workers/metrics/index.js +0 -108
  66. package/dist/src/lib/workers/worker/index.js +0 -378
  67. package/dist/src/lib/workers/worker/slice.js +0 -122
  68. package/dist/test/config/schemas/system_schema-spec.js +0 -26
  69. package/dist/test/lib/cluster/services/cluster/backends/kubernetes/v2/k8s-v2-spec.js +0 -458
  70. package/dist/test/lib/cluster/services/cluster/backends/kubernetes/v2/k8sResource-v2-spec.js +0 -818
  71. package/dist/test/lib/cluster/services/cluster/backends/kubernetes/v2/k8sState-multicluster-v2-spec.js +0 -67
  72. package/dist/test/lib/cluster/services/cluster/backends/kubernetes/v2/k8sState-v2-spec.js +0 -84
  73. package/dist/test/lib/cluster/services/cluster/backends/kubernetes/v2/utils-v2-spec.js +0 -320
  74. package/dist/test/lib/cluster/services/cluster/backends/state-utils-spec.js +0 -37
  75. package/dist/test/node_master-spec.js +0 -194
  76. package/dist/test/services/api-spec.js +0 -79
  77. package/dist/test/services/assets-spec.js +0 -158
  78. package/dist/test/services/messaging-spec.js +0 -440
  79. package/dist/test/storage/assets_storage-spec.js +0 -95
  80. package/dist/test/storage/s3_store-spec.js +0 -149
  81. package/dist/test/test.config.js +0 -23
  82. package/dist/test/test.setup.js +0 -6
  83. package/dist/test/utils/api_utils-spec.js +0 -25
  84. package/dist/test/utils/asset_utils-spec.js +0 -141
  85. package/dist/test/utils/elastic_utils-spec.js +0 -25
  86. package/dist/test/workers/execution-controller/execution-controller-spec.js +0 -371
  87. package/dist/test/workers/execution-controller/execution-special-test-cases-spec.js +0 -519
  88. package/dist/test/workers/execution-controller/execution-test-cases-spec.js +0 -343
  89. package/dist/test/workers/execution-controller/recovery-spec.js +0 -160
  90. package/dist/test/workers/execution-controller/scheduler-spec.js +0 -249
  91. package/dist/test/workers/execution-controller/slice-analytics-spec.js +0 -121
  92. package/dist/test/workers/fixtures/ops/example-op/processor.js +0 -20
  93. package/dist/test/workers/fixtures/ops/example-op/schema.js +0 -19
  94. package/dist/test/workers/fixtures/ops/example-reader/fetcher.js +0 -20
  95. package/dist/test/workers/fixtures/ops/example-reader/schema.js +0 -41
  96. package/dist/test/workers/fixtures/ops/example-reader/slicer.js +0 -37
  97. package/dist/test/workers/fixtures/ops/new-op/processor.js +0 -29
  98. package/dist/test/workers/fixtures/ops/new-op/schema.js +0 -18
  99. package/dist/test/workers/fixtures/ops/new-reader/fetcher.js +0 -19
  100. package/dist/test/workers/fixtures/ops/new-reader/schema.js +0 -23
  101. package/dist/test/workers/fixtures/ops/new-reader/slicer.js +0 -13
  102. package/dist/test/workers/helpers/configs.js +0 -128
  103. package/dist/test/workers/helpers/execution-controller-helper.js +0 -49
  104. package/dist/test/workers/helpers/index.js +0 -5
  105. package/dist/test/workers/helpers/test-context.js +0 -210
  106. package/dist/test/workers/helpers/zip-directory.js +0 -25
  107. package/dist/test/workers/worker/slice-spec.js +0 -333
  108. package/dist/test/workers/worker/worker-spec.js +0 -356
@@ -1,224 +0,0 @@
1
- import express from 'express';
2
- import { TSError, parseErrorInfo, logError, toBoolean } from '@terascope/core-utils';
3
- import { makeLogger } from '../../workers/helpers/terafoundation.js';
4
- import { AssetsStorage } from '../../storage/index.js';
5
- import { getBackendConfig } from '../../storage/assets.js';
6
- import { makeTable, handleTerasliceRequest, getSearchOptions, sendError, } from '../../utils/api_utils.js';
7
- export class AssetsService {
8
- context;
9
- assetsStorage;
10
- logger;
11
- port;
12
- app;
13
- running = false;
14
- constructor(context) {
15
- this.context = context;
16
- this.logger = makeLogger(context, 'assets_service');
17
- this.app = express();
18
- const { port } = process.env;
19
- this.port = port;
20
- this.app.set('json spaces', 4);
21
- this.app.use((req, _res, next) => {
22
- // @ts-expect-error
23
- req.logger = this.logger;
24
- next();
25
- });
26
- }
27
- async initialize() {
28
- try {
29
- this.assetsStorage = new AssetsStorage(this.context);
30
- await this.assetsStorage.initialize();
31
- this.app.get('/status', (req, res) => {
32
- const requestHandler = handleTerasliceRequest(req, res);
33
- requestHandler(async () => ({ available: this.running }));
34
- });
35
- this.app.post('/assets', (req, res) => {
36
- const blocking = toBoolean(req.query.blocking);
37
- this.logger.debug('loading an asset', { blocking });
38
- const results = [];
39
- req.on('data', (buff) => {
40
- results.push(buff);
41
- });
42
- req.on('end', async () => {
43
- try {
44
- const data = Buffer.concat(results);
45
- const { assetId, created } = await this.assetsStorage.save(data, blocking);
46
- const code = created ? 201 : 200;
47
- const assetResponse = {
48
- asset_id: assetId,
49
- };
50
- res.status(code).json(assetResponse);
51
- }
52
- catch (err) {
53
- const { statusCode, message } = parseErrorInfo(err);
54
- logError(this.logger, err, 'failure saving assets via proxy request');
55
- sendError(res, statusCode, message, this.logger);
56
- }
57
- });
58
- req.on('error', (err) => {
59
- const { statusCode, message } = parseErrorInfo(err);
60
- logError(this.logger, err, 'failure writing asset');
61
- res.status(statusCode).send(message);
62
- });
63
- });
64
- this.app.delete('/assets/:assetId', (req, res) => {
65
- const { assetId } = req.params;
66
- // @ts-expect-error
67
- const requestHandler = handleTerasliceRequest(req, res, `Could not delete asset ${assetId}`);
68
- if (assetId.length !== 40) {
69
- res.status(400).json({
70
- error: `asset ${assetId} is not formatted correctly, please provide the full asset_id`
71
- });
72
- }
73
- else {
74
- const assetResponse = {
75
- asset_id: assetId,
76
- };
77
- requestHandler(async () => {
78
- await this.assetsStorage.remove(assetId);
79
- return assetResponse;
80
- });
81
- }
82
- });
83
- this.app.get('/txt/assets', (req, res) => {
84
- const query = 'id:*';
85
- this.createAssetTable(query, req, res);
86
- });
87
- this.app.get('/txt/assets/:name', (req, res) => {
88
- const query = `id:* AND name:"${req.params.name}"`;
89
- this.createAssetTable(query, req, res);
90
- });
91
- this.app.get('/txt/assets/:name/:version', (req, res) => {
92
- const query = `id:* AND name:"${req.params.name}" AND version:"${req.params.version}"`;
93
- this.createAssetTable(query, req, res);
94
- });
95
- this.app.get('/assets', (req, res) => {
96
- const query = 'id:*';
97
- this.assetsSearch(query, req, res);
98
- });
99
- this.app.get('/assets/:name', (req, res) => {
100
- const query = `id:* AND name:"${req.params.name}"`;
101
- this.assetsSearch(query, req, res);
102
- });
103
- this.app.get('/assets/:name/:version', (req, res) => {
104
- const query = `id:* AND name:"${req.params.name}" AND version:"${req.params.version}"`;
105
- this.assetsSearch(query, req, res);
106
- });
107
- await new Promise((resolve, reject) => {
108
- // @ts-expect-error
109
- this.app.listen(this.port, (err) => {
110
- if (err) {
111
- reject(err);
112
- return;
113
- }
114
- this.logger.info(`assets_service is listening on port ${this.port}`);
115
- resolve(true);
116
- });
117
- // @ts-expect-error TODO: verify this
118
- this.app.timeout = this.context.sysconfig.teraslice.api_response_timeout;
119
- });
120
- await this.assetsStorage.autoload();
121
- this.running = true;
122
- }
123
- catch (err) {
124
- this.running = false;
125
- throw new TSError(err, {
126
- reason: 'Failure while creating assets_service'
127
- });
128
- }
129
- }
130
- getS3AssetStatus(s3List, esList) {
131
- const result = [...esList];
132
- for (const esRecord of result) {
133
- esRecord.external_storage = 'missing';
134
- for (const s3Record of s3List) {
135
- /// s3AssetId is just the file name without the .zip
136
- const s3AssetId = s3Record.File.slice(0, -4);
137
- if (s3AssetId === esRecord.id) {
138
- esRecord.external_storage = 'available';
139
- break;
140
- }
141
- }
142
- }
143
- return result;
144
- }
145
- createAssetTable(query, req, res) {
146
- const { size, from, sort } = getSearchOptions(req, '_created:desc');
147
- const defaults = [
148
- 'name',
149
- 'version',
150
- 'id',
151
- '_created',
152
- 'description',
153
- 'node_version',
154
- 'platform',
155
- 'arch'
156
- ];
157
- const s3Defaults = [...defaults, 'external_storage'];
158
- function mapping(item) {
159
- return (field) => {
160
- if (field === 'description') {
161
- return item[field] ? item[field].slice(0, 30) : item[field];
162
- }
163
- return item[field];
164
- };
165
- }
166
- const requestHandler = handleTerasliceRequest(req, res, 'Could not get assets');
167
- requestHandler(async () => {
168
- const results = await this.assetsStorage.search(query, from, size, sort, defaults);
169
- const assets = results.hits.hits.map((asset) => {
170
- const record = asset._source;
171
- record.id = asset._id;
172
- return record;
173
- });
174
- const { assetConnectionType } = getBackendConfig(this.context, this.logger);
175
- if (assetConnectionType === 's3') {
176
- const s3Assets = await this.assetsStorage.grabS3Info();
177
- const updatedAssets = this.getS3AssetStatus(s3Assets, assets);
178
- return makeTable(req, s3Defaults, updatedAssets, mapping);
179
- }
180
- return makeTable(req, defaults, assets, mapping);
181
- });
182
- }
183
- assetsSearch(query, req, res) {
184
- const { size, from, sort } = getSearchOptions(req, '_created:desc');
185
- const requestHandler = handleTerasliceRequest(req, res, 'Could not get assets');
186
- requestHandler(async () => {
187
- const fields = ['_created', 'name', 'version', 'description', 'node_version', 'platform', 'arch'];
188
- const results = await this.assetsStorage.search(query, from, size, sort, fields);
189
- const mappedRecords = results.hits.hits.map((asset) => {
190
- const record = asset._source;
191
- record.id = asset._id;
192
- return record;
193
- });
194
- const { assetConnectionType } = getBackendConfig(this.context, this.logger);
195
- if (assetConnectionType === 's3') {
196
- const s3Assets = await this.assetsStorage.grabS3Info();
197
- const updatedAssets = this.getS3AssetStatus(s3Assets, mappedRecords);
198
- return updatedAssets;
199
- }
200
- return mappedRecords;
201
- });
202
- }
203
- run() {
204
- return new Promise((resolve) => {
205
- if (!this.running) {
206
- resolve(true);
207
- return;
208
- }
209
- const runningInterval = setInterval(() => {
210
- if (!this.running) {
211
- clearInterval(runningInterval);
212
- resolve(true);
213
- }
214
- }, 1000);
215
- });
216
- }
217
- async shutdown() {
218
- this.running = false;
219
- if (!this.assetsStorage)
220
- return;
221
- await this.assetsStorage.shutdown(true);
222
- }
223
- }
224
- //# sourceMappingURL=assets.js.map
@@ -1,192 +0,0 @@
1
- import { TSError, logError, get, cloneDeep, pRetry } from '@terascope/core-utils';
2
- import { makeLogger } from '../../../../../workers/helpers/terafoundation.js';
3
- import { gen } from './k8sState.js';
4
- import { K8s } from './k8s.js';
5
- import { getRetryConfig } from './utils.js';
6
- import { K8sJobResource } from './k8sJobResource.js';
7
- import { K8sServiceResource } from './k8sServiceResource.js';
8
- import { K8sDeploymentResource } from './k8sDeploymentResource.js';
9
- /*
10
- Execution Life Cycle for _status
11
- pending -> scheduling -> running -> [ paused -> running ] -> [ stopped | completed ]
12
- Exceptions
13
- rejected - when a job is rejected prior to scheduling
14
- failed - when there is an error while the job is running
15
- aborted - when a job was running at the point when the cluster shuts down
16
- */
17
- export class KubernetesClusterBackendV2 {
18
- context;
19
- k8s;
20
- logger;
21
- clusterStateInterval;
22
- clusterState = {};
23
- clusterNameLabel;
24
- constructor(context, clusterMasterServer) {
25
- const kubernetesNamespace = get(context, 'sysconfig.teraslice.kubernetes_namespace', 'default');
26
- const clusterName = get(context, 'sysconfig.teraslice.name');
27
- this.context = context;
28
- this.logger = makeLogger(context, 'kubernetesV2_cluster_service');
29
- this.clusterNameLabel = clusterName.replace(/[^a-zA-Z0-9_\-.]/g, '_').substring(0, 63);
30
- this.clusterState = {};
31
- this.clusterStateInterval = undefined;
32
- this.k8s = new K8s(this.logger, null, kubernetesNamespace, context.sysconfig.teraslice.kubernetes_api_poll_delay, context.sysconfig.teraslice.shutdown_timeout);
33
- clusterMasterServer.onClientOnline((exId) => {
34
- this.logger.info(`execution ${exId} is connected`);
35
- });
36
- }
37
- /**
38
- * getClusterState returns a copy of the clusterState object
39
- * @return {Object} a copy of the clusterState object
40
- */
41
- getClusterState() {
42
- return cloneDeep(this.clusterState);
43
- }
44
- /**
45
- * Creates clusterState by iterating over all k8s pods matching both labels
46
- * app.kubernetes.io/name=teraslice
47
- * app.kubernetes.io/instance=${clusterNameLabel}
48
- * @constructor
49
- * @return {Promise} void
50
- */
51
- async _getClusterState() {
52
- return this.k8s.list(`app.kubernetes.io/name=teraslice,app.kubernetes.io/instance=${this.clusterNameLabel}`, 'pods')
53
- .then((tsPodList) => gen(tsPodList, this.clusterState))
54
- .catch((err) => {
55
- // TODO: We might need to do more here. I think it's OK to just
56
- // log though. This only gets used to show slicer info through
57
- // the API. We wouldn't want to disrupt the cluster master
58
- // for rare failures to reach the k8s API.
59
- logError(this.logger, err, 'Error listing teraslice pods in k8s');
60
- });
61
- }
62
- /**
63
- * Return value indicates whether the cluster has enough workers to start
64
- * an execution. It must be able to allocate a slicer and at least one
65
- * worker.
66
- * @return {boolean} Ok to create job?
67
- */
68
- readyForAllocation() {
69
- // return _availableWorkers() >= 2;
70
- // TODO: This will be addressed in the future, see:
71
- // https://github.com/terascope/teraslice/issues/744
72
- return true;
73
- }
74
- /**
75
- * Creates k8s Service and Job for the Teraslice Execution Controller
76
- * (formerly slicer). This currently works by creating a service with a
77
- * hostname that contains the exId in it listening on a well known port.
78
- * The hostname and port are used later by the workers to contact this
79
- * Execution Controller.
80
- * @param {Object} execution Object containing execution details
81
- * @return {Promise} [description]
82
- */
83
- async allocateSlicer(ex) {
84
- const execution = cloneDeep(ex);
85
- execution.slicer_port = 45680;
86
- const exJobResource = new K8sJobResource(this.context.sysconfig.teraslice, execution, this.logger);
87
- const exJob = exJobResource.resource;
88
- this.logger.debug(exJob, 'execution allocating slicer');
89
- const jobResult = await this.k8s.post(exJob);
90
- if (!jobResult.metadata.uid) {
91
- throw new Error('Required field uid missing from jobResult.metadata');
92
- }
93
- const exServiceResource = new K8sServiceResource(this.context.sysconfig.teraslice, execution, this.logger,
94
- // Needed to create the deployment and service resource ownerReferences
95
- jobResult.metadata.name, jobResult.metadata.uid);
96
- const exService = exServiceResource.resource;
97
- const serviceResult = await this.k8s.post(exService);
98
- this.logger.debug(jobResult, 'k8s slicer job submitted');
99
- const exServiceName = serviceResult.metadata.name;
100
- const exServiceHostName = `${exServiceName}.${this.k8s.defaultNamespace}`;
101
- this.logger.debug(`Slicer is using host name: ${exServiceHostName}`);
102
- execution.slicer_hostname = `${exServiceHostName}`;
103
- return execution;
104
- }
105
- /**
106
- * Creates k8s deployment that executes Teraslice workers for specified
107
- * Execution.
108
- * @param {Object} execution Object that contains information of Execution
109
- * @return {Promise} [description]
110
- */
111
- async allocateWorkers(execution) {
112
- // NOTE: I tried to set these on the execution inside allocateSlicer
113
- // but these properties were gone by the time this was called, perhaps
114
- // because they are not on the schema. So I do this k8s API call
115
- // instead.
116
- const selector = `app.kubernetes.io/component=execution_controller,teraslice.terascope.io/jobId=${execution.job_id}`;
117
- const jobs = await pRetry(() => this.k8s.nonEmptyJobList(selector), getRetryConfig());
118
- if (!jobs.items[0].metadata.uid) {
119
- throw new Error('Required field uid missing from kubernetes job metadata');
120
- }
121
- const kr = new K8sDeploymentResource(this.context.sysconfig.teraslice, execution, this.logger, jobs.items[0].metadata.name, jobs.items[0].metadata.uid);
122
- const workerDeployment = kr.resource;
123
- this.logger.debug(`workerDeployment:\n\n${JSON.stringify(workerDeployment, null, 2)}`);
124
- return this.k8s.post(workerDeployment)
125
- .then((result) => this.logger.debug(`k8s worker deployment submitted: ${JSON.stringify(result)}`))
126
- .catch((err) => {
127
- const error = new TSError(err, {
128
- reason: 'Error submitting k8s worker deployment'
129
- });
130
- return Promise.reject(error);
131
- });
132
- }
133
- // FIXME: These functions should probably do something with the response
134
- // NOTE: I find is strange that the expected return value here is
135
- // effectively the same as the function inputs
136
- async addWorkers(executionContext, numWorkers) {
137
- await this.k8s.scaleExecution(executionContext.ex_id, numWorkers, 'add');
138
- return { action: 'add', ex_id: executionContext.ex_id, workerNum: numWorkers };
139
- }
140
- // NOTE: This is passed exId instead of executionContext like addWorkers and
141
- // removeWorkers. I don't know why, just dealing with it.
142
- async removeWorkers(exId, numWorkers) {
143
- await this.k8s.scaleExecution(exId, numWorkers, 'remove');
144
- return { action: 'remove', ex_id: exId, workerNum: numWorkers };
145
- }
146
- // TODO: fix types here
147
- async setWorkers(executionContext, numWorkers) {
148
- await this.k8s.scaleExecution(executionContext.ex_id, numWorkers, 'set');
149
- return { action: 'set', ex_id: executionContext.ex_id, workerNum: numWorkers };
150
- }
151
- /**
152
- * Stops all workers for exId
153
- * @param {String} exId The execution ID of the Execution to stop
154
- * @param {StopExecutionOptions} options force, timeout, and excludeNode
155
- * force: stop all related pod, deployment, and job resources
156
- * timeout and excludeNode are not used in k8s clustering.
157
- * @return {Promise}
158
- */
159
- async stopExecution(exId, options) {
160
- return this.k8s.deleteExecution(exId, options?.force);
161
- }
162
- async shutdown() {
163
- clearInterval(this.clusterStateInterval);
164
- }
165
- /**
166
- * Returns a list of all k8s resources associated with a job ID
167
- * @param {string} jobId The job ID of the job to list associated resources
168
- * @returns {Array<TSPod[] | TSDeployment[] | TSService[]
169
- * | TSJob[] | TSReplicaSet[]>}
170
- */
171
- async listResourcesForJobId(jobId) {
172
- const resources = [];
173
- const resourceTypes = ['pods', 'deployments', 'services', 'jobs', 'replicasets'];
174
- for (const type of resourceTypes) {
175
- const list = await this.k8s.list(`teraslice.terascope.io/jobId=${jobId}`, type);
176
- if (list.items.length > 0) {
177
- resources.push(list.items);
178
- }
179
- }
180
- return resources;
181
- }
182
- async initialize() {
183
- this.logger.info('kubernetesV2 clustering initializing');
184
- // Periodically update cluster state, update period controlled by:
185
- // context.sysconfig.teraslice.node_state_interval
186
- this.clusterStateInterval = setInterval(() => {
187
- this.logger.trace('cluster_master requesting cluster state update.');
188
- this._getClusterState();
189
- }, this.context.sysconfig.teraslice.node_state_interval);
190
- }
191
- }
192
- //# sourceMappingURL=index.js.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=interfaces.js.map