← Inside orch contents

Chapter 2 - Worked answers

1. Follow both implementation and composition

Runtime is defined in internal/docker/docker.go47–56. EngineRuntime implements daemon calls in that file; FakeRuntime is in internal/docker/fake.go and records operations. cmd/orch-agent/main.go74–83 constructs and wraps the engine adapter, then injects it into Runner. The declaration describes a contract, the implementations describe two possible worlds, and the constructor chooses the world used by this binary. An intended internal/runtime directory would prove none of these facts.

2. Planner fixture scope

The fixture checks deterministic assignments for explicit nodes, services, pending tasks and existing resource use. It can assert no assignment on insufficient resources, bad labels or offline/draining nodes. It cannot establish that normal CreateService invoked Plan. MemoryService.reconcileServiceTasksLocked creates assigned tasks directly; compare that caller independently before claiming all ordinary deployments have planner filtering.

3. Controller restart versus process restart

A new controller using an old MemoryService tests resumption against preserved maps. It may prove repeated reconciliation avoids duplicate work for those fixture inputs. A new process creates a new MemoryService and loses those maps. The unsafe claim is process/database durability. To test it, use distinct processes and compare persisted IDs before and after, not a reused pointer.

4. Honest tool statement

“make lint completed its available fallback: tracked-Go gofmt check and go vet. golangci-lint was unavailable and was not executed.” The remaining check is the configured golangci-lint version and rules. Also record the source export/VCS context because the fallback uses git ls-files and a source copy without Git history needs deliberate handling. Do not label the fallback as a full lint run.

Reasoning answers were checked against pinned source. The chapter's selected Plan and fake-runtime tests were executed with the exact recorded command; no answer claims real daemon/database evidence.

Return to Chapter 2.