teraslice 2.17.2 → 3.0.0-dev.0
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/dist/src/lib/cluster/services/api.js +5 -8
- package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/index.js +1 -1
- package/dist/src/lib/cluster/services/cluster/index.js +0 -4
- package/dist/src/lib/cluster/services/execution.js +1 -1
- package/dist/src/lib/cluster/services/jobs.js +12 -8
- package/dist/src/lib/config/schemas/system.js +1 -1
- package/dist/src/lib/utils/api_utils.js +1 -41
- package/dist/src/lib/workers/helpers/worker-shutdown.js +4 -19
- package/dist/test/utils/api_utils-spec.js +1 -62
- package/package.json +11 -12
- package/dist/src/lib/cluster/services/cluster/backends/kubernetes/index.js +0 -192
- package/dist/src/lib/cluster/services/cluster/backends/kubernetes/k8s.js +0 -481
- package/dist/src/lib/cluster/services/cluster/backends/kubernetes/k8sResource.js +0 -414
- package/dist/src/lib/cluster/services/cluster/backends/kubernetes/k8sState.js +0 -59
- package/dist/src/lib/cluster/services/cluster/backends/kubernetes/utils.js +0 -43
- package/dist/test/lib/cluster/services/cluster/backends/kubernetes/k8s-spec.js +0 -316
- package/dist/test/lib/cluster/services/cluster/backends/kubernetes/k8sResource-spec.js +0 -795
- package/dist/test/lib/cluster/services/cluster/backends/kubernetes/k8sState-multicluster-spec.js +0 -67
- package/dist/test/lib/cluster/services/cluster/backends/kubernetes/k8sState-spec.js +0 -84
- package/dist/test/lib/cluster/services/cluster/backends/kubernetes/utils-spec.js +0 -132
package/dist/test/lib/cluster/services/cluster/backends/kubernetes/k8sState-multicluster-spec.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { cloneDeep } from '@terascope/utils';
|
|
2
|
-
import _podsJobRunning from './files/job-running-v1-k8s-pods-multicluster.json';
|
|
3
|
-
import { gen } from '../../../../../../../src/lib/cluster/services/cluster/backends/kubernetes/k8sState.js';
|
|
4
|
-
describe('k8sState with pods from multiple clusters', () => {
|
|
5
|
-
it('should generate cluster state correctly on first call', () => {
|
|
6
|
-
const podsJobRunning = cloneDeep(_podsJobRunning);
|
|
7
|
-
const clusterState = {};
|
|
8
|
-
gen(podsJobRunning, clusterState);
|
|
9
|
-
// console.log(`clusterState\n\n${JSON.stringify(clusterState, null, 2)}`);
|
|
10
|
-
// console.log(JSON.stringify(podsJobRunning, null, 2));
|
|
11
|
-
expect(clusterState['192.168.99.100'].state).toEqual('connected');
|
|
12
|
-
expect(clusterState['192.168.99.100'].active.length).toEqual(3);
|
|
13
|
-
expect(clusterState['192.168.99.100'].active[1])
|
|
14
|
-
.toEqual({
|
|
15
|
-
worker_id: 'teraslice-execution_controller-123456-784cbt5mz',
|
|
16
|
-
assignment: 'execution_controller',
|
|
17
|
-
pod_name: 'teraslice-execution_controller-123456-784cbt5mz',
|
|
18
|
-
ex_id: '123456',
|
|
19
|
-
job_id: '654321',
|
|
20
|
-
pod_ip: '172.17.0.5',
|
|
21
|
-
assets: [],
|
|
22
|
-
image: 'docker.registry.example/teraslice:0.0.0'
|
|
23
|
-
});
|
|
24
|
-
expect(clusterState['192.168.99.100'].active[2])
|
|
25
|
-
.toEqual({
|
|
26
|
-
worker_id: 'teraslice-worker-123456-8b68v7p8t',
|
|
27
|
-
assignment: 'worker',
|
|
28
|
-
pod_name: 'teraslice-worker-123456-8b68v7p8t',
|
|
29
|
-
ex_id: '123456',
|
|
30
|
-
job_id: '654321',
|
|
31
|
-
pod_ip: '172.17.0.6',
|
|
32
|
-
assets: [],
|
|
33
|
-
image: 'docker.registry.example/teraslice:0.0.0'
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
it('should generate cluster state correctly on second call', () => {
|
|
37
|
-
const podsJobRunning = cloneDeep(_podsJobRunning);
|
|
38
|
-
const clusterState = {};
|
|
39
|
-
gen(podsJobRunning, clusterState);
|
|
40
|
-
gen(podsJobRunning, clusterState);
|
|
41
|
-
expect(clusterState['192.168.99.100'].state).toEqual('connected');
|
|
42
|
-
expect(clusterState['192.168.99.100'].active.length).toEqual(3);
|
|
43
|
-
expect(clusterState['192.168.99.100'].active[1])
|
|
44
|
-
.toEqual({
|
|
45
|
-
worker_id: 'teraslice-execution_controller-123456-784cbt5mz',
|
|
46
|
-
assignment: 'execution_controller',
|
|
47
|
-
pod_name: 'teraslice-execution_controller-123456-784cbt5mz',
|
|
48
|
-
ex_id: '123456',
|
|
49
|
-
job_id: '654321',
|
|
50
|
-
pod_ip: '172.17.0.5',
|
|
51
|
-
assets: [],
|
|
52
|
-
image: 'docker.registry.example/teraslice:0.0.0'
|
|
53
|
-
});
|
|
54
|
-
expect(clusterState['192.168.99.100'].active[2])
|
|
55
|
-
.toEqual({
|
|
56
|
-
worker_id: 'teraslice-worker-123456-8b68v7p8t',
|
|
57
|
-
assignment: 'worker',
|
|
58
|
-
pod_name: 'teraslice-worker-123456-8b68v7p8t',
|
|
59
|
-
ex_id: '123456',
|
|
60
|
-
job_id: '654321',
|
|
61
|
-
pod_ip: '172.17.0.6',
|
|
62
|
-
assets: [],
|
|
63
|
-
image: 'docker.registry.example/teraslice:0.0.0'
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
//# sourceMappingURL=k8sState-multicluster-spec.js.map
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { cloneDeep } from '@terascope/utils';
|
|
2
|
-
import _podsJobRunning from './files/job-running-v1-k8s-pods.json';
|
|
3
|
-
import { gen } from '../../../../../../../src/lib/cluster/services/cluster/backends/kubernetes/k8sState.js';
|
|
4
|
-
describe('k8sState', () => {
|
|
5
|
-
it('should generate cluster state correctly on first call', () => {
|
|
6
|
-
const podsJobRunning = cloneDeep(_podsJobRunning);
|
|
7
|
-
const clusterState = {};
|
|
8
|
-
gen(podsJobRunning, clusterState);
|
|
9
|
-
// console.log(`clusterState\n\n${JSON.stringify(clusterState, null, 2)}`);
|
|
10
|
-
expect(clusterState['192.168.99.100'].state).toEqual('connected');
|
|
11
|
-
expect(clusterState['192.168.99.100'].active.length).toEqual(3);
|
|
12
|
-
expect(clusterState['192.168.99.100'].active[1])
|
|
13
|
-
.toEqual({
|
|
14
|
-
worker_id: 'teraslice-execution_controller-123456-784cbt5mz',
|
|
15
|
-
assignment: 'execution_controller',
|
|
16
|
-
pod_name: 'teraslice-execution_controller-123456-784cbt5mz',
|
|
17
|
-
ex_id: '123456',
|
|
18
|
-
job_id: '654321',
|
|
19
|
-
pod_ip: '172.17.0.5',
|
|
20
|
-
assets: [],
|
|
21
|
-
image: 'docker.registry.example/teraslice:0.0.0'
|
|
22
|
-
});
|
|
23
|
-
expect(clusterState['192.168.99.100'].active[2])
|
|
24
|
-
.toEqual({
|
|
25
|
-
worker_id: 'teraslice-worker-123456-8b68v7p8t',
|
|
26
|
-
assignment: 'worker',
|
|
27
|
-
pod_name: 'teraslice-worker-123456-8b68v7p8t',
|
|
28
|
-
ex_id: '123456',
|
|
29
|
-
job_id: '654321',
|
|
30
|
-
pod_ip: '172.17.0.6',
|
|
31
|
-
assets: [],
|
|
32
|
-
image: 'docker.registry.example/teraslice:0.0.0'
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
it('should generate cluster state correctly on second call', () => {
|
|
36
|
-
const podsJobRunning = cloneDeep(_podsJobRunning);
|
|
37
|
-
const clusterState = {};
|
|
38
|
-
gen(podsJobRunning, clusterState);
|
|
39
|
-
gen(podsJobRunning, clusterState);
|
|
40
|
-
expect(clusterState['192.168.99.100'].state).toEqual('connected');
|
|
41
|
-
expect(clusterState['192.168.99.100'].active.length).toEqual(3);
|
|
42
|
-
expect(clusterState['192.168.99.100'].active[1])
|
|
43
|
-
.toEqual({
|
|
44
|
-
worker_id: 'teraslice-execution_controller-123456-784cbt5mz',
|
|
45
|
-
assignment: 'execution_controller',
|
|
46
|
-
pod_name: 'teraslice-execution_controller-123456-784cbt5mz',
|
|
47
|
-
ex_id: '123456',
|
|
48
|
-
job_id: '654321',
|
|
49
|
-
pod_ip: '172.17.0.5',
|
|
50
|
-
assets: [],
|
|
51
|
-
image: 'docker.registry.example/teraslice:0.0.0'
|
|
52
|
-
});
|
|
53
|
-
expect(clusterState['192.168.99.100'].active[2])
|
|
54
|
-
.toEqual({
|
|
55
|
-
worker_id: 'teraslice-worker-123456-8b68v7p8t',
|
|
56
|
-
assignment: 'worker',
|
|
57
|
-
pod_name: 'teraslice-worker-123456-8b68v7p8t',
|
|
58
|
-
ex_id: '123456',
|
|
59
|
-
job_id: '654321',
|
|
60
|
-
pod_ip: '172.17.0.6',
|
|
61
|
-
assets: [],
|
|
62
|
-
image: 'docker.registry.example/teraslice:0.0.0'
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
it('should remove old host ips', () => {
|
|
66
|
-
const podsJobRunning = cloneDeep(_podsJobRunning);
|
|
67
|
-
const clusterState = {};
|
|
68
|
-
clusterState['2.2.2.2'] = {
|
|
69
|
-
node_id: '2.2.2.2',
|
|
70
|
-
hostname: '2.2.2.2',
|
|
71
|
-
pid: 'N/A',
|
|
72
|
-
node_version: 'N/A',
|
|
73
|
-
teraslice_version: 'N/A',
|
|
74
|
-
total: 'N/A',
|
|
75
|
-
state: 'idk',
|
|
76
|
-
available: 'N/A',
|
|
77
|
-
active: []
|
|
78
|
-
};
|
|
79
|
-
gen(podsJobRunning, clusterState);
|
|
80
|
-
expect(clusterState['192.168.99.100'].active.length).toEqual(3);
|
|
81
|
-
expect(clusterState['2.2.2.2']).toBeUndefined();
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
//# sourceMappingURL=k8sState-spec.js.map
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { makeTemplate, getMaxOldSpace } from '../../../../../../../src/lib/cluster/services/cluster/backends/kubernetes/utils.js';
|
|
2
|
-
import { safeEncode } from '../../../../../../../src/lib/utils/encoding_utils.js';
|
|
3
|
-
describe('K8s Utils', () => {
|
|
4
|
-
describe('->makeTemplate', () => {
|
|
5
|
-
it('should be able to support the execution_controller job', () => {
|
|
6
|
-
const exJobTemplate = makeTemplate('jobs', 'execution_controller');
|
|
7
|
-
const config = {
|
|
8
|
-
name: 'example',
|
|
9
|
-
jobNameLabel: 'example-job',
|
|
10
|
-
clusterNameLabel: 'example-cluster',
|
|
11
|
-
exId: 'some-ex-id',
|
|
12
|
-
jobId: 'some-job-id',
|
|
13
|
-
nodeType: 'execution_controller',
|
|
14
|
-
namespace: 'some-namespace',
|
|
15
|
-
dockerImage: 'some/docker-image',
|
|
16
|
-
execution: safeEncode({ example: 'hello' }),
|
|
17
|
-
shutdownTimeout: 12345
|
|
18
|
-
};
|
|
19
|
-
const exJob = exJobTemplate(config);
|
|
20
|
-
expect(exJob.kind).toEqual('Job');
|
|
21
|
-
expect(exJob.metadata).toEqual({
|
|
22
|
-
labels: {
|
|
23
|
-
'app.kubernetes.io/name': 'teraslice',
|
|
24
|
-
'app.kubernetes.io/component': config.nodeType,
|
|
25
|
-
'teraslice.terascope.io/exId': config.exId,
|
|
26
|
-
'teraslice.terascope.io/jobId': config.jobId,
|
|
27
|
-
'teraslice.terascope.io/jobName': config.jobNameLabel,
|
|
28
|
-
'app.kubernetes.io/instance': config.clusterNameLabel
|
|
29
|
-
},
|
|
30
|
-
name: config.name,
|
|
31
|
-
namespace: config.namespace
|
|
32
|
-
});
|
|
33
|
-
expect(exJob.spec.template.metadata.labels).toEqual(exJob.metadata.labels);
|
|
34
|
-
const templateSpec = exJob.spec.template.spec;
|
|
35
|
-
expect(templateSpec.containers[0].image).toEqual(config.dockerImage);
|
|
36
|
-
expect(templateSpec.containers[0].name).toEqual(config.name);
|
|
37
|
-
expect(templateSpec.containers[0].env).toEqual([
|
|
38
|
-
{
|
|
39
|
-
name: 'NODE_TYPE',
|
|
40
|
-
value: config.nodeType
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: 'EX',
|
|
44
|
-
value: config.execution
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
name: 'POD_IP',
|
|
48
|
-
valueFrom: {
|
|
49
|
-
fieldRef: {
|
|
50
|
-
fieldPath: 'status.podIP'
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
]);
|
|
55
|
-
expect(templateSpec.terminationGracePeriodSeconds).toEqual(config.shutdownTimeout);
|
|
56
|
-
});
|
|
57
|
-
it('should be able to support the worker deployment', () => {
|
|
58
|
-
const workerDeploymentTemplate = makeTemplate('deployments', 'worker');
|
|
59
|
-
const config = {
|
|
60
|
-
name: 'example',
|
|
61
|
-
jobNameLabel: 'example-job',
|
|
62
|
-
clusterNameLabel: 'example-cluster',
|
|
63
|
-
exId: 'some-ex-id',
|
|
64
|
-
exName: 'example-job-abcd',
|
|
65
|
-
exUid: 'UID1',
|
|
66
|
-
jobId: 'some-job-id',
|
|
67
|
-
nodeType: 'worker',
|
|
68
|
-
namespace: 'some-namespace',
|
|
69
|
-
dockerImage: 'some/docker-image',
|
|
70
|
-
execution: safeEncode({ example: 'hello' }),
|
|
71
|
-
replicas: 1,
|
|
72
|
-
shutdownTimeout: 12345
|
|
73
|
-
};
|
|
74
|
-
const workerDeployment = workerDeploymentTemplate(config);
|
|
75
|
-
expect(workerDeployment.kind).toEqual('Deployment');
|
|
76
|
-
expect(workerDeployment.metadata).toEqual({
|
|
77
|
-
labels: {
|
|
78
|
-
'app.kubernetes.io/name': 'teraslice',
|
|
79
|
-
'app.kubernetes.io/component': config.nodeType,
|
|
80
|
-
'teraslice.terascope.io/exId': config.exId,
|
|
81
|
-
'teraslice.terascope.io/jobId': config.jobId,
|
|
82
|
-
'teraslice.terascope.io/jobName': config.jobNameLabel,
|
|
83
|
-
'app.kubernetes.io/instance': config.clusterNameLabel
|
|
84
|
-
},
|
|
85
|
-
name: config.name,
|
|
86
|
-
namespace: config.namespace,
|
|
87
|
-
ownerReferences: [
|
|
88
|
-
{
|
|
89
|
-
apiVersion: 'batch/v1',
|
|
90
|
-
blockOwnerDeletion: false,
|
|
91
|
-
controller: false,
|
|
92
|
-
kind: 'Job',
|
|
93
|
-
name: 'example-job-abcd',
|
|
94
|
-
uid: 'UID1',
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
});
|
|
98
|
-
expect(workerDeployment.spec.replicas).toEqual(config.replicas);
|
|
99
|
-
const { labels } = workerDeployment.spec.template.metadata;
|
|
100
|
-
expect(labels).toEqual(workerDeployment.metadata.labels);
|
|
101
|
-
const templateSpec = workerDeployment.spec.template.spec;
|
|
102
|
-
expect(templateSpec.containers[0].image).toEqual(config.dockerImage);
|
|
103
|
-
expect(templateSpec.containers[0].name).toEqual(config.name);
|
|
104
|
-
expect(templateSpec.containers[0].env).toEqual([
|
|
105
|
-
{
|
|
106
|
-
name: 'NODE_TYPE',
|
|
107
|
-
value: config.nodeType
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
name: 'EX',
|
|
111
|
-
value: config.execution
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
name: 'POD_IP',
|
|
115
|
-
valueFrom: {
|
|
116
|
-
fieldRef: {
|
|
117
|
-
fieldPath: 'status.podIP'
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
]);
|
|
122
|
-
expect(templateSpec.terminationGracePeriodSeconds).toEqual(config.shutdownTimeout);
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
describe('->getMaxOldSpace', () => {
|
|
126
|
-
it('should convert bytes to mb', () => {
|
|
127
|
-
const oneGBInBytes = 1024 * 1024 * 1024;
|
|
128
|
-
expect(getMaxOldSpace(oneGBInBytes)).toEqual(Math.round(0.9 * 1024));
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
//# sourceMappingURL=utils-spec.js.map
|