underpost 2.8.836 → 2.8.838
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/README.md +6 -2
- package/cli.md +21 -10
- package/docker-compose.yml +1 -1
- package/manifests/deployment/dd-template-development/deployment.yaml +2 -2
- package/manifests/maas/device-scan.sh +3 -3
- package/package.json +1 -1
- package/src/cli/baremetal.js +3 -13
- package/src/cli/cluster.js +1 -1
- package/src/cli/deploy.js +5 -0
- package/src/cli/index.js +5 -0
- package/src/cli/run.js +117 -11
- package/src/index.js +1 -1
- package/src/server/process.js +10 -20
package/README.md
CHANGED
|
@@ -23,15 +23,19 @@ template
|
|
|
23
23
|
<div align="center">
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
|
|
27
|
+
|
|
26
28
|
<!-- badges -->
|
|
27
29
|
|
|
28
30
|
|
|
29
|
-
[](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [](https://github.com/underpostnet/engine/actions/workflows/coverall.yml) [](https://www.npmjs.com/package/underpost) [](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [](https://github.com/underpostnet/engine/actions/workflows/coverall.yml) [](https://www.npmjs.com/package/underpost) [](https://socket.dev/npm/package/underpost/overview/2.8.838) [](https://coveralls.io/github/underpostnet/engine?branch=master) [](https://www.npmjs.org/package/underpost) [](https://www.npmjs.com/package/underpost)
|
|
30
32
|
|
|
31
33
|
|
|
32
34
|
<!-- end-badges -->
|
|
33
35
|
|
|
34
36
|
|
|
37
|
+
|
|
38
|
+
|
|
35
39
|
</div>
|
|
36
40
|
|
|
37
41
|
<div align="center">
|
|
@@ -76,7 +80,7 @@ Run dev client server
|
|
|
76
80
|
npm run dev
|
|
77
81
|
```
|
|
78
82
|
<!-- -->
|
|
79
|
-
## underpost ci/cd cli v2.8.
|
|
83
|
+
## underpost ci/cd cli v2.8.838
|
|
80
84
|
|
|
81
85
|
### Usage: `underpost [options] [command]`
|
|
82
86
|
```
|
package/cli.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
## underpost ci/cd cli v2.8.
|
|
1
|
+
## underpost ci/cd cli v2.8.838
|
|
2
2
|
|
|
3
3
|
### Usage: `underpost [options] [command]`
|
|
4
4
|
```
|
|
@@ -554,17 +554,28 @@ Options:
|
|
|
554
554
|
Runs a script from the specified path.
|
|
555
555
|
|
|
556
556
|
Arguments:
|
|
557
|
-
runner-id
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
557
|
+
runner-id The runner ID to run. Options:
|
|
558
|
+
spark-template, gpu-env, tf-gpu-test, ide,
|
|
559
|
+
monitor, tf-vae-test, deploy-job.
|
|
560
|
+
path The absolute or relative directory path
|
|
561
|
+
where the script is located.
|
|
561
562
|
|
|
562
563
|
Options:
|
|
563
|
-
--command <command-array>
|
|
564
|
-
--args <args-array>
|
|
565
|
-
--dev
|
|
566
|
-
|
|
567
|
-
-
|
|
564
|
+
--command <command-array> Array of commands to run.
|
|
565
|
+
--args <args-array> Array of arguments to pass to the command.
|
|
566
|
+
--dev Sets the development context environment
|
|
567
|
+
for the script.
|
|
568
|
+
--pod-name <pod-name> Optional: Specifies the pod name for test
|
|
569
|
+
execution.
|
|
570
|
+
--volume-name <volume-name> Optional: Specifies the volume name for
|
|
571
|
+
test execution.
|
|
572
|
+
--image-name <image-name> Optional: Specifies the image name for
|
|
573
|
+
test execution.
|
|
574
|
+
--container-name <container-name> Optional: Specifies the container name for
|
|
575
|
+
test execution.
|
|
576
|
+
--namespace <namespace> Optional: Specifies the namespace for test
|
|
577
|
+
execution.
|
|
578
|
+
-h, --help display help for command
|
|
568
579
|
|
|
569
580
|
```
|
|
570
581
|
|
package/docker-compose.yml
CHANGED
|
@@ -17,7 +17,7 @@ spec:
|
|
|
17
17
|
spec:
|
|
18
18
|
containers:
|
|
19
19
|
- name: dd-template-development-blue
|
|
20
|
-
image: localhost/rockylinux9-underpost:v2.8.
|
|
20
|
+
image: localhost/rockylinux9-underpost:v2.8.838
|
|
21
21
|
# resources:
|
|
22
22
|
# requests:
|
|
23
23
|
# memory: "124Ki"
|
|
@@ -100,7 +100,7 @@ spec:
|
|
|
100
100
|
spec:
|
|
101
101
|
containers:
|
|
102
102
|
- name: dd-template-development-green
|
|
103
|
-
image: localhost/rockylinux9-underpost:v2.8.
|
|
103
|
+
image: localhost/rockylinux9-underpost:v2.8.838
|
|
104
104
|
# resources:
|
|
105
105
|
# requests:
|
|
106
106
|
# memory: "124Ki"
|
|
@@ -8,14 +8,14 @@ for iface_path in /sys/class/net/*; do
|
|
|
8
8
|
operstate=$(< "$iface_path/operstate")
|
|
9
9
|
mtu=$(< "$iface_path/mtu")
|
|
10
10
|
|
|
11
|
-
# Driver
|
|
11
|
+
# Driver
|
|
12
12
|
if [ -L "$iface_path/device/driver" ]; then
|
|
13
13
|
driver=$(basename "$(readlink -f "$iface_path/device/driver")")
|
|
14
14
|
else
|
|
15
15
|
driver="—"
|
|
16
16
|
fi
|
|
17
17
|
|
|
18
|
-
# Vendor
|
|
18
|
+
# Vendor device ID PCI
|
|
19
19
|
pci_dev="$iface_path/device"
|
|
20
20
|
if [ -f "$pci_dev/vendor" ] && [ -f "$pci_dev/device" ]; then
|
|
21
21
|
vendor_id=$(< "$pci_dev/vendor")
|
|
@@ -28,7 +28,7 @@ for iface_path in /sys/class/net/*; do
|
|
|
28
28
|
pci="—"
|
|
29
29
|
fi
|
|
30
30
|
|
|
31
|
-
# Link Speed
|
|
31
|
+
# Link Speed
|
|
32
32
|
speed=$(cat "$iface_path/speed" 2>/dev/null || echo "—")
|
|
33
33
|
|
|
34
34
|
echo "Interface: $name"
|
package/package.json
CHANGED
package/src/cli/baremetal.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getNpmRootPath, getUnderpostRootPath } from '../server/conf.js';
|
|
2
|
-
import { pbcopy, shellExec } from '../server/process.js';
|
|
2
|
+
import { openTerminal, pbcopy, shellExec } from '../server/process.js';
|
|
3
3
|
import dotenv from 'dotenv';
|
|
4
4
|
import { loggerFactory } from '../server/logger.js';
|
|
5
5
|
import { getLocalIPv4Address } from '../server/dns.js';
|
|
@@ -699,18 +699,8 @@ menuentry '${menuentryStr}' {
|
|
|
699
699
|
fs.writeFileSync(`${nfsHostPath}/underpost/token-secret`, token_secret, 'utf8');
|
|
700
700
|
|
|
701
701
|
// Open new terminals for live cloud-init logs.
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
{
|
|
705
|
-
async: true,
|
|
706
|
-
},
|
|
707
|
-
);
|
|
708
|
-
shellExec(
|
|
709
|
-
`gnome-terminal -- bash -c "node ${underpostRoot}/bin baremetal --logs machine; exec bash" & disown`,
|
|
710
|
-
{
|
|
711
|
-
async: true,
|
|
712
|
-
},
|
|
713
|
-
);
|
|
702
|
+
openTerminal(`node ${underpostRoot}/bin baremetal --logs cloud`);
|
|
703
|
+
openTerminal(`node ${underpostRoot}/bin baremetal --logs machine`);
|
|
714
704
|
} catch (error) {
|
|
715
705
|
logger.error(error, error.stack);
|
|
716
706
|
} finally {
|
package/src/cli/cluster.js
CHANGED
|
@@ -662,7 +662,7 @@ net.ipv4.ip_forward = 1' | sudo tee ${iptableConfPath}`);
|
|
|
662
662
|
const archData = UnderpostBaremetal.API.getHostArch();
|
|
663
663
|
logger.info('Installing essential host-level prerequisites for Kubernetes...', archData);
|
|
664
664
|
// Install Docker and its dependencies
|
|
665
|
-
shellExec(`sudo dnf -y install dnf-plugins-core`);
|
|
665
|
+
shellExec(`sudo dnf -y install dnf-plugins-core dbus-x11`);
|
|
666
666
|
shellExec(`sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo`);
|
|
667
667
|
shellExec(`sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin`);
|
|
668
668
|
|
package/src/cli/deploy.js
CHANGED
|
@@ -296,6 +296,11 @@ kind: StatefulSet
|
|
|
296
296
|
metadata:
|
|
297
297
|
name: ...
|
|
298
298
|
EOF
|
|
299
|
+
|
|
300
|
+
https://org.ngc.nvidia.com/setup/api-keys
|
|
301
|
+
docker login nvcr.io
|
|
302
|
+
Username: $oauthtoken
|
|
303
|
+
Password: <Your Key>
|
|
299
304
|
`);
|
|
300
305
|
if (deployList === 'dd' && fs.existsSync(`./engine-private/deploy/dd.router`))
|
|
301
306
|
deployList = fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8');
|
package/src/cli/index.js
CHANGED
|
@@ -323,6 +323,11 @@ program
|
|
|
323
323
|
.option('--command <command-array>', 'Array of commands to run.')
|
|
324
324
|
.option('--args <args-array>', 'Array of arguments to pass to the command.')
|
|
325
325
|
.option('--dev', 'Sets the development context environment for the script.')
|
|
326
|
+
.option('--pod-name <pod-name>', 'Optional: Specifies the pod name for test execution.')
|
|
327
|
+
.option('--volume-name <volume-name>', 'Optional: Specifies the volume name for test execution.')
|
|
328
|
+
.option('--image-name <image-name>', 'Optional: Specifies the image name for test execution.')
|
|
329
|
+
.option('--container-name <container-name>', 'Optional: Specifies the container name for test execution.')
|
|
330
|
+
.option('--namespace <namespace>', 'Optional: Specifies the namespace for test execution.')
|
|
326
331
|
.description('Runs a script from the specified path.')
|
|
327
332
|
.action(UnderpostRun.API.callback);
|
|
328
333
|
|
package/src/cli/run.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
import { pbcopy, shellCd, shellExec } from '../server/process.js';
|
|
1
|
+
import { getTerminalPid, openTerminal, pbcopy, shellCd, shellExec } from '../server/process.js';
|
|
2
2
|
import read from 'read';
|
|
3
3
|
import { getNpmRootPath } from '../server/conf.js';
|
|
4
4
|
import { loggerFactory } from '../server/logger.js';
|
|
5
5
|
import UnderpostTest from './test.js';
|
|
6
6
|
import fs from 'fs-extra';
|
|
7
|
+
import { timer } from '../client/components/core/CommonJs.js';
|
|
7
8
|
|
|
8
9
|
const logger = loggerFactory(import.meta);
|
|
9
10
|
|
|
10
11
|
class UnderpostRun {
|
|
11
|
-
static DEFAULT_OPTION = {
|
|
12
|
+
static DEFAULT_OPTION = {
|
|
13
|
+
dev: false,
|
|
14
|
+
podName: '',
|
|
15
|
+
volumeName: '',
|
|
16
|
+
imageName: '',
|
|
17
|
+
containerName: '',
|
|
18
|
+
namespace: '',
|
|
19
|
+
};
|
|
12
20
|
static RUNNERS = {
|
|
13
21
|
'spark-template': (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
14
22
|
const dir = '/home/dd/spark-template';
|
|
@@ -45,23 +53,116 @@ class UnderpostRun {
|
|
|
45
53
|
const { underpostRoot } = options;
|
|
46
54
|
shellExec(`node ${underpostRoot}/bin/vs ${path}`);
|
|
47
55
|
},
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
56
|
+
monitor: (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
57
|
+
const pid = getTerminalPid();
|
|
58
|
+
logger.info('monitor pid', pid);
|
|
59
|
+
const checkPath = '/await';
|
|
60
|
+
const _monitor = async () => {
|
|
61
|
+
const result = JSON.parse(
|
|
62
|
+
shellExec(`kubectl exec ${path} -- test -f ${checkPath} && echo "true" || echo "false"`, {
|
|
63
|
+
stdout: true,
|
|
64
|
+
disableLog: true,
|
|
65
|
+
silent: true,
|
|
66
|
+
}).trim(),
|
|
67
|
+
);
|
|
68
|
+
logger.info('monitor', result);
|
|
69
|
+
if (result === true) {
|
|
70
|
+
switch (path) {
|
|
71
|
+
case 'tf-vae-test':
|
|
72
|
+
{
|
|
73
|
+
const nameSpace = 'default';
|
|
74
|
+
const podName = path;
|
|
75
|
+
const basePath = '/home/dd';
|
|
76
|
+
const scriptPath = '/site/en/tutorials/generative/cvae.py';
|
|
77
|
+
shellExec(
|
|
78
|
+
`sudo kubectl cp ${nameSpace}/${podName}:${basePath}/docs${scriptPath} ${basePath}/lab/src/${scriptPath
|
|
79
|
+
.split('/')
|
|
80
|
+
.pop()}`,
|
|
81
|
+
);
|
|
82
|
+
const file = fs.readFileSync(`${basePath}/lab/src/${scriptPath.split('/').pop()}`, 'utf8');
|
|
83
|
+
fs.writeFileSync(
|
|
84
|
+
`${basePath}/lab/src/${scriptPath.split('/').pop()}`,
|
|
85
|
+
file.replace(
|
|
86
|
+
`import time`,
|
|
87
|
+
`import time
|
|
88
|
+
print('=== SCRIPT UPDATE TEST ===')`,
|
|
89
|
+
),
|
|
90
|
+
'utf8',
|
|
91
|
+
);
|
|
92
|
+
shellExec(
|
|
93
|
+
`sudo kubectl cp ${basePath}/lab/src/${scriptPath
|
|
94
|
+
.split('/')
|
|
95
|
+
.pop()} ${nameSpace}/${podName}:${basePath}/docs${scriptPath}`,
|
|
96
|
+
);
|
|
97
|
+
// shellExec(`sudo kubectl exec -i ${podName} -- sh -c "ipython ${basePath}/docs${scriptPath}"`);
|
|
98
|
+
shellExec(`sudo kubectl exec -i ${podName} -- sh -c "rm -rf ${checkPath}"`);
|
|
99
|
+
shellExec(`sudo kill -9 ${pid}`);
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
|
|
103
|
+
default:
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
await timer(1000);
|
|
109
|
+
_monitor();
|
|
110
|
+
};
|
|
111
|
+
_monitor();
|
|
112
|
+
},
|
|
113
|
+
'tf-vae-test': async (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
114
|
+
const { underpostRoot } = options;
|
|
115
|
+
const podName = 'tf-vae-test';
|
|
116
|
+
await UnderpostRun.RUNNERS['deploy-job']('', {
|
|
117
|
+
podName,
|
|
118
|
+
on: {
|
|
119
|
+
init: async () => {
|
|
120
|
+
openTerminal(`node bin run --dev monitor ${podName}`);
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
args: [
|
|
124
|
+
`pip install --upgrade \
|
|
125
|
+
nbconvert \
|
|
126
|
+
tensorflow-probability==0.23.0 \
|
|
127
|
+
imageio \
|
|
128
|
+
git+https://github.com/tensorflow/docs \
|
|
129
|
+
matplotlib \
|
|
130
|
+
"numpy<1.25,>=1.21"`,
|
|
131
|
+
'mkdir -p /home/dd',
|
|
132
|
+
'cd /home/dd',
|
|
133
|
+
'git clone https://github.com/tensorflow/docs.git',
|
|
134
|
+
'cd docs',
|
|
135
|
+
'jupyter nbconvert --to python site/en/tutorials/generative/cvae.ipynb',
|
|
136
|
+
`echo '' > /await`,
|
|
137
|
+
`echo '=== WAITING SCRIPT LAUNCH ==='`,
|
|
138
|
+
`while [ -f /await ]; do sleep 1; done`,
|
|
139
|
+
`ipython site/en/tutorials/generative/cvae.py`,
|
|
140
|
+
`echo '=== FINISHED ==='`,
|
|
141
|
+
],
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
'deploy-job': async (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
145
|
+
const podName = options.podName || 'deploy-job';
|
|
146
|
+
const volumeName = options.volumeName || `${podName}-volume`;
|
|
51
147
|
const args = (options.args ? options.args : path ? [`python ${path}`] : []).filter((c) => c.trim());
|
|
148
|
+
const imageName = options.imageName || 'nvcr.io/nvidia/tensorflow:24.04-tf2-py3';
|
|
149
|
+
const containerName = options.containerName || `${podName}-container`;
|
|
150
|
+
const gpuEnable = imageName.match('nvidia');
|
|
151
|
+
const runtimeClassName = gpuEnable ? 'nvidia' : '';
|
|
152
|
+
const namespace = options.namespace || 'default';
|
|
52
153
|
|
|
53
154
|
const cmd = `kubectl apply -f - <<EOF
|
|
54
155
|
apiVersion: v1
|
|
55
156
|
kind: Pod
|
|
56
157
|
metadata:
|
|
57
158
|
name: ${podName}
|
|
58
|
-
namespace:
|
|
159
|
+
namespace: ${namespace}
|
|
59
160
|
spec:
|
|
60
161
|
restartPolicy: Never
|
|
61
|
-
runtimeClassName:
|
|
162
|
+
${runtimeClassName ? ` runtimeClassName: ${runtimeClassName}` : ''}
|
|
62
163
|
containers:
|
|
63
|
-
- name:
|
|
64
|
-
image:
|
|
164
|
+
- name: ${containerName}
|
|
165
|
+
image: ${imageName}
|
|
65
166
|
imagePullPolicy: IfNotPresent
|
|
66
167
|
tty: true
|
|
67
168
|
stdin: true
|
|
@@ -73,12 +174,16 @@ ${
|
|
|
73
174
|
${args.map((arg) => ` ${arg}`).join('\n')}`
|
|
74
175
|
: ''
|
|
75
176
|
}
|
|
76
|
-
|
|
177
|
+
${
|
|
178
|
+
gpuEnable
|
|
179
|
+
? ` resources:
|
|
77
180
|
limits:
|
|
78
181
|
nvidia.com/gpu: '1'
|
|
79
182
|
env:
|
|
80
183
|
- name: NVIDIA_VISIBLE_DEVICES
|
|
81
|
-
value: all
|
|
184
|
+
value: all`
|
|
185
|
+
: ''
|
|
186
|
+
}
|
|
82
187
|
${
|
|
83
188
|
path
|
|
84
189
|
? `
|
|
@@ -98,6 +203,7 @@ EOF`;
|
|
|
98
203
|
shellExec(cmd, { disableLog: true });
|
|
99
204
|
const successInstance = await UnderpostTest.API.statusMonitor(podName);
|
|
100
205
|
if (successInstance) {
|
|
206
|
+
options.on?.init ? await options.on.init() : null;
|
|
101
207
|
shellExec(`kubectl logs -f ${podName}`);
|
|
102
208
|
}
|
|
103
209
|
},
|
package/src/index.js
CHANGED
package/src/server/process.js
CHANGED
|
@@ -10,8 +10,6 @@ dotenv.config();
|
|
|
10
10
|
|
|
11
11
|
const logger = loggerFactory(import.meta);
|
|
12
12
|
|
|
13
|
-
// process.exit();
|
|
14
|
-
|
|
15
13
|
const getRootDirectory = () => process.cwd().replace(/\\/g, '/');
|
|
16
14
|
|
|
17
15
|
const ProcessController = {
|
|
@@ -63,27 +61,19 @@ const shellCd = (cd, options = { disableLog: false }) => {
|
|
|
63
61
|
return shell.cd(cd);
|
|
64
62
|
};
|
|
65
63
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// sudo apt update
|
|
72
|
-
// sudo apt install xclip
|
|
73
|
-
// paste: xclip -o
|
|
74
|
-
// copy:
|
|
75
|
-
// shellExec(`echo "${data}" | xclip -sel clip`, { async: true });
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
break;
|
|
64
|
+
const openTerminal = (cmd) =>
|
|
65
|
+
shellExec(`gnome-terminal -- bash -c "${cmd}; exec bash" & disown`, {
|
|
66
|
+
async: true,
|
|
67
|
+
stdout: true,
|
|
68
|
+
});
|
|
79
69
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
70
|
+
// list all terminals: pgrep gnome-terminal
|
|
71
|
+
// list last terminal: pgrep -n gnome-terminal
|
|
72
|
+
const getTerminalPid = () => JSON.parse(shellExec(`pgrep -n gnome-terminal`, { stdout: true, silent: true }));
|
|
83
73
|
|
|
74
|
+
function pbcopy(data) {
|
|
84
75
|
clipboard.writeSync(data || '🦄');
|
|
85
|
-
|
|
86
76
|
logger.info(`copied to clipboard`, clipboard.readSync());
|
|
87
77
|
}
|
|
88
78
|
|
|
89
|
-
export { ProcessController, getRootDirectory, shellExec, shellCd, pbcopy };
|
|
79
|
+
export { ProcessController, getRootDirectory, shellExec, shellCd, pbcopy, openTerminal, getTerminalPid };
|