Skip to content

Commit 4e43065

Browse files
authored
feat: fix agent for distroless and have scr name in flag/history/log (#65)
feat(agent): change to a secondary chroot_exec so it happens in a different process Due to distroless we can't do a subprocess.run(chroot /root [cmd]) So instead we call a separate python process to chroot inside of. If we do the chroot inside controller the chroot last for the rest of the process which causes issues with file management and other things that happen after the call. feat(agent): allow passing of root dirs for flag/history/log For GKE we need to be able to control where flag and history files go so that they persist between reboots when using the ContainerOS which only as a few specific stateful directories that are writeable. feat(operator): set env vars for package/interrupt that have SCR name In order to disambiguate between the same package in different SCRs the operator will add the SCR name to the root directories passed to the agent. feat: add test automation for full integration test between operator and agent
1 parent 32c5a06 commit 4e43065

File tree

17 files changed

+844
-220
lines changed

17 files changed

+844
-220
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.cursorignore
2+
.cursor
23
.pytest_cache
34
.idea
45
**/err.txt
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#
2+
# LICENSE START
3+
#
4+
# Copyright (c) NVIDIA CORPORATION. All rights reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
# LICENSE END
19+
#
20+
21+
import os
22+
import stat
23+
import json
24+
import sys
25+
import subprocess
26+
import shutil
27+
28+
29+
def chroot_exec(config: dict, chroot_dir: str):
30+
cmds = config["cmd"]
31+
no_chmod = config["no_chmod"]
32+
if chroot_dir != "local":
33+
os.chroot(chroot_dir)
34+
try:
35+
if not no_chmod:
36+
# chmod +x the step
37+
os.chmod(cmds[0], os.stat(cmds[0]).st_mode | stat.S_IXGRP | stat.S_IXUSR | stat.S_IXOTH)
38+
subprocess.run(cmds, check=True)
39+
except:
40+
raise
41+
42+
43+
if __name__ == "__main__":
44+
control_file = sys.argv[1]
45+
chroot_dir = sys.argv[2]
46+
47+
with open(control_file, "r") as f:
48+
config = json.load(f)
49+
50+
chroot_exec(config, chroot_dir)

0 commit comments

Comments
 (0)