ch-runner: another iter of cleanup prior to moving things around

This commit is contained in:
Else Someone 2026-02-20 10:50:31 +02:00
parent 97f2ba4c66
commit 342a1dfe3a

View file

@ -311,10 +311,25 @@ in
} }
def configure_execline(prefix, vm, check=True, **defaults): def configure_exec(prefix, vm, check=True, **defaults):
def execline(*args, check=check, **kwargs):
def exec(*args, check=check, **kwargs):
return subprocess.run( return subprocess.run(
["execlineb", "-c", "\n".join(args)], [*args],
**defaults,
env={
**PASSTHRU_ENV,
"PATH": PASSTHRU_PATH,
"PREFIX": prefix,
"VM": vm,
},
check=check,
cwd=prefix,
**kwargs)
def execline(*args, check=check, **kwargs):
return exec(
"execlineb", "-c", "\n".join(args),
**defaults, **defaults,
executable=ELB_DIR + "/execlineb", executable=ELB_DIR + "/execlineb",
env={ env={
@ -326,7 +341,8 @@ in
check=check, check=check,
cwd=prefix, cwd=prefix,
**kwargs) **kwargs)
return execline
return exec, execline
def preprocess_args(args_mut): def preprocess_args(args_mut):
@ -373,7 +389,8 @@ in
] ]
p = subprocess.Popen( p = subprocess.Popen(
args, args,
shell=False) shell=False,
pass_fds=(2,))
try: try:
p.wait(1.0) p.wait(1.0)
needs_cleanup = False needs_cleanup = False
@ -408,7 +425,7 @@ in
preprocess_args(args) preprocess_args(args)
os.makedirs(args.prefix, exist_ok=True) os.makedirs(args.prefix, exist_ok=True)
execline = configure_execline( exec, _ = configure_exec(
prefix=args.prefix, prefix=args.prefix,
vm=args.vm) vm=args.vm)
@ -420,14 +437,17 @@ in
with ExitStack() as cleanup: with ExitStack() as cleanup:
ch = cleanup.enter_context(run_ch(args.prefix)) ch = cleanup.enter_context(run_ch(args.prefix))
execline(*ch_remote, "create", args.vm_config) exec(*ch_remote, "create", args.vm_config)
execline( exec(
TAPS_PATH, "pass", TAPS_PATH, "pass",
*ch_remote, "add-net", *ch_remote, "add-net",
"id=wan,fd=3,mac=00:00:00:00:00:01") "id=wan,fd=3,mac=00:00:00:00:00:01")
execline(*ch_remote, "boot") exec(*ch_remote, "boot")
execline(*ch_remote, "info") exec(*ch_remote, "info")
try:
ch.wait() ch.wait()
except KeyboardInterrupt:
pass
''; '';
in in
writeElb "run-${hostName}" '' writeElb "run-${hostName}" ''