0
0
guest image fetch resumes (finding 76); plan 0040 project record
docs/plans/0040-release-pipeline.md+3−0
| @@ -158,6 +158,9 @@ Manifest, one `httpArtifact` per binary. The CID is CIDv1 raw sha2-256 of the bi | ||
} | ||
``` | ||
| ||
Written 2026-11-16: `software.release.project/socialweb-computer` (cid bafyreidnbxkyomi6gm6zaef2a5jn5xihw6repfzezje32rqxpvzwafkwke). No channel | ||
yet: its first target is rc169 (the first published rc with the follower; rc168 never published, finding 75). | ||
| ||
Lexicons (built 2026-11-16): `lexicons/software/release/{project,defs,manifest,version,channel}.json`, Go types in | ||
`internal/atproto/release` (lexgen). | ||
| ||
docs/plans/0044-ci-by-hand.md+1−1
| @@ -380,7 +380,7 @@ everything and exits (finding 5). If its cleanup reports errors (`cleanupErrors` | ||
| 73 | Prod gate 3 (2fb0f74d), 0013 FROZEN "no answer 5 min after the first prompt": the guest's atirc-agent restarted 45 times on "the mesh identity (ATP_USERNAME, /etc/atirc/iroh_key.hex) is not in the secrets bundle yet" (its atirc.env 0 bytes). The requester wrote ATP_USERNAME at 03:14:12.158, 0.3 s after the guest.secretsUpdated it had just sent (secrets-updated-dt3dah...), and sent none after it: the event's name is `secretsUpdated` of (contract, ref URI, ref CID), and the agent path and atirc.go passed the file path with no CID, so every later change of that file was the same name and dropped as known. The guest refetched once, too early. Fix: the ref names the content (`bundleRef`: path and sha256 of the value), so each distinct bundle version sends one event. Also: a hand identity change needs every requester under `$CI_IDENTITY_DIR/requesters` recorded with the old one moved aside (0012's `qs`, 0013's `mp`, not only `stg`) | fixed (branch fix-secrets-updated-version) | | ||
| 74 | Prod gate 3: 0007:restart, the four 0014 and 0015:pressure read PASS in 0-1 s, but each was `readings.skipped` (staging only); the test host now prints its tick lines on stdout before the JSON result, so gate.sh's `jq` of that file failed and fell through to PASS (and a FAIL's note to "exit 1: readings: ..."). Fix: gate.sh reads the document from its first `{` line | fixed | | ||
| 75 | The v0.0.0-rc168 tag build (53cad0e3): `stage` "killed after 900s": two small PUTs to Spaces answered UnknownError (retried), the 545 MB arm64 binary uploaded in 26 s, the amd64 one's PUT never returned: `publish-spaces.ts` gives a request no time limit. Rerun (attempt 2). Fix: every S3 request gets a limit that grows with the file (60 s + 1 s per 5 MB), so a hung PUT is aborted and `attempt` retries it (owner, 2026-11-16: not a control) | fixed | | ||
| 76 | CI test on 62841d92, 0005 FAIL "R2 not Held in 10 min": R2's discovery kept one of 3 candidates (b1, already hosting 0005's outer VM, so every round `requester_bidder_declined` capacity 4608M of 7965M) and dropped b2 with no reason in the log (`dropped 2`). The same suite passed on 2fb0f74d and cd67bb7a. Change: `requester_bidder_discovery` names each drop (`drops: ["<did>: <reason>"]`: no fresh heartbeat, or the offering's reason) so a recurrence says why | open: rerun with the drop reasons | | ||
| 76 | CI test on 62841d92, 0005 FAIL "R2 not Held in 10 min". Cause: staging bidder b2 published no heartbeat until 17:31:48 (0006 reading `guestImageReadyAt`; b1 17:08:52), because a bidder writes no offering/heartbeat until its guest image verifies, and b2's 1.5 GB rootfs download from Spaces ran ~1 MB/s for 24 min (b1, same host, same object, same minute: 66 s; probes now 20-65 MB/s from hat-8 and from both staging VMs). `guestimage.fetchOne` had only the 30 min FetchTimeout, no per-attempt limit, no resume. R2 dropped b2 (`no fresh heartbeat`) and b1 was full. Fix: each attempt gets 60 s + 1 s per 5 MB still to fetch, then resumes with `Range` from the bytes already hashed (hand proof: a stream stalled at 10 of 40 MiB resumes and verifies in 70 s). Also: `requester_bidder_discovery` names each drop and its reason. Lesson: I cleaned up the frozen run before finding this; the cause came from the CI artifacts (0006 readings) | fixed | | ||
| ||
## Runs | ||
| ||
internal/guestimage/guestimage.go+69−14
| @@ -5,6 +5,7 @@ import ( | ||
"crypto/sha256" | ||
"encoding/hex" | ||
"encoding/json" | ||
"errors" | ||
"fmt" | ||
"io" | ||
"net/http" | ||
| @@ -211,19 +212,30 @@ func (s Store) Verify(pin Pin) (string, error) { | ||
return dir, nil | ||
} | ||
| ||
func (s Store) open(ctx context.Context, source, name string) (io.ReadCloser, error) { | ||
func (s Store) open(ctx context.Context, source, name string, offset int64) (io.ReadCloser, error) { | ||
u, err := url.Parse(source) | ||
if err != nil { | ||
return nil, fmt.Errorf("guestimage: the source %q: %w", source, err) | ||
} | ||
switch u.Scheme { | ||
case "file": | ||
return os.Open(filepath.Join(u.Path, name)) | ||
f, err := os.Open(filepath.Join(u.Path, name)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if _, err := f.Seek(offset, io.SeekStart); err != nil { | ||
f.Close() | ||
return nil, err | ||
} | ||
return f, nil | ||
case "http", "https": | ||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, strings.TrimSuffix(source, "/")+"/"+name, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if offset > 0 { | ||
req.Header.Set("Range", fmt.Sprintf("bytes=%d-", offset)) | ||
} | ||
client := s.Client | ||
if client == nil { | ||
client = http.DefaultClient | ||
| @@ -232,9 +244,13 @@ func (s Store) open(ctx context.Context, source, name string) (io.ReadCloser, er | ||
if err != nil { | ||
return nil, err | ||
} | ||
if resp.StatusCode != http.StatusOK { | ||
want := http.StatusOK | ||
if offset > 0 { | ||
want = http.StatusPartialContent | ||
} | ||
if resp.StatusCode != want { | ||
resp.Body.Close() | ||
return nil, fmt.Errorf("GET %s answered %s", req.URL, resp.Status) | ||
return nil, fmt.Errorf("%w: GET %s answered %s", errAnswered, req.URL, resp.Status) | ||
} | ||
return resp.Body, nil | ||
default: | ||
| @@ -244,6 +260,37 @@ func (s Store) open(ctx context.Context, source, name string) (io.ReadCloser, er | ||
| ||
const FetchTimeout = 30 * time.Minute | ||
| ||
const ( | ||
AttemptBase = 60 * time.Second | ||
| ||
AttemptBytesPerSecond = 5_000_000 | ||
| ||
AttemptPause = 2 * time.Second | ||
) | ||
| ||
var errAnswered = errors.New("the source answered") | ||
| ||
func attemptLimit(bytes int64) time.Duration { | ||
return AttemptBase + time.Duration(max(bytes, 0)/AttemptBytesPerSecond)*time.Second | ||
} | ||
| ||
func (s Store) fetchFrom(ctx context.Context, source, name string, want int64, w io.Writer, n *int64) error { | ||
actx, cancel := context.WithTimeout(ctx, attemptLimit(want-*n)) | ||
defer cancel() | ||
in, err := s.open(actx, source, name, *n) | ||
if err != nil { | ||
return err | ||
} | ||
defer in.Close() | ||
var src io.Reader = in | ||
if want > 0 { | ||
src = io.LimitReader(in, want-*n+1) | ||
} | ||
c, err := io.Copy(w, src) | ||
*n += c | ||
return err | ||
} | ||
| ||
type flight struct { | ||
done chan struct{} | ||
| ||
| @@ -347,11 +394,6 @@ func localSource(source string) bool { | ||
} | ||
| ||
func (s Store) fetchOne(ctx context.Context, pin Pin, source, name, dst string) error { | ||
in, err := s.open(ctx, source, name) | ||
if err != nil { | ||
return fmt.Errorf("guestimage: fetching %s of %s from %s: %w", name, pin.Target, source, err) | ||
} | ||
defer in.Close() | ||
out, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY|os.O_EXCL, 0o644) | ||
if err != nil { | ||
return fmt.Errorf("guestimage: %w", err) | ||
| @@ -360,16 +402,29 @@ func (s Store) fetchOne(ctx context.Context, pin Pin, source, name, dst string) | ||
h := sha256.New() | ||
pw := progress.New(name, want.Bytes, s.Out, s.TTY && !localSource(source), 0) | ||
defer pw.Finish() | ||
var src io.Reader = in | ||
if want.Bytes > 0 { | ||
src = io.LimitReader(in, want.Bytes+1) | ||
w := io.MultiWriter(out, h, pw) | ||
var n int64 | ||
for { | ||
err = s.fetchFrom(ctx, source, name, want.Bytes, w, &n) | ||
if err == nil && want.Bytes > 0 && n < want.Bytes { | ||
err = io.ErrUnexpectedEOF | ||
} | ||
if err == nil || ctx.Err() != nil || errors.Is(err, errAnswered) || (want.Bytes > 0 && n > want.Bytes) { | ||
break | ||
} | ||
if s.Out != nil { | ||
fmt.Fprintf(s.Out, "guestimage: %s of %s: the attempt ended at %d of %d bytes (%v); resuming from there\n", name, pin.Target, n, want.Bytes, err) | ||
} | ||
select { | ||
case <-ctx.Done(): | ||
case <-time.After(AttemptPause): | ||
} | ||
} | ||
n, err := io.Copy(io.MultiWriter(out, h, pw), src) | ||
if cerr := out.Close(); err == nil { | ||
err = cerr | ||
} | ||
if err != nil { | ||
return fmt.Errorf("guestimage: fetching %s of %s: %w", name, pin.Target, err) | ||
return fmt.Errorf("guestimage: fetching %s of %s from %s: %w", name, pin.Target, source, err) | ||
} | ||
if got := hex.EncodeToString(h.Sum(nil)); got != want.SHA256 { | ||
return fmt.Errorf("guestimage: %s of %s from %s hashes to %s and is pinned at %s; "+ | ||