fix(recovery): accept ai loop ssh control path alias
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 35s
CD Pipeline / build-and-deploy (push) Failing after 29s
CD Pipeline / post-deploy-checks (push) Has been skipped
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 35s
CD Pipeline / build-and-deploy (push) Failing after 29s
CD Pipeline / post-deploy-checks (push) Has been skipped
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
set -euo pipefail
|
||||
|
||||
MODE="check"
|
||||
REQUESTED_MODE="--check"
|
||||
TARGET_USER="${TARGET_USER:-wooo}"
|
||||
EXPECTED_HOST_IP="${AWOOOI_110_EXPECTED_HOST_IP:-192.168.0.110}"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
@@ -18,11 +19,13 @@ RELOAD_SSH="${RELOAD_SSH:-0}"
|
||||
|
||||
usage() {
|
||||
cat <<'USAGE'
|
||||
Usage: recover-110-control-path-and-harbor-local.sh [--check|--apply-ssh-metadata|--repair-harbor-once|--apply-all]
|
||||
Usage: recover-110-control-path-and-harbor-local.sh [--check|--apply-ssh-metadata|--apply-ssh-control-path|--repair-harbor-once|--apply-all]
|
||||
|
||||
Modes:
|
||||
--check Read-only checks for SSH metadata, Harbor readiness, and controlled CD lane readiness.
|
||||
--apply-ssh-metadata Fix TARGET_USER home/.ssh/authorized_keys metadata only.
|
||||
--apply-ssh-control-path
|
||||
AI Loop alias for --apply-ssh-metadata.
|
||||
--repair-harbor-once Run one bounded Harbor watchdog repair cycle only.
|
||||
--apply-all Apply SSH metadata repair, then one Harbor repair cycle.
|
||||
|
||||
@@ -38,18 +41,22 @@ USAGE
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--check)
|
||||
MODE="check"
|
||||
;;
|
||||
--apply-ssh-metadata)
|
||||
MODE="apply_ssh_metadata"
|
||||
;;
|
||||
--repair-harbor-once)
|
||||
MODE="repair_harbor_once"
|
||||
;;
|
||||
--apply-all)
|
||||
MODE="apply_all"
|
||||
;;
|
||||
--check)
|
||||
MODE="check"
|
||||
REQUESTED_MODE="$1"
|
||||
;;
|
||||
--apply-ssh-metadata|--apply-ssh-control-path)
|
||||
MODE="apply_ssh_metadata"
|
||||
REQUESTED_MODE="$1"
|
||||
;;
|
||||
--repair-harbor-once)
|
||||
MODE="repair_harbor_once"
|
||||
REQUESTED_MODE="$1"
|
||||
;;
|
||||
--apply-all)
|
||||
MODE="apply_all"
|
||||
REQUESTED_MODE="$1"
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
@@ -184,11 +191,18 @@ run_controlled_lane_check() {
|
||||
TARGET_HOST_IP="$EXPECTED_HOST_IP" "$script"
|
||||
}
|
||||
|
||||
echo "AWOOOI_110_CONTROL_PATH_AND_HARBOR_LOCAL_RECOVERY mode=${MODE} target_user=${TARGET_USER}"
|
||||
echo "AWOOOI_110_CONTROL_PATH_AND_HARBOR_LOCAL_RECOVERY mode=${MODE} requested_mode=${REQUESTED_MODE} target_user=${TARGET_USER}"
|
||||
echo "expected_host_ip=${EXPECTED_HOST_IP}"
|
||||
echo "ssh_publickey_auth_stall_recovery_supported=true"
|
||||
echo "ssh_control_path_apply_alias_supported=true"
|
||||
echo "ssh_control_path_apply_alias=--apply-ssh-control-path"
|
||||
echo "ssh_control_path_apply_canonical_mode=--apply-ssh-metadata"
|
||||
echo "local_console_required_for_apply=true"
|
||||
echo "operation_boundary_secret_value_read=false"
|
||||
echo "operation_boundary_runner_token_read=false"
|
||||
echo "operation_boundary_raw_runner_registration_read=false"
|
||||
echo "operation_boundary_authorized_keys_content_printed=false"
|
||||
echo "operation_boundary_ssh_key_material_created=false"
|
||||
echo "operation_boundary_host_reboot_performed=false"
|
||||
echo "operation_boundary_docker_daemon_restart_performed=false"
|
||||
echo "operation_boundary_node_drain_performed=false"
|
||||
|
||||
@@ -15,11 +15,16 @@ def test_recover_110_orchestrator_contracts() -> None:
|
||||
|
||||
assert "--check" in text
|
||||
assert "--apply-ssh-metadata" in text
|
||||
assert "--apply-ssh-control-path" in text
|
||||
assert "--repair-harbor-once" in text
|
||||
assert "--apply-all" in text
|
||||
assert "operation_boundary_secret_value_read=false" in text
|
||||
assert "operation_boundary_runner_token_read=false" in text
|
||||
assert "operation_boundary_raw_runner_registration_read=false" in text
|
||||
assert "operation_boundary_authorized_keys_content_printed=false" in text
|
||||
assert "operation_boundary_ssh_key_material_created=false" in text
|
||||
assert "ssh_publickey_auth_stall_recovery_supported=true" in text
|
||||
assert "ssh_control_path_apply_alias_supported=true" in text
|
||||
assert "operation_boundary_host_reboot_performed=false" in text
|
||||
assert "operation_boundary_docker_daemon_restart_performed=false" in text
|
||||
assert "repair-110-ssh-publickey-auth-local.sh" in text
|
||||
@@ -85,6 +90,7 @@ def test_recover_110_check_uses_fake_helpers_without_writes(tmp_path: Path) -> N
|
||||
|
||||
assert result.returncode == 0, result.stdout + result.stderr
|
||||
assert "AWOOOI_110_CONTROL_PATH_AND_HARBOR_LOCAL_RECOVERY mode=check" in result.stdout
|
||||
assert "requested_mode=--check" in result.stdout
|
||||
assert "SSH_HELPER_MODE=--check" in result.stdout
|
||||
assert "HARBOR_HELPER_MODE=--check" in result.stdout
|
||||
assert "LANE_VERIFIER_MODE=check" in result.stdout
|
||||
@@ -93,3 +99,62 @@ def test_recover_110_check_uses_fake_helpers_without_writes(tmp_path: Path) -> N
|
||||
assert "LANE_VERIFIER_REGISTRATION_CONTENT_READ=false" in result.stdout
|
||||
assert "operation_boundary_secret_value_read=false" in result.stdout
|
||||
assert "operation_boundary_raw_runner_registration_read=false" in result.stdout
|
||||
|
||||
|
||||
def test_recover_110_accepts_ai_loop_apply_ssh_control_path_alias(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
ssh_helper = tmp_path / "ssh-helper.sh"
|
||||
harbor_helper = tmp_path / "harbor-helper.sh"
|
||||
lane_helper = tmp_path / "lane-helper.sh"
|
||||
ssh_helper.write_text(
|
||||
"#!/usr/bin/env bash\n"
|
||||
"echo SSH_HELPER_MODE=$1\n"
|
||||
"echo SSH_METADATA_WRITE=$([ \"$1\" = \"--apply\" ] && echo true || echo false)\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
harbor_helper.write_text(
|
||||
"#!/usr/bin/env bash\n"
|
||||
"echo HARBOR_HELPER_SHOULD_NOT_RUN=$1\n"
|
||||
"exit 70\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
lane_helper.write_text(
|
||||
"#!/usr/bin/env bash\n"
|
||||
"echo LANE_HELPER_SHOULD_NOT_RUN=$1\n"
|
||||
"exit 71\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
for helper in (ssh_helper, harbor_helper, lane_helper):
|
||||
helper.chmod(helper.stat().st_mode | stat.S_IXUSR)
|
||||
|
||||
env = {
|
||||
**os.environ,
|
||||
"ALLOW_NON_110": "1",
|
||||
"AWOOOI_110_SSH_REPAIR_SCRIPT": str(ssh_helper),
|
||||
"AWOOOI_HARBOR_WATCHDOG_SCRIPT": str(harbor_helper),
|
||||
"AWOOOI_110_CONTROLLED_LANE_VERIFIER_SCRIPT": str(lane_helper),
|
||||
}
|
||||
result = subprocess.run(
|
||||
["bash", str(RECOVERY), "--apply-ssh-control-path"],
|
||||
check=False,
|
||||
env=env,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
)
|
||||
|
||||
assert result.returncode == 0, result.stdout + result.stderr
|
||||
assert (
|
||||
"AWOOOI_110_CONTROL_PATH_AND_HARBOR_LOCAL_RECOVERY mode=apply_ssh_metadata"
|
||||
in result.stdout
|
||||
)
|
||||
assert "requested_mode=--apply-ssh-control-path" in result.stdout
|
||||
assert "ssh_control_path_apply_alias_supported=true" in result.stdout
|
||||
assert "ssh_control_path_apply_canonical_mode=--apply-ssh-metadata" in result.stdout
|
||||
assert "SSH_HELPER_MODE=--apply" in result.stdout
|
||||
assert "SSH_METADATA_WRITE=true" in result.stdout
|
||||
assert "HARBOR_HELPER_SHOULD_NOT_RUN" not in result.stdout
|
||||
assert "LANE_HELPER_SHOULD_NOT_RUN" not in result.stdout
|
||||
assert "operation_boundary_authorized_keys_content_printed=false" in result.stdout
|
||||
assert "operation_boundary_ssh_key_material_created=false" in result.stdout
|
||||
|
||||
Reference in New Issue
Block a user