~ knotless Search/
↑↓ move↵ open⇧↵ all results

socialweb.computer/socialweb-computer-kcp

socialweb.computer: a compute market on atproto (kcp)

1 collaborator
0
0

release follower network PLC + retry; APIBinding covered (finding 77)

Merged johnandersen777.bsky.social asked to merge into main from socialweb.computer/socialweb-computer-kcp:fix-76-image-fetch
docs/plans/0044-ci-by-hand.md+1−0
@@ -381,6 +381,7 @@ everything and exits (finding 5). If its cleanup reports errors (`cleanupErrors`
| 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". 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 |
| 77 | CI test on b8b8ed18, 0006 and 0008 FAIL: b2's one startup ERROR `the HostProcess supervisor stopped` at 20:08:33.874: `APIBinding hostprocesses in root ... metadata.labels[claimed.internal.apis.kcp.io/...]: Invalid value: ""`. Cause: the computevm component and the HostProcess supervisor apply the same hostprocesses set at once (20:08:33.632/.665/.861); kcpapply skips an unchanged APIBinding only on a strict spec match, and the live spec carries the server default `deletionPolicy: Delete`, so every re-apply was an update; one landed after the create (20:08:33) and before `kcp-apibinding` stamped the claimed label (20:08:34), and admission refused it. Fix: an APIBinding is unchanged when every field the manifest declares matches the live spec (`covered`), so repeated and concurrent applies send no update | fixed |
## Runs
internal/controllers/runtime/kcpapply/kcpapply.go+31−1
@@ -395,7 +395,7 @@ func (a *Applier) applyOne(ctx context.Context, ri dynamic.ResourceInterface, u
return a.applySchema(ctx, ri, u, live, c)
}
if live != nil && u.GroupVersionKind().Group == "apis.kcp.io" && u.GetKind() == "APIBinding" &&
reflect.DeepEqual(u.Object["spec"], live.Object["spec"]) {
covered(u.Object["spec"], live.Object["spec"]) {
c.Action = Unchanged
return c, nil
}
@@ -901,3 +901,33 @@ func failedObject(u *unstructured.Unstructured) string {
}
return ""
}
func covered(want, live any) bool {
switch w := want.(type) {
case map[string]any:
l, ok := live.(map[string]any)
if !ok {
return false
}
for k, v := range w {
lv, ok := l[k]
if !ok || !covered(v, lv) {
return false
}
}
return true
case []any:
l, ok := live.([]any)
if !ok || len(l) != len(w) {
return false
}
for i := range w {
if !covered(w[i], l[i]) {
return false
}
}
return true
default:
return reflect.DeepEqual(want, live)
}
}
internal/stack/bidder/core.go+1−1
@@ -136,7 +136,7 @@ func RunCore(ctx context.Context, c CoreConfig, m hostsvc.Manager) error {
if err := notify.Ready(); err != nil {
return fmt.Errorf("bidder: telling systemd the core is ready: %w", err)
}
go followRelease(ctx, k, c.StateDir, log)
go followRelease(ctx, k, c.StateDir, c.Spec.Network, log)
<-ctx.Done()
return nil
}}, m)
internal/stack/bidder/release.go+64−21
@@ -2,14 +2,19 @@ package bidder
import (
"context"
"crypto/tls"
"crypto/x509"
"encoding/json"
"errors"
"io"
"log/slog"
"net/http"
"os"
"os/user"
"path/filepath"
"runtime"
"strings"
"time"
"github.com/bluesky-social/indigo/atproto/identity"
@@ -24,7 +29,32 @@ import (
const releaseChannelWatch = "release-channel"
func followRelease(ctx context.Context, k *Kcp, stateDir string, log *slog.Logger) {
func releaseClient(n *v1alpha1.MarketNetworkValue) (*http.Client, identity.Directory) {
client := &http.Client{Timeout: releaseReadTimeout}
if n != nil && n.CABundle != "" {
pool, err := x509.SystemCertPool()
if err != nil || pool == nil {
pool = x509.NewCertPool()
}
pool.AppendCertsFromPEM([]byte(n.CABundle))
client.Transport = &http.Transport{Proxy: http.ProxyFromEnvironment, TLSClientConfig: &tls.Config{RootCAs: pool}}
}
plc := identity.DefaultPLCURL
if n != nil && strings.TrimSpace(n.PLCDirectoryURL) != "" {
plc = strings.TrimRight(strings.TrimSpace(n.PLCDirectoryURL), "/")
}
return client, &identity.BaseDirectory{PLCURL: plc, HTTPClient: *client, PLCClient: client, SkipHandleVerification: true}
}
const (
releaseReadTimeout = 60 * time.Second
releaseDownloadTimeout = 10 * time.Minute
releaseRetry = 5 * time.Minute
)
func followRelease(ctx context.Context, k *Kcp, stateDir string, network *v1alpha1.MarketNetworkValue, log *slog.Logger) {
version, _ := buildstamp.Identity()
if buildstamp.Dev() || version == "" {
log.Info("releasefollow_off", "reason", "a dev build follows no release channel")
@@ -44,8 +74,12 @@ func followRelease(ctx context.Context, k *Kcp, stateDir string, log *slog.Logge
channel = "rc"
}
rkey := "socialweb-computer:" + channel
client, dir := releaseClient(network)
reader := market.NewHTTPReader(dir)
reader.Client = client
download := &http.Client{Transport: client.Transport, Timeout: releaseDownloadTimeout}
f := releasefollow.New(releasefollow.Config{Running: version, OS: runtime.GOOS, Arch: runtime.GOARCH,
Dir: filepath.Join(stateDir, "bin", ".incoming"), Reader: market.NewHTTPReader(identity.DefaultDirectory()), Log: log,
Dir: filepath.Join(stateDir, "bin", ".incoming"), Reader: reader, HTTP: download, Log: log,
Upgrade: func(ctx context.Context, binary, sum string) error {
return install.Upgrade(ctx, install.UpgradeOptions{StateDir: stateDir, Home: u.HomeDir, Account: u.Username,
RuntimeDir: install.OwnRuntimeDir(), Binary: binary, SHA256: sum, Out: io.Discard,
@@ -53,27 +87,36 @@ func followRelease(ctx context.Context, k *Kcp, stateDir string, log *slog.Logge
}})
log.Info("releasefollow_on", "channel", channel, "running", version)
seen := ""
_, _ = kube.Await(ctx, k.dyn.Resource(v1alpha1.AtprotoRecordWatchGVR), releaseChannelWatch, 0, func(o *v1alpha1.AtprotoRecordWatch) (bool, error) {
if o == nil {
return false, nil
}
for _, r := range o.Status.Records {
if !strings.HasSuffix(r.URI, "/"+rkey) || r.Cid == seen {
continue
for ctx.Err() == nil {
_, err := kube.Await(ctx, k.dyn.Resource(v1alpha1.AtprotoRecordWatchGVR), releaseChannelWatch, releaseRetry, func(o *v1alpha1.AtprotoRecordWatch) (bool, error) {
if o == nil {
return false, nil
}
seen = r.Cid
var value map[string]any
if err := json.Unmarshal(r.Value, &value); err != nil {
log.Warn("releasefollow_failed", "channel", r.URI, "err", err.Error())
continue
for _, r := range o.Status.Records {
if !strings.HasSuffix(r.URI, "/"+rkey) || r.Cid == seen {
continue
}
var value map[string]any
if err := json.Unmarshal(r.Value, &value); err != nil {
log.Warn("releasefollow_failed", "channel", r.URI, "err", err.Error())
continue
}
out, err := f.Follow(ctx, contract.Channel{URI: r.URI, CID: r.Cid, Value: value})
if err != nil {
log.Warn("releasefollow_failed", "channel", r.URI, "err", err.Error())
continue
}
seen = r.Cid
log.Info("releasefollow_seen", "channel", r.URI, "version", out.Version, "installed", out.Installed)
}
out, err := f.Follow(ctx, contract.Channel{URI: r.URI, CID: r.Cid, Value: value})
if err != nil {
log.Warn("releasefollow_failed", "channel", r.URI, "err", err.Error())
continue
return false, nil
})
if err != nil && ctx.Err() == nil && !errors.Is(err, kube.ErrAwaitTimeout) {
log.Warn("releasefollow_watch_failed", "watch", releaseChannelWatch, "err", err.Error())
select {
case <-ctx.Done():
case <-time.After(releaseRetry):
}
log.Info("releasefollow_seen", "channel", r.URI, "version", out.Version, "installed", out.Installed)
}
return false, nil
})
}
}