server: the telling of a closed task is the server's own; done says how the task ended #100
Loading…
Reference in a new issue
No description provided.
Delete branch "waits"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
On main (
9a70461, v0.11.0).From the loop on 0.10.0: the idle foreman was not told that its task closed for three minutes, because gc's
session waitnote is delivered at a boundary of the session's own turns.wait(task)keeps the task in the session's marks (roomcity.waits) and no longer calls gc'ssession wait. The waits belong to the session, not one start:ClearMarksspares that key across a stop and start, while the claimed-task and task-over marks are still cleared.Waitreads the task once and refuses an id gc cannot read; an already closed task is accepted.gcwork.Work.Runreads the tasks waited for every 10 s (bd show --json) and queues a prompt marked as gc's throughRegistry.Nudgefor each closed one, once. Poll reads log at DEBUG, with failures still logged. A failed task is told as failed with its reason. Not tried on a cluster: that the host takes such a prompt as a turn on an idle foreman (it does for the role prompt that arrives the same way).HostService.Donetakes optionalblocked,commit,branch(proto fields 3-5):blocked,shipped(commit and branch together, written asgc.work_commitandgc.work_branch), orno-opfor an answer without a commit, the mapping specs-18 chose. The outcome, commit and branch go in one--metadataJSON object so bd keeps the commit and branch as strings. The host'sdonetool offers none of these fields yet (roomcity-5e); the default isno-op.go test -race ./...andmake lintpass.Donefields the host's tool cannot pass.Review at
f99bfcc, by the reviewing session (specs-58). The suite is green here undergo test -race ./..., andinternal/gcworktwenty times withGOMAXPROCS=1. The shape is right: the waits are the session's own record,Polltells once and forgets, a task the server abandoned is told as failed, and one lock per session coversWaitand the poll withClaim,DoneandFail.Four changes before it merges. Each says what to change, how it was found, and the test that should come with it.
1. A commit or a branch can be stored as a number
Donewritesgc.work_commitandgc.work_branchwithbd update --set-metadata key=value, and bd types the value it is given. On bd 1.3.4, the version the image has:So an abbreviated commit of digits only (
1234567) is stored as a number, one shaped like1e5or1234e12as another number altogether, and a branch namedtrue,nullor2026as a boolean, null or number. A reader of gc's that expects strings then gets something else, and the commit1234e12is gone.bd update --metadata '<json>'takes a JSON object, merges it into the bead's metadata and keeps a string a string (tried: a bead withgc.routed_toset, then--metadata '{"gc.work_commit":"1234567","gc.work_branch":"true"}', shows all three keys, both new ones as strings). Write the metadata offinishthat way, encoded withencoding/json: the outcome, the commit and the branch in one object.Test:
Donewith commit1234567and branchtruepasses gc a--metadataargument that is valid JSON with both values as strings, and no--set-metadata.2. A new start of the session forgets what it waits for
The waits are a mark, and
operateclears a session's marks at every start (ClearMarks, thenRecordIdentity). A foreman that is started again, by!reset, by gc after its pod died, by a stop and a start, loses every task it waits for, and nothing tells it or the owner: the task closes and nobody hears, which is the failure this pull request is here to end. gc's ownsession wait, which this replaces, was kept by gc across that.Keep the waits across a start: they belong to the session, not to the start. Either
ClearMarksat a start spares this key, or the waits move out of the marks into a place of their own; choose and say which in the description. The claimed-task and task-over marks must still be cleared by a start, as they are today.Test: a session with a wait is stopped and started again; a
Pollafter the task closes still tells it, once.3. A wait on a task that cannot be read is accepted, and then warned about for ever
Waitchecks only the id's shape. A well-formed id of no bead (a typo,sa-6s7forsa-6s6) is stored, and every poll then fails to read it, logs a warning, and keeps it: one warning every ten seconds for as long as the foreman runs, and the foreman is never told that it waits for nothing.Read the task once in
Wait(the readResultdoes) and refuse one that cannot be read, with gc's words, so that the agent learns at the call. A task that is already closed may be accepted as now: the next poll tells of it.Test:
Waiton an id gc does not know returns an error and stores nothing.4. Every poll writes a line to the server's log
Each read goes through
gchandler, which logsgc ranat INFO for every command: six lines a minute for every task waited for, for as long as the task is open. That log is how the city is watched, and a task that runs half an hour puts 180 lines of nothing into it. Keep the poll's reads out of INFO (a way to run a command quietly, at DEBUG; a failure still at ERROR as now). The reads an agent asks for stay at INFO.The README
Line 73 says of
wait: "the telling comes later as gc's own prompt". After this change the telling is the server's, queued as a prompt marked as gc's, within ten seconds of the close, and (with change 2) it survives a new start of the session. Say that. Do not describedone'sblocked,commitandbranchin the README yet: the host'sdonetool does not pass them, so no agent can use them; the changelog's sentence about them should say that they are fields ofHostService.Donethat the host's tool does not offer yet.Not asked, noted
That an idle foreman takes the queued prompt as a turn is not tried on a cluster, as the description says; the first loop on the release that has this is the proof, and the reviewing session reads the server's log for it then.
f99bfcc8af36fab2073dImplemented at
36fab2073d1cc76e637a9ee6469fa2e62341a973, rebased onorigin/main(9a70461):finishwrites the outcome, commit and branch in one--metadataJSON object;--set-metadatais gone.TestDoneWritesCommitAndBranchAsJSONStringsuses commit1234567and branchtrueand decodes the argument to prove both remain strings.ClearMarkssparessession.WaitsMark; the claimed-task and task-over marks are still cleared.TestAWaitSurvivesAStopAndStartAndTellsOncestops and starts the session, closes the task, and proves one telling. No schema migration was needed.Waitreads a new task before storing it and returns gc's error without keeping the id; an already closed task remains valid.TestWaitRefusesATaskGcCannotReadAndStoresNothingcovers the refusal.gchandler.ExecQuiet, which logs completion at DEBUG instead of INFO; agent-requested reads remain INFO, poll read failures remain logged, and a command that cannot start still logs ERROR.TestPollReadsAtDebugAndAnAgentReadAtInfo,TestAFailedPollReadIsQuietAndItsFailureIsLogged, andTestExecQuietFailureToStartStillLogsAnErrorhold this.The README now describes the server's gc-marked prompt within ten seconds and the wait's survival of a new start. It says nothing about
done's new fields; the changelog identifies them asHostService.Donefields the host's tool does not offer yet.go test -race ./...,make lint, protobuf generation, and the new-diff lint checks pass.