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