feat: sync runtime cache through Go Agent
parent
210a1ec244
commit
9dbc6b2c84
@ -0,0 +1,32 @@
|
||||
# Go Agent runtime observation sync
|
||||
|
||||
`CloudInstanceRuntimeSyncService` now refreshes the lifecycle power-state cache
|
||||
through the fresh Go Agent protocol. It no longer calls the retired Python
|
||||
Engine or the host-wide `vm-states` endpoint.
|
||||
|
||||
The scheduler first selects a bounded, actor-independent set of non-deleted
|
||||
database instances. Every row must have a valid `host_id` and canonical VM UUID;
|
||||
the pair is retained as the only target identity. Before making a host request,
|
||||
PHP claims that runtime row's revision with `beginObservation()`. It then sends
|
||||
one signed `domain_observe` operation through `CloudAgentObservationService` to
|
||||
that exact host and UUID.
|
||||
|
||||
Only a succeeded operation whose returned UUID matches the requested UUID and
|
||||
whose state is in the panel's bounded vocabulary may call `markObserved()` with
|
||||
the claim revision. A transport timeout, uncertain operation, deterministic
|
||||
Agent rejection, malformed response, unknown state, or UUID mismatch calls
|
||||
`markUnavailable()` with the same revision. The last successful power state is
|
||||
therefore retained; an unavailable observation is never interpreted as
|
||||
`stopped`. A concurrent lifecycle/action writer can win the revision CAS, in
|
||||
which case the stale poll is counted as skipped and cannot overwrite it.
|
||||
|
||||
The returned counters remain `observed`, `unavailable`, `skipped`, and a
|
||||
bounded error-code list so existing lifecycle heartbeat diagnostics and page
|
||||
contracts remain unchanged. Each Agent observation is journaled with its
|
||||
operation ID; uncertain transport outcomes are not replayed by the scheduler.
|
||||
They require the normal operation-status/reconcile path.
|
||||
|
||||
This is a narrow readback cutover, not approval to delete all Python code. VM
|
||||
creation, reinstall/delete, network, settings, snapshots, firewall, rescue,
|
||||
console, metrics, and remaining host administration still need typed Agent
|
||||
operations and real-host acceptance before Python service units can be removed.
|
||||
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
// Static migration contract for the lifecycle runtime poller. The scheduler
|
||||
// must use one typed, explicitly addressed Agent observation per VM; a batch
|
||||
// inventory response or the retired Python/SSH transport would reintroduce a
|
||||
// host-wide authority boundary and cannot preserve per-row CAS fencing.
|
||||
$root = dirname(__DIR__);
|
||||
$assert = static function ($condition, string $message): void {
|
||||
if (!$condition) {
|
||||
throw new RuntimeException($message);
|
||||
}
|
||||
};
|
||||
|
||||
$service = file_get_contents($root . '/app/Services/Cloud/CloudInstanceRuntimeSyncService.php');
|
||||
$observation = file_get_contents($root . '/app/Services/Cloud/CloudAgentObservationService.php');
|
||||
$assert(is_string($service) && is_string($observation), 'Runtime sync sources are unreadable.');
|
||||
|
||||
$assert(str_contains($service, 'CloudAgentObservationService')
|
||||
&& str_contains($service, 'CloudAgentHostClientResolverFactory::fromConfig()')
|
||||
&& str_contains($service, '->observe($hostId, $uuid, $actor)')
|
||||
&& str_contains($service, 'CloudInstanceRuntimeService::beginObservation(')
|
||||
&& str_contains($service, 'CloudInstanceRuntimeService::markObserved(')
|
||||
&& str_contains($service, 'CloudInstanceRuntimeService::markUnavailable(')
|
||||
&& str_contains($service, 'hash_equals($uuid, $candidateUuid)')
|
||||
&& !str_contains($service, 'CloudEngineClient')
|
||||
&& !str_contains($service, 'vm-states')
|
||||
&& !str_contains($service, 'shell_exec')
|
||||
&& !str_contains($service, 'ssh'),
|
||||
'Runtime sync must use typed Agent observations and no Python/SSH or host-wide vm-states fallback.');
|
||||
|
||||
$assert(str_contains($observation, 'resolveReadOnly($hostId)')
|
||||
&& str_contains($observation, "'domain_observe'")
|
||||
&& str_contains($observation, 'markUncertain')
|
||||
&& str_contains($observation, 'observeMany'),
|
||||
'Agent observation service must keep read-only resolver, typed operation and uncertain journal semantics.');
|
||||
|
||||
echo "Cloud Agent runtime sync contract passed.\n";
|
||||
Loading…
Reference in New Issue