fix(agent): preserve executor boundary runtime proof
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 1s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 1m5s
CD Pipeline / build-and-deploy (push) Successful in 4m38s
CD Pipeline / post-deploy-checks (push) Has been cancelled

This commit is contained in:
ogt
2026-07-11 01:36:41 +08:00
parent 242d9ae919
commit de5e29360f
5 changed files with 74 additions and 25 deletions

View File

@@ -6309,7 +6309,25 @@ _RUNTIME_OPERATION_LATEST_SQL = """
duration_ms,
created_at
FROM automation_operation_log operation_row
WHERE coalesce(input ->> 'semantic_operation_type', operation_type) IN (
LEFT JOIN latest_apply_chain ON TRUE
WHERE operation_row.operation_type IN (
'ansible_candidate_matched',
'ansible_check_mode_executed',
'ansible_apply_executed',
'ansible_learning_writeback_recorded',
'ansible_rollback_executed',
'ansible_execution_skipped',
'ansible_executor_capability_issued',
'ansible_executor_capability_revoked',
'ansible_executor_capability_expired',
'log_controlled_writeback_dispatched',
'remediation_executed',
'km_linked'
)
AND coalesce(
operation_row.input ->> 'semantic_operation_type',
operation_row.operation_type
) IN (
'ansible_candidate_matched',
'ansible_check_mode_executed',
'ansible_apply_executed',
@@ -6323,15 +6341,14 @@ _RUNTIME_OPERATION_LATEST_SQL = """
)
ORDER BY
CASE
WHEN EXISTS (
SELECT 1
FROM latest_apply_chain
WHERE operation_row.op_id::text = latest_apply_chain.apply_op_id
OR operation_row.op_id::text = latest_apply_chain.check_mode_op_id
OR operation_row.op_id::text = latest_apply_chain.candidate_op_id
OR operation_row.input ->> 'automation_run_id'
= latest_apply_chain.candidate_op_id
) THEN 0
WHEN operation_row.op_id::text IN (
latest_apply_chain.apply_op_id,
latest_apply_chain.check_mode_op_id,
latest_apply_chain.candidate_op_id
)
OR operation_row.input ->> 'automation_run_id'
= latest_apply_chain.candidate_op_id
THEN 0
WHEN coalesce(
input ->> 'semantic_operation_type',
operation_type
@@ -6392,7 +6409,25 @@ _RUNTIME_OPERATION_LATEST_DIRECT_SQL = """
duration_ms,
created_at
FROM automation_operation_log operation_row
WHERE coalesce(input ->> 'semantic_operation_type', operation_type) IN (
LEFT JOIN latest_apply_chain ON TRUE
WHERE operation_row.operation_type IN (
'ansible_candidate_matched',
'ansible_check_mode_executed',
'ansible_apply_executed',
'ansible_learning_writeback_recorded',
'ansible_rollback_executed',
'ansible_execution_skipped',
'ansible_executor_capability_issued',
'ansible_executor_capability_revoked',
'ansible_executor_capability_expired',
'log_controlled_writeback_dispatched',
'remediation_executed',
'km_linked'
)
AND coalesce(
operation_row.input ->> 'semantic_operation_type',
operation_row.operation_type
) IN (
'ansible_candidate_matched',
'ansible_check_mode_executed',
'ansible_apply_executed',
@@ -6406,15 +6441,14 @@ _RUNTIME_OPERATION_LATEST_DIRECT_SQL = """
)
ORDER BY
CASE
WHEN EXISTS (
SELECT 1
FROM latest_apply_chain
WHERE operation_row.op_id::text = latest_apply_chain.apply_op_id
OR operation_row.op_id::text = latest_apply_chain.check_mode_op_id
OR operation_row.op_id::text = latest_apply_chain.candidate_op_id
OR operation_row.input ->> 'automation_run_id'
= latest_apply_chain.candidate_op_id
) THEN 0
WHEN operation_row.op_id::text IN (
latest_apply_chain.apply_op_id,
latest_apply_chain.check_mode_op_id,
latest_apply_chain.candidate_op_id
)
OR operation_row.input ->> 'automation_run_id'
= latest_apply_chain.candidate_op_id
THEN 0
WHEN coalesce(
input ->> 'semantic_operation_type',
operation_type

View File

@@ -120,18 +120,22 @@ async def load_executor_trust_boundary_readback(
configmap_name=configmap_name,
)
except Exception as exc: # pragma: no cover - production readback boundary
error_status = getattr(exc, "status", None)
public_error_type = type(exc).__name__
if isinstance(error_status, int):
public_error_type = f"{public_error_type}:{error_status}"
logger.warning(
"executor_trust_boundary_readback_failed",
namespace=namespace,
configmap_name=configmap_name,
error_type=type(exc).__name__,
error_type=public_error_type,
)
payload = build_executor_trust_boundary_readback(
{},
deployed_source_sha=deployed_source_sha,
namespace=namespace,
configmap_name=configmap_name,
error_type=type(exc).__name__,
error_type=public_error_type,
)
finally:
if api_client is not None: