host: give the move storage probe the shared stall bounds
Astra round 1, P2: T4's probe (probeStores) built its S3 client from bare options with neither bound, and runs under the instances loop's Background context while the moves pass holds the worker's mutex, so a store that took the request and went quiet blocked both for good. probeStoreOptions keeps the delivered static credentials, region, path-style endpoint and when-required checksums, and adds rootaws's StallHTTPClient and StallAPIOptions. Nothing changes for a store that answers; a stalled one now fails the probe.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+82
−16
internal/host/movesstore.go+32 −16internal/host/movesstore_stall_test.go+50 −0
diff --git a/internal/host/movesstore.go b/internal/host/movesstore.go| index 7d1b1e9e1..e0f246825 100644 |
| --- a/internal/host/movesstore.go |
| +++ b/internal/host/movesstore.go |
| @@ -16,6 +16,7 @@ import ( |
| "github.com/carlosframework/platform/internal/lease" |
| "github.com/carlosframework/platform/internal/moves" |
| "github.com/carlosframework/platform/internal/objstore" |
| + "github.com/carlosframework/platform/internal/rootaws" |
| ) |
| // The storage probes of the target's report: T4's probe of every store |
| @@ -31,6 +32,9 @@ import ( |
| // credentials, the delivered region, and the endpoint path-style when one |
| // is delivered. |
| func probeStores(ctx context.Context, env map[string]string, id string) (string, error) { |
| + // The caller's context has no deadline (the instances loop's pass), and |
| + // the pass holds the moves worker's mutex throughout, so the probe |
| + // client carries the shared stall bounds (probeStoreOptions). |
| for _, p := range storePrefixes(env) { |
| if err := probeStore(ctx, env, p, id); err != nil { |
| return p, err |
| @@ -40,22 +44,8 @@ func probeStores(ctx context.Context, env map[string]string, id string) (string, |
| } |
| func probeStore(ctx context.Context, env map[string]string, prefix, id string) error { |
| - bn, rn, en, ak, sk := objstore.EnvNames(prefix) |
| - region := env[rn] |
| - if region == "" { |
| - region = "us-east-1" |
| - } |
| - opts := awss3.Options{ |
| - Region: region, |
| - Credentials: credentials.NewStaticCredentialsProvider(env[ak], env[sk], ""), |
| - RequestChecksumCalculation: aws.RequestChecksumCalculationWhenRequired, |
| - ResponseChecksumValidation: aws.ResponseChecksumValidationWhenRequired, |
| - } |
| - if ep := env[en]; ep != "" { |
| - opts.BaseEndpoint = aws.String(ep) |
| - opts.UsePathStyle = true |
| - } |
| - c := awss3.New(opts) |
| + bn, _, _, _, _ := objstore.EnvNames(prefix) |
| + c := awss3.New(probeStoreOptions(env, prefix)) |
| bucket := aws.String(env[bn]) |
| key := aws.String(".carlos-move-probe/" + id) |
| body := []byte("carlos move probe " + id) |
| @@ -83,6 +73,32 @@ func probeStore(ctx context.Context, env map[string]string, prefix, id string) e |
| return nil |
| } |
| +// probeStoreOptions is the T4 client for the store bound at prefix: the |
| +// delivered static credentials and region, the delivered endpoint |
| +// path-style, checksums only where required, and rootaws's stall bounds |
| +// (a header timeout and a body inactivity limit), so a store that takes a |
| +// request and goes quiet fails the probe instead of holding the pass. |
| +func probeStoreOptions(env map[string]string, prefix string) awss3.Options { |
| + _, rn, en, ak, sk := objstore.EnvNames(prefix) |
| + region := env[rn] |
| + if region == "" { |
| + region = "us-east-1" |
| + } |
| + opts := awss3.Options{ |
| + Region: region, |
| + Credentials: credentials.NewStaticCredentialsProvider(env[ak], env[sk], ""), |
| + RequestChecksumCalculation: aws.RequestChecksumCalculationWhenRequired, |
| + ResponseChecksumValidation: aws.ResponseChecksumValidationWhenRequired, |
| + HTTPClient: rootaws.StallHTTPClient(), |
| + APIOptions: rootaws.StallAPIOptions(), |
| + } |
| + if ep := env[en]; ep != "" { |
| + opts.BaseEndpoint = aws.String(ep) |
| + opts.UsePathStyle = true |
| + } |
| + return opts |
| +} |
| + |
| // laneProbe is T10 in production: put-if-absent then delete-by-version of |
| // moves/_lane/<id> in the source's bucket. A probe object left by an earlier |
| // pass whose delete failed is removed by version and the check fails this |
diff --git a/internal/host/movesstore_stall_test.go b/internal/host/movesstore_stall_test.go| new file mode 100644 |
| index 000000000..77573d0d8 |
| --- /dev/null |
| +++ b/internal/host/movesstore_stall_test.go |
| @@ -0,0 +1,50 @@ |
| +package host |
| + |
| +import ( |
| + "context" |
| + "testing" |
| + |
| + "github.com/aws/aws-sdk-go-v2/aws" |
| + awshttp "github.com/aws/aws-sdk-go-v2/aws/transport/http" |
| + "github.com/aws/smithy-go/middleware" |
| + |
| + "github.com/carlosframework/platform/internal/objstore" |
| + "github.com/carlosframework/platform/internal/rootaws" |
| +) |
| + |
| +// T4's probe client runs under the moves pass with no deadline of its own, |
| +// so it carries rootaws's stall bounds, and keeps the delivered credentials, |
| +// region, endpoint and checksum settings it always had. |
| +func TestProbeStoreClientCarriesStallBounds(t *testing.T) { |
| + bn, rn, en, ak, sk := objstore.EnvNames("STORE") |
| + env := map[string]string{bn: "bkt", rn: "eu-west-2", en: "https://store.example.com", ak: "AK", sk: "SK"} |
| + o := probeStoreOptions(env, "STORE") |
| + |
| + client, ok := o.HTTPClient.(*awshttp.BuildableClient) |
| + if !ok { |
| + t.Fatalf("HTTP client is %T, want rootaws's BuildableClient", o.HTTPClient) |
| + } |
| + if h := client.GetTransport().ResponseHeaderTimeout; h != rootaws.ResponseHeaderTimeout { |
| + t.Fatalf("header timeout %s, want %s", h, rootaws.ResponseHeaderTimeout) |
| + } |
| + stack := middleware.NewStack("probe", nil) |
| + for _, fn := range o.APIOptions { |
| + if err := fn(stack); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + if _, ok := stack.Deserialize.Get("rootaws.BodyIdleTimeout"); !ok { |
| + t.Fatal("no body inactivity limit on the probe client") |
| + } |
| + |
| + creds, err := o.Credentials.Retrieve(context.Background()) |
| + if err != nil || creds.AccessKeyID != "AK" || creds.SecretAccessKey != "SK" { |
| + t.Fatalf("credentials changed: %+v %v", creds, err) |
| + } |
| + if o.Region != "eu-west-2" || o.BaseEndpoint == nil || *o.BaseEndpoint != "https://store.example.com" || !o.UsePathStyle { |
| + t.Fatalf("region or endpoint changed: %s %v %v", o.Region, o.BaseEndpoint, o.UsePathStyle) |
| + } |
| + if o.RequestChecksumCalculation != aws.RequestChecksumCalculationWhenRequired || o.ResponseChecksumValidation != aws.ResponseChecksumValidationWhenRequired { |
| + t.Fatalf("checksum settings changed: %v %v", o.RequestChecksumCalculation, o.ResponseChecksumValidation) |
| + } |
| +} |