200306f1cf
test / unit (pull_request) Successful in 35s
test / integration (pull_request) Successful in 21s
lint / lint (push) Successful in 1m44s
test / unit (push) Successful in 32s
test / integration (push) Successful in 19s
Update Quality Badges / update-badges (push) Successful in 1m17s
Replace module-level apply_routes_change wrappers with a public applicator singleton in each backend. Callers now work with the EgressApplicator instance directly (applicator.apply_routes_change) rather than through a function shim.
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
"""Host-side egress apply for the macos-container backend.
|
|
|
|
Uses `container kill --signal HUP` (Apple Container framework) instead
|
|
of `docker kill` to signal the sidecar bundle.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import subprocess
|
|
|
|
from ...log import warn
|
|
from ..egress_apply import EgressApplicator, EgressApplyError
|
|
from .launch import sidecar_container_name
|
|
|
|
|
|
class MacOSContainerEgressApplicator(EgressApplicator):
|
|
def _signal_bundle_reload(self, slug: str) -> None:
|
|
container = sidecar_container_name(slug)
|
|
result = subprocess.run(
|
|
["container", "kill", "--signal", "HUP", container],
|
|
capture_output=True, text=True, check=False, env=os.environ,
|
|
)
|
|
if result.returncode != 0:
|
|
last_error = (result.stderr or "").strip() or (result.stdout or "").strip()
|
|
warn(
|
|
f"egress: routes updated on disk for {slug}, but bundle reload failed: "
|
|
f"{last_error or 'container kill failed'}"
|
|
)
|
|
raise EgressApplyError(
|
|
f"could not reload egress bundle {container}: "
|
|
f"{last_error or 'container kill failed'}"
|
|
)
|
|
|
|
|
|
applicator = MacOSContainerEgressApplicator()
|
|
|
|
|
|
__all__ = ["MacOSContainerEgressApplicator", "EgressApplyError", "applicator"]
|