fix(reboot): reconcile collected windows99 collector readback
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 1s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Failing after 1m4s
CD Pipeline / build-and-deploy (push) Has been skipped
CD Pipeline / post-deploy-checks (push) Has been skipped

This commit is contained in:
ogt
2026-07-10 10:52:52 +08:00
parent 210d7db338
commit 23e191692b
3 changed files with 94 additions and 7 deletions

View File

@@ -122,6 +122,9 @@ _WINDOWS99_COLLECTOR_BLOCKERS_BY_STATUS = {
"blocked_remote_verify_output_invalid": "windows99_remote_verify_output_invalid",
"blocked_remote_verify_command_failed": "windows99_remote_verify_command_failed",
}
_WINDOWS99_COLLECTOR_BLOCKER_VALUES = set(
_WINDOWS99_COLLECTOR_BLOCKERS_BY_STATUS.values()
) | {"windows99_no_secret_collector_not_ready"}
_WINDOWS99_COLLECTED_VERIFY_STATUS = "collected_windows99_vmware_verify_stdout"
_WINDOWS99_MISSING_VMX_NEXT_SAFE_ACTION = (
"restore_windows99_missing_vmx_source_for_aliases_then_rerun_no_secret_"
@@ -739,10 +742,21 @@ def _apply_prometheus_windows99_no_secret_collector_readback(
available_channels = _strings(collection.get("available_collection_channels"))
if ssh_ready:
available_channels.append("no_secret_ssh_batchmode_verify_collector")
collector_blockers = _strings(collection.get("collection_blockers"))
collector_blockers = [
item
for item in _strings(collection.get("collection_blockers"))
if item not in _WINDOWS99_COLLECTOR_BLOCKER_VALUES
]
if blocker:
collector_blockers.append(blocker)
collector = _dict(collection.get("no_secret_collector"))
nested_collector_blockers = [
item
for item in _strings(collector.get("blockers"))
if item not in _WINDOWS99_COLLECTOR_BLOCKER_VALUES
]
if blocker:
nested_collector_blockers.append(blocker)
collector.update(
{
"schema_version": "windows99_vmware_verify_collector_v1",
@@ -753,6 +767,7 @@ def _apply_prometheus_windows99_no_secret_collector_readback(
"port_22_open": port_22_open,
"remote_verify_attempted": remote_attempted,
"source": "prometheus_textfile_metric",
"blockers": _unique_strings(nested_collector_blockers),
}
)
collection.update(
@@ -794,9 +809,7 @@ def _apply_prometheus_windows99_no_secret_collector_readback(
rollups["windows99_available_collection_channels"] = collection[
"available_collection_channels"
]
rollups["windows99_verify_collection_blocker_count"] = len(
_strings(collection.get("collection_blockers"))
)
_sync_windows99_verify_collection_readback(payload)
def _apply_prometheus_windows99_vmware_readback(
@@ -814,6 +827,19 @@ def _apply_prometheus_windows99_vmware_readback(
windows99_blockers = [
blocker for blocker in active_blockers if blocker.startswith("windows99_")
]
collector_status = str(
_dict(payload.get("windows99_vmware_verify_collector")).get("status")
or _dict(payload.get("windows99_verify_collection")).get(
"no_secret_collector_status"
)
or ""
)
if collector_status == _WINDOWS99_COLLECTED_VERIFY_STATUS:
windows99_blockers = [
blocker
for blocker in windows99_blockers
if blocker not in _WINDOWS99_COLLECTOR_BLOCKER_VALUES
]
verify_ready = metric_readback.get("windows99_vmware_verify_ready") is True
metric_config_ready = metric_readback.get(
"windows99_vmware_autostart_config_ready"
@@ -967,9 +993,7 @@ def _apply_prometheus_windows99_vmware_readback(
)
rollups["windows99_autostart_task_never_ran"] = scheduled_task.get("never_ran")
rollups["windows99_verify_collection_status"] = collection["status"]
rollups["windows99_verify_collection_blocker_count"] = len(
_strings(collection.get("collection_blockers"))
)
_sync_windows99_verify_collection_readback(payload)
_sync_windows99_vmx_source_repair_package(
payload,
generated_at=str(
@@ -1035,6 +1059,15 @@ def _reconcile_prometheus_metric_active_blockers_with_runtime_readbacks(
or rollups.get(ready_key) is True
):
runtime_ready_blockers.add(blocker)
collector_status = str(
_dict(payload.get("windows99_vmware_verify_collector")).get("status")
or _dict(payload.get("windows99_verify_collection")).get(
"no_secret_collector_status"
)
or ""
)
if collector_status == _WINDOWS99_COLLECTED_VERIFY_STATUS:
runtime_ready_blockers.update(_WINDOWS99_COLLECTOR_BLOCKER_VALUES)
if not runtime_ready_blockers:
return _unique_strings(active_blockers)
@@ -1068,6 +1101,27 @@ def _reconcile_prometheus_metric_active_blockers_with_runtime_readbacks(
return _unique_strings(reconciled)
def _sync_windows99_verify_collection_readback(payload: dict[str, Any]) -> None:
collection = _dict(payload.get("windows99_verify_collection"))
if not collection:
return
collection_blockers = _strings(collection.get("collection_blockers"))
status = str(collection.get("status") or "unknown")
can_collect_no_secret = collection.get("can_collect_no_secret_verify") is True
readback = _dict(payload.setdefault("readback", {}))
readback["windows99_verify_collection_status"] = status
readback["windows99_verify_collection_can_collect_no_secret"] = can_collect_no_secret
readback["windows99_verify_collection_blockers"] = collection_blockers
readback["windows99_verify_collection_blocker_count"] = len(collection_blockers)
rollups = _dict(payload.setdefault("rollups", {}))
rollups["windows99_verify_collection_status"] = status
rollups["windows99_verify_collection_can_collect_no_secret"] = can_collect_no_secret
rollups["windows99_verify_collection_blockers"] = collection_blockers
rollups["windows99_verify_collection_blocker_count"] = len(collection_blockers)
def _public_maintenance_reconciled_metric_blockers(
public_maintenance: dict[str, Any],
) -> set[str]:
@@ -2652,6 +2706,11 @@ def _build_windows99_verify_collection_packet(
if blocker not in collection_blockers:
collection_blockers.append(blocker)
for blocker in _strings(windows99_collector.get("blockers")):
if (
collector_status == _WINDOWS99_COLLECTED_VERIFY_STATUS
and blocker in _WINDOWS99_COLLECTOR_BLOCKER_VALUES
):
continue
if blocker not in collection_blockers:
collection_blockers.append(blocker)
for blocker in console_artifact_blockers: