← Inside orch contents

Chapter 4 - Worked Answers

1. Correlate a replica

Keep task id, service_id, version, node_id, container_id, desired_status, and actual_status, together with namespace and observation time. The container ID can be absent before creation. Service name identifies intent for a human but cannot distinguish two replicas, an old deployment version, or an identity created after deletion. Compare the report's task identity against the actual assigned task before updating any state.

2. Separate generic legality from report acceptance

The actual-state validator allows unhealthy to healthy, rejects failed to running, and allows failed to removed as cleanup. The agent gate adds conditions. With desired running and actual failed, only a duplicate failed report is accepted by the terminal-state branch; a removed report is rejected. With desired removed, cleanup reports including removed are accepted by the earlier desired-state branch. The order of checks matters. The generic edge does not by itself authorize an agent report. These conclusions follow directly from lifecycle.go136–187 and302–318 and the selected executed lifecycle tests.

3. Interpret three different objects

Service active describes eligibility for reconciliation. Deployment succeeded records the terminal result of a particular rollout operation. Task failed describes a particular execution identity. A later container failure does not rewrite the historical rollout result into a new result. A policy-driven replacement creates another task, associated with the service's intended version. Whether that replacement is durably recorded or recovered after restart requires inspecting the selected control plane and store, rather than reading the type definitions.

4. Reject stale health after cleanup intent

A later arrival time does not mean a report reflects later server intent. The agent could have observed health before receiving the scale-down instruction. AgentCanReportTaskStatus rejects healthy when desired status is removed, allowing only cleanup reports. Keep the task and report identifiers and inspect the desired-state branch. Do not turn an event timestamp into a distributed total order. This rejection preserves deletion intent while the next assignment poll teaches the agent what cleanup is required.

Return to Chapter 4.