region HA P1a Task 3: P0: console enrolment pass and AWS membership read removed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9 files changed,
+0
−440
internal/console/awsmembership.go+0 −16internal/console/claim_authority_census_test.go+0 −5internal/console/enrollpass.go+0 −100internal/console/enrollpass_test.go+0 −71internal/console/hostclaimops.go+0 −3internal/console/testdata/claim-authority-sites.txt+0 −3internal/hostactors/awsmembership/awsmembership.go+0 −104internal/hostactors/awsmembership/awsmembership_test.go+0 −134region_ha_boundary_test.go+0 −4
CI failed — run details
diff --git a/internal/console/awsmembership.go b/internal/console/awsmembership.go| deleted file mode 100644 |
| index 2447bafc3..000000000 |
| --- a/internal/console/awsmembership.go |
| +++ /dev/null |
| @@ -1,16 +0,0 @@ |
| -package console |
| - |
| -import ( |
| - "context" |
| - |
| - "github.com/carlosframework/platform/internal/hostactors" |
| - "github.com/carlosframework/platform/internal/hostactors/awsmembership" |
| -) |
| - |
| -// consoleMembershipReader is the enrollment pass's membership read (region |
| -// HA spec 2 §5 step 5, H28, §25): the AWS adapter, over the console's own |
| -// instance role, which 2c grants autoscaling:DescribeAutoScalingInstances |
| -// and ec2:DescribeInstances, read-only, in the deployment's AWS regions. |
| -func consoleMembershipReader(ctx context.Context) (hostactors.MembershipReader, error) { |
| - return awsmembership.New(ctx) |
| -} |
diff --git a/internal/console/claim_authority_census_test.go b/internal/console/claim_authority_census_test.go| index eb84a7ab3..89d65aab8 100644 |
| --- a/internal/console/claim_authority_census_test.go |
| +++ b/internal/console/claim_authority_census_test.go |
| @@ -43,11 +43,6 @@ func claimAuthoritySites(t *testing.T) []string { |
| "EnrollBackfillApp": true, "OpenGated": true, "WithAppMutation": true, |
| "withClaimSQL": true, "withPreparedClaimSQL": true, "RegisterIngest": true, "RecoverIngest": true, "RecoverSQLTransaction": true, "BindTransaction": true, "PrepareSQLPermit": true, "FenceSQL": true, "FenceSQLOutcome": true, "WithProjection": true, |
| "BindMutationRunner": true, "claimEnrollmentContext": true, |
| - // Region HA spec 2's automatic enrollment pass (plan 2b Task 5): its |
| - // construction hands this console's roster directory and root |
| - // signer to hostactors.AutoEnroller, its start runs it, and its one |
| - // invocation is the pass that invites and enrolls boxes. |
| - "newAutoEnroller": true, "runEnrollPass": true, "EnrollPass": true, |
| } |
| fs := token.NewFileSet() |
| var sites []string |
diff --git a/internal/console/enrollpass.go b/internal/console/enrollpass.go| deleted file mode 100644 |
| index 64cae7a6f..000000000 |
| --- a/internal/console/enrollpass.go |
| +++ /dev/null |
| @@ -1,100 +0,0 @@ |
| -package console |
| - |
| -import ( |
| - "context" |
| - "log" |
| - "time" |
| - |
| - "github.com/carlosframework/platform/internal/boxid" |
| - "github.com/carlosframework/platform/internal/hostactors" |
| - "github.com/carlosframework/platform/internal/hostops" |
| -) |
| - |
| -// The console's automatic enrollment pass (region HA spec 2 §5 step 5, |
| -// H16, H28): every enrollPassInterval it takes the next step for each box |
| -// its region's group launched that the roster does not list yet |
| -// (hostactors.AutoEnroller: attempt, invitation, guard-ready, enrollment). |
| -// It runs beside claim recovery, on a host-claim console with region HA |
| -// on, and signs with the root key this console already holds. It confirms |
| -// each box's group membership itself, with its own read-only Auto Scaling |
| -// and EC2 describes (consoleMembershipReader), immediately before it |
| -// invites and before it enrolls. The console is the only writer of the |
| -// roster and the only membership confirmer, so it is the only place this |
| -// can run. |
| - |
| -// enrollPassInterval is how often the pass runs: a box is invited, and |
| -// enrolled once its guard-ready report is published, within ten seconds. |
| -const enrollPassInterval = 10 * time.Second |
| - |
| -// enrollPatience is how long the pass keeps an attempt the cloud refused |
| -// before it begins another (doubling with each refusal). |
| -const enrollPatience = 2 * time.Minute |
| - |
| -// newAutoEnroller is the pass over this console's claim authority (its |
| -// roster, root signer, report evidence and namespace, and the default |
| -// pool) and its own membership reader. An error when either is missing. |
| -func newAutoEnroller(a *hostops.ProductionAuthority, members hostactors.MembershipReader) (*hostactors.AutoEnroller, error) { |
| - if a == nil || members == nil { |
| - return nil, hostops.ErrContract |
| - } |
| - certs, err := boxid.EmbeddedCerts() |
| - if err != nil { |
| - return nil, err |
| - } |
| - return &hostactors.AutoEnroller{Directory: a.Directory, Signer: a.Signer, Evidence: a.Evidence, Members: members, Certs: certs, |
| - Namespace: a.Namespace, Pool: "default", Now: time.Now, Patience: enrollPatience, Logf: log.Printf}, nil |
| -} |
| - |
| -// runEnrollPass runs the pass until ctx ends. Each box's step is logged |
| -// when it changes, and a failed pass on its first failure and every |
| -// tenth. |
| -func runEnrollPass(ctx context.Context, e *hostactors.AutoEnroller, every time.Duration, logf func(string, ...any)) { |
| - logf("console: automatic box enrollment armed (every %s)", every) |
| - last := map[string]string{} |
| - fails := 0 |
| - for { |
| - steps, err := e.EnrollPass(ctx) |
| - switch { |
| - case err != nil: |
| - fails++ |
| - if fails == 1 || fails%10 == 0 { |
| - logf("console: automatic box enrollment (failure #%d): %v", fails, err) |
| - } |
| - default: |
| - fails = 0 |
| - seen := map[string]bool{} |
| - for _, st := range steps { |
| - seen[st.Box] = true |
| - if last[st.Box] != st.Step { |
| - logf("console: automatic box enrollment: %s: %s", st.Box, st.Step) |
| - last[st.Box] = st.Step |
| - } |
| - } |
| - for box := range last { |
| - if !seen[box] { |
| - delete(last, box) |
| - } |
| - } |
| - } |
| - select { |
| - case <-ctx.Done(): |
| - return |
| - case <-time.After(every): |
| - } |
| - } |
| -} |
| - |
| -// startEnrollPass starts the pass for this server, or logs why it cannot. |
| -func (s *Server) startEnrollPass(ctx context.Context) { |
| - members, err := consoleMembershipReader(ctx) |
| - if err != nil { |
| - log.Printf("console: automatic box enrollment: not started: %v", err) |
| - return |
| - } |
| - e, err := newAutoEnroller(s.cfg.ClaimAuthority, members) |
| - if err != nil { |
| - log.Printf("console: automatic box enrollment: not started: %v", err) |
| - return |
| - } |
| - go runEnrollPass(ctx, e, enrollPassInterval, log.Printf) |
| -} |
diff --git a/internal/console/enrollpass_test.go b/internal/console/enrollpass_test.go| deleted file mode 100644 |
| index 87bbac2db..000000000 |
| --- a/internal/console/enrollpass_test.go |
| +++ /dev/null |
| @@ -1,71 +0,0 @@ |
| -package console |
| - |
| -import ( |
| - "context" |
| - "crypto/ed25519" |
| - "errors" |
| - "fmt" |
| - "strings" |
| - "sync" |
| - "testing" |
| - "time" |
| - |
| - "github.com/carlosframework/platform/internal/hostactors" |
| - "github.com/carlosframework/platform/internal/hostops" |
| - "github.com/carlosframework/platform/internal/release" |
| -) |
| - |
| -// noMembers is a membership reader that is never asked. |
| -type noMembers struct{} |
| - |
| -func (noMembers) Member(context.Context, string, string) (hostactors.Membership, error) { |
| - return hostactors.Membership{}, errors.New("not asked") |
| -} |
| - |
| -func TestEnrollPassIsBuiltFromTheClaimAuthority(t *testing.T) { |
| - pub, key, _ := ed25519.GenerateKey(nil) |
| - a := &hostops.ProductionAuthority{Directory: hostactors.Directory{Store: release.NewDirStore(t.TempDir()), PublicKey: pub, Bucket: "bucket"}, |
| - Signer: release.RootSigner(key), Namespace: "platform"} |
| - if _, err := newAutoEnroller(nil, noMembers{}); !errors.Is(err, hostops.ErrContract) { |
| - t.Fatalf("no authority: %v", err) |
| - } |
| - if _, err := newAutoEnroller(a, nil); !errors.Is(err, hostops.ErrContract) { |
| - t.Fatalf("no membership reader: %v", err) |
| - } |
| - e, err := newAutoEnroller(a, noMembers{}) |
| - if err != nil { |
| - t.Fatal(err) |
| - } |
| - if e.Namespace != "platform" || e.Pool != "default" || e.Patience != enrollPatience || len(e.Certs) == 0 || e.Directory.Bucket != "bucket" || e.Members != (noMembers{}) || e.Logf == nil { |
| - t.Fatalf("enroller %+v", e) |
| - } |
| -} |
| - |
| -// A pass that cannot read the roster is logged on its first failure and |
| -// every tenth, not every ten seconds, and the loop ends with its context. |
| -func TestEnrollPassLogsFailuresSparingly(t *testing.T) { |
| - pub, key, _ := ed25519.GenerateKey(nil) |
| - e := &hostactors.AutoEnroller{Directory: hostactors.Directory{Store: release.NewDirStore(t.TempDir()), PublicKey: pub, Bucket: "bucket"}, |
| - Signer: release.RootSigner(key), Namespace: "platform", Pool: "default", Now: time.Now, Patience: time.Minute} |
| - var mu sync.Mutex |
| - var lines []string |
| - logf := func(format string, args ...any) { |
| - mu.Lock() |
| - lines = append(lines, fmt.Sprintf(format, args...)) |
| - mu.Unlock() |
| - } |
| - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) |
| - defer cancel() |
| - runEnrollPass(ctx, e, 2*time.Millisecond, logf) |
| - mu.Lock() |
| - defer mu.Unlock() |
| - if len(lines) < 2 || !strings.Contains(lines[0], "armed") { |
| - t.Fatalf("lines %q", lines) |
| - } |
| - for i, l := range lines[1:] { |
| - var n int |
| - if _, err := fmt.Sscanf(l[strings.Index(l, "#"):], "#%d", &n); err != nil || (n != 1 && n%10 != 0) || (i == 0 && n != 1) { |
| - t.Fatalf("logged %q", l) |
| - } |
| - } |
| -} |
diff --git a/internal/console/hostclaimops.go b/internal/console/hostclaimops.go| index 6ca3ebffe..da3c081ee 100644 |
| --- a/internal/console/hostclaimops.go |
| +++ b/internal/console/hostclaimops.go |
| @@ -62,9 +62,6 @@ func (s *Server) StartClaimRecoveryPass(ctx context.Context) { |
| if pub := capacityPublisherFromEnv(ctx, os.Getenv); pub != nil { |
| go s.runCapacityPass(ctx, pub) |
| } |
| - // Automatic enrollment of the boxes regions' groups launch |
| - // (region HA spec 2 §5 step 5, enrollpass.go). |
| - s.startEnrollPass(ctx) |
| } |
| t := time.NewTicker(claimRecoveryInterval) |
| defer t.Stop() |
diff --git a/internal/console/testdata/claim-authority-sites.txt b/internal/console/testdata/claim-authority-sites.txt| index 8cb44d9fe..ec81b84ad 100644 |
| --- a/internal/console/testdata/claim-authority-sites.txt |
| +++ b/internal/console/testdata/claim-authority-sites.txt |
| @@ -147,6 +147,3 @@ claim_loss_pages.go|pageClaimLossesAt|s.store.db.ExecContext(ctx, `INSERT INTO c |
| claim_loss_pages.go|pageClaimLossesAt|s.store.db.QueryRowContext(ctx, `SELECT last_key FROM claim_loss_pages WHERE rule = 'scan'`) |
| store_gate.go|OpenGated|s.db.Exec(`ALTER TABLE claim_loss_pages ADD COLUMN last_key TEXT NOT NULL DEFAULT ''`) |
| awsregionmetric.go|capacityPublisherFromEnv|cloudwatch.NewFromConfig(cfg, func(o *cloudwatch.Options) { o.Region = awsRegion }) |
| -enrollpass.go|startEnrollPass|newAutoEnroller(s.cfg.ClaimAuthority, members) |
| -enrollpass.go|startEnrollPass|runEnrollPass(ctx, e, enrollPassInterval, log.Printf) |
| -enrollpass.go|runEnrollPass|e.EnrollPass(ctx) |
diff --git a/internal/hostactors/awsmembership/awsmembership.go b/internal/hostactors/awsmembership/awsmembership.go| deleted file mode 100644 |
| index 24c7f26c7..000000000 |
| --- a/internal/hostactors/awsmembership/awsmembership.go |
| +++ /dev/null |
| @@ -1,104 +0,0 @@ |
| -// Package awsmembership is the AWS adapter of the console's membership |
| -// read (region HA spec 2 §5 step 5, §25; H16, H28): read-only Auto Scaling |
| -// and EC2 describe calls, made in the AWS region the roster names for the |
| -// attempt's placement. The console role needs |
| -// autoscaling:DescribeAutoScalingInstances and ec2:DescribeInstances, |
| -// conditioned on aws:RequestedRegion being one of the deployment's AWS |
| -// regions. No box role has either. |
| -package awsmembership |
| - |
| -import ( |
| - "context" |
| - "errors" |
| - |
| - "github.com/aws/aws-sdk-go-v2/aws" |
| - awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" |
| - awshttp "github.com/aws/aws-sdk-go-v2/aws/transport/http" |
| - "github.com/aws/aws-sdk-go-v2/config" |
| - "github.com/aws/aws-sdk-go-v2/service/autoscaling" |
| - "github.com/aws/aws-sdk-go-v2/service/ec2" |
| - ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types" |
| - "github.com/aws/smithy-go/middleware" |
| - |
| - "github.com/carlosframework/platform/internal/hostactors" |
| -) |
| - |
| -// Reader is hostactors.MembershipReader over the console's own credentials. |
| -type Reader struct{ cfg aws.Config } |
| - |
| -// New loads the console's AWS configuration (its instance role). |
| -func New(ctx context.Context) (*Reader, error) { |
| - cfg, err := config.LoadDefaultConfig(ctx) |
| - if err != nil { |
| - return nil, err |
| - } |
| - return &Reader{cfg: cfg}, nil |
| -} |
| - |
| -// Member describes instance's Auto Scaling membership, then its EC2 state |
| -// and owner: two calls, two request ids. A call that fails ends the read; |
| -// the ids of the calls made come back with the error, the failed call's |
| -// from the cloud's error response (failedID). |
| -func (r *Reader) Member(ctx context.Context, awsRegion, instance string) (hostactors.Membership, error) { |
| - asg := autoscaling.NewFromConfig(r.cfg, func(o *autoscaling.Options) { o.Region = awsRegion }) |
| - ao, err := asg.DescribeAutoScalingInstances(ctx, &autoscaling.DescribeAutoScalingInstancesInput{InstanceIds: []string{instance}}) |
| - if err != nil { |
| - return hostactors.Membership{RequestIDs: []string{failedID(err)}}, err |
| - } |
| - ec := ec2.NewFromConfig(r.cfg, func(o *ec2.Options) { o.Region = awsRegion }) |
| - eo, err := ec.DescribeInstances(ctx, &ec2.DescribeInstancesInput{Filters: []ec2types.Filter{{Name: aws.String("instance-id"), Values: []string{instance}}}}) |
| - if err != nil { |
| - return hostactors.Membership{RequestIDs: []string{requestID(ao.ResultMetadata), failedID(err)}}, err |
| - } |
| - return membershipFrom(instance, ao, eo), nil |
| -} |
| - |
| -// failedID is the request id of a call that failed: the one the cloud gave |
| -// in its error response, or hostactors.NoRequestID when the call failed |
| -// before the cloud answered (no connection, a cancelled context). |
| -func failedID(err error) string { |
| - var re *awshttp.ResponseError |
| - if errors.As(err, &re) && re.ServiceRequestID() != "" { |
| - return re.ServiceRequestID() |
| - } |
| - return hostactors.NoRequestID |
| -} |
| - |
| -// membershipFrom reads the two replies. Anything but exactly the one |
| -// instance asked about, in exactly one group, is no membership. |
| -func membershipFrom(instance string, ao *autoscaling.DescribeAutoScalingInstancesOutput, eo *ec2.DescribeInstancesOutput) hostactors.Membership { |
| - m := hostactors.Membership{RequestIDs: []string{requestID(ao.ResultMetadata), requestID(eo.ResultMetadata)}} |
| - if len(ao.AutoScalingInstances) == 1 && aws.ToString(ao.AutoScalingInstances[0].InstanceId) == instance { |
| - d := ao.AutoScalingInstances[0] |
| - m.GroupName = aws.ToString(d.AutoScalingGroupName) |
| - m.LifecycleState = aws.ToString(d.LifecycleState) |
| - m.AvailabilityZoneRegion = zoneRegion(aws.ToString(d.AvailabilityZone)) |
| - } |
| - if len(eo.Reservations) == 1 && len(eo.Reservations[0].Instances) == 1 && aws.ToString(eo.Reservations[0].Instances[0].InstanceId) == instance { |
| - res := eo.Reservations[0] |
| - m.Owner = aws.ToString(res.OwnerId) |
| - if st := res.Instances[0].State; st != nil { |
| - m.InstanceState = string(st.Name) |
| - } |
| - } |
| - return m |
| -} |
| - |
| -// zoneRegion is the region of an availability zone name ("eu-west-1a" is |
| -// in "eu-west-1"): the name less one trailing letter after a digit. Any |
| -// other shape (a Local Zone, a zone id) answers "", which matches no |
| -// region. |
| -func zoneRegion(az string) string { |
| - n := len(az) |
| - if n < 3 || az[n-1] < 'a' || az[n-1] > 'z' || az[n-2] < '0' || az[n-2] > '9' { |
| - return "" |
| - } |
| - return az[:n-1] |
| -} |
| - |
| -func requestID(md middleware.Metadata) string { |
| - id, _ := awsmiddleware.GetRequestIDMetadata(md) |
| - return id |
| -} |
| - |
| -var _ hostactors.MembershipReader = (*Reader)(nil) |
diff --git a/internal/hostactors/awsmembership/awsmembership_test.go b/internal/hostactors/awsmembership/awsmembership_test.go| deleted file mode 100644 |
| index 183464251..000000000 |
| --- a/internal/hostactors/awsmembership/awsmembership_test.go |
| +++ /dev/null |
| @@ -1,134 +0,0 @@ |
| -package awsmembership |
| - |
| -import ( |
| - "context" |
| - "errors" |
| - "fmt" |
| - "io" |
| - "net/http" |
| - "reflect" |
| - "strings" |
| - "testing" |
| - |
| - "github.com/aws/aws-sdk-go-v2/aws" |
| - awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" |
| - "github.com/aws/aws-sdk-go-v2/service/autoscaling" |
| - asgtypes "github.com/aws/aws-sdk-go-v2/service/autoscaling/types" |
| - "github.com/aws/aws-sdk-go-v2/service/ec2" |
| - ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types" |
| - "github.com/aws/smithy-go/middleware" |
| - |
| - "github.com/carlosframework/platform/internal/hostactors" |
| -) |
| - |
| -func meta(id string) middleware.Metadata { |
| - var md middleware.Metadata |
| - awsmiddleware.SetRequestIDMetadata(&md, id) |
| - return md |
| -} |
| - |
| -func asgReply(instance, group, zone, state string) *autoscaling.DescribeAutoScalingInstancesOutput { |
| - return &autoscaling.DescribeAutoScalingInstancesOutput{ResultMetadata: meta("asg-req"), AutoScalingInstances: []asgtypes.AutoScalingInstanceDetails{{ |
| - InstanceId: aws.String(instance), AutoScalingGroupName: aws.String(group), AvailabilityZone: aws.String(zone), LifecycleState: aws.String(state)}}} |
| -} |
| - |
| -func ec2Reply(owner string, instances map[string]ec2types.InstanceStateName) *ec2.DescribeInstancesOutput { |
| - res := ec2types.Reservation{OwnerId: aws.String(owner)} |
| - for id, st := range instances { |
| - res.Instances = append(res.Instances, ec2types.Instance{InstanceId: aws.String(id), State: &ec2types.InstanceState{Name: st}}) |
| - } |
| - return &ec2.DescribeInstancesOutput{ResultMetadata: meta("ec2-req"), Reservations: []ec2types.Reservation{res}} |
| -} |
| - |
| -func TestMembershipFromTheTwoReplies(t *testing.T) { |
| - got := membershipFrom("i-new", asgReply("i-new", "routers-ie", "eu-west-1b", "InService"), ec2Reply("123", map[string]ec2types.InstanceStateName{"i-new": ec2types.InstanceStateNameRunning})) |
| - want := hostactors.Membership{GroupName: "routers-ie", AvailabilityZoneRegion: "eu-west-1", LifecycleState: "InService", InstanceState: "running", Owner: "123", RequestIDs: []string{"asg-req", "ec2-req"}} |
| - if !reflect.DeepEqual(got, want) { |
| - t.Fatalf("got %+v\nwant %+v", got, want) |
| - } |
| - // Not a member: Auto Scaling knows nothing of it, or answers for |
| - // another instance. EC2 knowing it changes nothing. |
| - for _, ao := range []*autoscaling.DescribeAutoScalingInstancesOutput{{ResultMetadata: meta("asg-req")}, asgReply("i-other", "routers-ie", "eu-west-1b", "InService")} { |
| - m := membershipFrom("i-new", ao, ec2Reply("123", map[string]ec2types.InstanceStateName{"i-new": ec2types.InstanceStateNameRunning})) |
| - if m.GroupName != "" || m.LifecycleState != "" { |
| - t.Fatalf("non-member read as %+v", m) |
| - } |
| - } |
| - // EC2 no longer lists it: no state and no owner. |
| - m := membershipFrom("i-new", asgReply("i-new", "routers-ie", "eu-west-1b", "Terminating"), &ec2.DescribeInstancesOutput{ResultMetadata: meta("ec2-req")}) |
| - if m.InstanceState != "" || m.Owner != "" { |
| - t.Fatalf("forgotten instance read as %+v", m) |
| - } |
| -} |
| - |
| -func TestZoneRegion(t *testing.T) { |
| - for az, want := range map[string]string{"eu-west-1a": "eu-west-1", "ap-southeast-2c": "ap-southeast-2", "us-west-2-lax-1a": "us-west-2-lax-1", "euw1-az1": "", "eu-west-1": "", "": ""} { |
| - if got := zoneRegion(az); got != want { |
| - t.Fatalf("zoneRegion(%q) = %q, want %q", az, got, want) |
| - } |
| - } |
| -} |
| - |
| -// cloudHTTP stands in for the network under the SDK: Auto Scaling and EC2 |
| -// in one region. Each service answers its reply, an error response |
| -// carrying the cloud's request id, or (down) no answer at all. |
| -type cloudHTTP struct { |
| - asg, ec2 string // "ok", "error" or "down" |
| -} |
| - |
| -func (h cloudHTTP) Do(r *http.Request) (*http.Response, error) { |
| - mode, id, okBody, errBody := h.ec2, "ec2", `<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/"><requestId>ec2-req</requestId><reservationSet><item><ownerId>123</ownerId><instancesSet><item><instanceId>i-new</instanceId><instanceState><code>16</code><name>running</name></instanceState></item></instancesSet></item></reservationSet></DescribeInstancesResponse>`, |
| - `<Response><Errors><Error><Code>UnauthorizedOperation</Code><Message>no</Message></Error></Errors><RequestID>ec2-err</RequestID></Response>` |
| - if strings.HasPrefix(r.URL.Host, "autoscaling.") { |
| - mode, id, okBody, errBody = h.asg, "asg", `<DescribeAutoScalingInstancesResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/"><DescribeAutoScalingInstancesResult><AutoScalingInstances><member><InstanceId>i-new</InstanceId><AutoScalingGroupName>routers-ie</AutoScalingGroupName><AvailabilityZone>eu-west-1b</AvailabilityZone><LifecycleState>InService</LifecycleState><HealthStatus>HEALTHY</HealthStatus><ProtectedFromScaleIn>false</ProtectedFromScaleIn></member></AutoScalingInstances></DescribeAutoScalingInstancesResult><ResponseMetadata><RequestId>asg-req</RequestId></ResponseMetadata></DescribeAutoScalingInstancesResponse>`, |
| - `<ErrorResponse><Error><Type>Sender</Type><Code>AccessDenied</Code><Message>no</Message></Error><RequestId>asg-err</RequestId></ErrorResponse>` |
| - } |
| - if r.Body != nil { |
| - _, _ = io.Copy(io.Discard, r.Body) |
| - } |
| - if !strings.Contains(r.URL.Host, ".eu-west-1.") { |
| - return nil, fmt.Errorf("a call to %s, not the attempt's AWS region", r.URL.Host) |
| - } |
| - resp := &http.Response{Header: http.Header{"Content-Type": {"text/xml"}}, Request: r, Proto: "HTTP/1.1", ProtoMajor: 1, ProtoMinor: 1} |
| - switch mode { |
| - case "down": |
| - return nil, errors.New("dial tcp: connection refused") |
| - case "error": |
| - resp.StatusCode = http.StatusForbidden |
| - resp.Header.Set("X-Amzn-Requestid", id+"-err") |
| - resp.Body = io.NopCloser(strings.NewReader(errBody)) |
| - default: |
| - resp.StatusCode = http.StatusOK |
| - resp.Header.Set("X-Amzn-Requestid", id+"-req") |
| - resp.Body = io.NopCloser(strings.NewReader(okBody)) |
| - } |
| - return resp, nil |
| -} |
| - |
| -// Member, through the SDK: both ids on success, and on a failed read the |
| -// ids of the calls made, the failed call's from the cloud's error |
| -// response, or NoRequestID when the cloud never answered. |
| -func TestMemberKeepsTheIdsOfAFailedRead(t *testing.T) { |
| - for name, c := range map[string]struct { |
| - cloud cloudHTTP |
| - ids []string |
| - fails bool |
| - }{ |
| - "both calls answer": {cloudHTTP{"ok", "ok"}, []string{"asg-req", "ec2-req"}, false}, |
| - "the second call fails": {cloudHTTP{"ok", "error"}, []string{"asg-req", "ec2-err"}, true}, |
| - "the first call fails": {cloudHTTP{"error", "ok"}, []string{"asg-err"}, true}, |
| - "the second call never reaches a cloud": {cloudHTTP{"ok", "down"}, []string{"asg-req", hostactors.NoRequestID}, true}, |
| - "the first call never reaches a cloud": {cloudHTTP{"down", "ok"}, []string{hostactors.NoRequestID}, true}, |
| - } { |
| - t.Run(name, func(t *testing.T) { |
| - r := &Reader{cfg: aws.Config{Region: "us-east-1", Credentials: aws.AnonymousCredentials{}, HTTPClient: c.cloud, Retryer: func() aws.Retryer { return aws.NopRetryer{} }}} |
| - m, err := r.Member(context.Background(), "eu-west-1", "i-new") |
| - if (err != nil) != c.fails || !reflect.DeepEqual(m.RequestIDs, c.ids) { |
| - t.Fatalf("Member: %+v, %v; want ids %v", m, err, c.ids) |
| - } |
| - if !c.fails && (m.GroupName != "routers-ie" || m.InstanceState != "running" || m.Owner != "123" || m.AvailabilityZoneRegion != "eu-west-1") { |
| - t.Fatalf("a member read as %+v", m) |
| - } |
| - }) |
| - } |
| -} |
diff --git a/region_ha_boundary_test.go b/region_ha_boundary_test.go| index 978abfbf8..fe75136a3 100644 |
| --- a/region_ha_boundary_test.go |
| +++ b/region_ha_boundary_test.go |
| @@ -38,7 +38,6 @@ var regionHACoreFiles = []string{ |
| "internal/hostactors/membershipread.go", |
| "internal/hostactors/groupref.go", |
| "internal/hostactors/autoenroll.go", |
| - "internal/console/enrollpass.go", |
| "internal/host/boxreference.go", |
| "internal/status/fleet.go", |
| "internal/host/agententry.go", |
| @@ -50,8 +49,6 @@ var regionHAAdapterFiles = []string{ |
| "internal/host/awsaddr.go", |
| "internal/console/awsregionmetric.go", |
| "internal/hostenv/awsssm.go", |
| - "internal/hostactors/awsmembership/awsmembership.go", |
| - "internal/console/awsmembership.go", |
| } |
| // regionHAPackages are the packages spec 2 touches. Every S3 client built |
| @@ -64,7 +61,6 @@ var regionHAPackages = []string{ |
| "internal/edgesfile", |
| "internal/host", |
| "internal/hostactors", |
| - "internal/hostactors/awsmembership", |
| "internal/hostenv", |
| "internal/hostops", |
| "internal/lbhealth", |