← Back to Pull requests

fix: use the CR UID as the idempotency token of FileSystem and AccessPoint #91

Closed
unknown closed this pull request without merging on Nov 19, 2026 19:12 UTC
View on GitHub
unknown unknown commented on Nov 13, 2026 07:33 UTC
Author

Issue #, if available: aws-controllers-k8s/community#3122 (the same problem in ec2-controller), aws-controllers-k8s/community#3143 (point 3: a stable idempotency token)

Description of changes:

CreateFileSystem got its CreationToken from time.Now().UTC().Nanosecond(), and CreateAccessPoint its ClientToken from time.Now().UTC().Format("20060102150405000000"), which has a resolution of one second: the trailing zeros in the layout are literal. Each Create sent a new token, so the token never protected anything. When the controller lost the response of a Create that went through (a client-side timeout, or a restart before the ID reached the status), the next reconcile found no ID, called Create again and made a second file system or access point. The first one was left behind, unmanaged and still billed. Two access points created in the same second, on the other hand, shared a token.

This change:

  • The token is the UID of the CR, as acmpca-controller does for IssueCertificate. Every Create for one CR sends the same token.

  • A repeated Create with a token EFS has already seen returns FileSystemAlreadyExists or AccessPointAlreadyExists with the ID of the resource created the first time; EFS does not return the resource itself (see aws/aws-sdk#163). A new sdk_create_post_request hook takes that ID into the status and returns the resource without an error; the reconciler reads the rest of it with ReadOne right after Create, as for any new resource.

  • EFS frees the token once the file system or access point is deleted (checked, see below), so the Create that replaces one deleted outside of the controller makes a new one with the same token.

  • When the status has no ID, the read looks the resource up by the token: DescribeFileSystems with the CreationToken, or the access points of spec.fileSystemID with that ClientToken. Without it, a CR deleted before the response of a lost Create reached the status lost its finalizer and left the resource behind (raised in review: https://github.com/aws-controllers-k8s/efs-controller/pull/91#discussion_r4611587767).

  • - The file system lookup is one filtered call and runs on any read without an ID. The access point lookup pages through every access point of the file system, which can hold thousands, so it runs only for a CR being deleted; any other read without an ID returns NotFound, and the Create that follows gets the ID from AccessPointAlreadyExists (raised in review: https://github.com/aws-controllers-k8s/efs-controller/pull/91#discussion_r4620222830).
    - The runtime ignores reference errors on delete, so for an AccessPoint with a fileSystemRef whose FileSystem CR is already gone or not synced, spec.fileSystemID is empty and the lookup is skipped: an access point whose Create response was lost is then left behind.
  • The read right after an AccessPointAlreadyExists passes requeueWaitState the access point it read, and requeueWaitState no longer returns nil, so an access point that is still creating is requeued instead of left without a state (raised in review: https://github.com/aws-controllers-k8s/efs-controller/pull/91#discussion_r4611174111).
  • pkg/resource//sdk.go was regenerated with code-generator v0.68.0; the only changes are the token call and the new hooks.

    Tests (new, against the real SDK client and an httptest server that answers like EFS):

  • the token is the CR's UID, the same on two Create calls;

  • a 409 FileSystemAlreadyExists / AccessPointAlreadyExists with an ID gives back the resource with that ID and no error;

  • any other error is returned as before;

  • after a 409 AccessPointAlreadyExists, the read of a creating access point asks for a requeue after a non-zero duration;

  • without an ID in the status, the read finds the file system by CreationToken, and the read of an access point being deleted finds it by ClientToken; without a match it returns NotFound, and without a UID it sends no request;

  • the read of an access point without an ID that is not being deleted sends no request.
  • Against the current code, the first two fail for both resources; the read tests fail on cc18cf1, the head of this PR before the review, and the last one fails on 71b29ad. go test ./... passes.

    Checked against real EFS in a sandbox account (ap-southeast-1). Runs 1 and 2 were made before the review; run 3 checks the first two review follow-ups (c66f4de, 71b29ad), and run 4 the last one (6f1e116).

    1. The API itself, with a small program (source below) that calls it with aws-sdk-go-v2/service/efs v1.34.7, the controller's version, and matches the errors with errors.As on the SDK types, as the hook does:

    | Call | Result |
    |---|---|
    | CreateFileSystem twice with the same CreationToken | the second returns FileSystemAlreadyExists with the first file system's FileSystemId |
    | CreateAccessPoint twice with the same ClientToken | the second returns AccessPointAlreadyExists with the first access point's AccessPointId |
    | CreateAccessPoint with the ClientToken of a deleted access point | a new access point |
    | CreateFileSystem with the CreationToken of a deleted file system | a new file system |

    2. The controller, killed right after Create. On kind, this controller built from main and from this branch, both against a runtime test build (diff below) that exits once per kind right after Create returns, before the ID reaches the status, as a controller killed at that moment would. The scenario (script below): a FileSystem; once it is synced after the restart, an AccessPoint with a fileSystemRef to it; once that is synced after the second restart, both CRs deleted.

    | | main | this PR |
    |---|---|---|
    | FileSystem after the restart | a second file system; the CR has its ID, the first one is in no CR | FileSystemAlreadyExists; the CR has the ID of the file system created before the exit; one file system |
    | AccessPoint after the restart | a second access point on the same file system; the first one is in no CR | AccessPointAlreadyExists; the CR has the ID of the access point created before the exit; one access point |
    | Conditions | ACK.ResourceSynced=True, Ready=True: nothing shows the duplicate | the same |
    | After deleting both CRs | the first file system is still in the account (the extra access point went away with its file system) | nothing is left |

    CloudTrail has every Create call the controller made in both runs, with the tokens it sent:

    time      call               token                                 result
    --- main ---
    07:26:07  CreateFileSystem   376771331                             fs-09730fc28278c4819  <- exit, the ID is lost
    07:26:09  CreateFileSystem   487146129                             fs-0034cbeef90de6bf4  (second file system)
    07:26:44  CreateAccessPoint  20261113072644000000                  fsap-0a8688e7ff6bac5a0  <- exit, the ID is lost
    07:26:58  CreateAccessPoint  20261113072658000000                  fsap-0269dcbbc9881db30  (second access point)
    --- this PR ---
    07:28:02  CreateFileSystem   6199311f-04f0-420a-9f4b-18b2b67c28d7  fs-0feba524f72127709  <- exit, the ID is lost
    07:28:04  CreateFileSystem   6199311f-04f0-420a-9f4b-18b2b67c28d7  FileSystemAlreadyExists: "File system 'fs-0feba524f72127709' already exists with creation token '6199311f-…'"
    07:28:40  CreateAccessPoint  48c2881f-7e36-48d2-91dc-6a52a447d406  fsap-09fd788fb64b374a3  <- exit, the ID is lost
    07:28:52  CreateAccessPoint  48c2881f-7e36-48d2-91dc-6a52a447d406  AccessPointAlreadyExists
    

    On main, every Create sends a new token: nanoseconds for file systems, and for access points the time to the second with six literal zeros. With this PR, the token is the CR's UID, the same on the retry, and EFS answers with the resource it already made.

    Everything the runs created was deleted afterwards.

    Not tested against moto: its FileSystemAlreadyExists carries no FileSystemId, and it does not check the ClientToken of access points at all.

    Raw output and sources (the account ID is replaced with 111122223333):

    3. The review follow-ups. A test (source below, build tag realefs) calls the controller's own code with the real SDK client: it creates a file system and an access point through sdkCreate / Create with a made-up UID as the token, calls Create again with the same UID, and then reads them without an ID in the status. The same test on cc18cf1, the head of this PR before the review, and on 71b29ad:

    | | cc18cf1 | 71b29ad |
    |---|---|---|
    | Second Create with the same UID | FileSystemAlreadyExists / AccessPointAlreadyExists, same ID | the same |
    | ReadOne right after the AccessPointAlreadyExists, access point creating | (
    requeue.RequeueNeededAfter)(nil): no requeue | requeue after 10s, "accesspoint in 'creating' state" |
    | Read without an ID in the status | NotFound, for both | finds the file system by CreationToken and the access point by ClientToken, both still creating |
    | Read with an unknown UID, or for a file system that does not exist | not run | NotFound |

    Everything the test created was deleted at the end of each run.

    <details><summary>Run 3 output, 71b29ad</summary>

    realefs_test.go:67: 0. file system fs-051fee4883a684aec available
        realefs_test.go:84: 1. Create: fsap-025c992e9839291d6, state creating, token ack-efs-review-ap-1794994648570780000
        realefs_test.go:91: 2. second Create with the same UID (AccessPointAlreadyExists): ID fsap-025c992e9839291d6 (same: true), state in the result: <nil>
        realefs_test.go:100: 3. ReadOne right after: requeue after 10s: "accesspoint in 'creating' state, requeuing until accesspoint is 'available'"
        realefs_test.go:112: 4. sdkFind without ID in the status: found fsap-025c992e9839291d6 (same: true), state creating, err=accesspoint in 'creating' state, requeuing until accesspoint is 'available'
        realefs_test.go:121: 5. sdkFind with an unknown UID: err=resource not found
        realefs_test.go:129: 6. sdkFind with a file system that does not exist: err=resource not found
        realefs_test.go:45: cleanup: DeleteAccessPoint fsap-025c992e9839291d6: err=<nil>
        realefs_test.go:55: cleanup: DeleteFileSystem fs-051fee4883a684aec: err=<nil>
    --- PASS: TestRealEFS_AccessPoint (17.56s)
    ok  	github.com/aws-controllers-k8s/efs-controller/pkg/resource/access_point	18.071s
        realefs_test.go:43: 1. sdkCreate: fs-05d549f9015c7b966, state creating, token ack-efs-review-1794994640052269000
        realefs_test.go:60: 2. second sdkCreate with the same UID: ID fs-05d549f9015c7b966 (same: true)
        realefs_test.go:66: 3. sdkFind without ID in the status: found fs-05d549f9015c7b966 (same: true), state creating
        realefs_test.go:75: 4. sdkFind with an unknown UID: err=resource not found
        realefs_test.go:53: cleanup: DeleteFileSystem fs-05d549f9015c7b966: err=<nil>
    --- PASS: TestRealEFS_FileSystemFoundByCreationToken (11.15s)
    ok  	github.com/aws-controllers-k8s/efs-controller/pkg/resource/file_system	11.633s
    

    </details>

    <details><summary>Run 3 output, cc18cf1</summary>

    realefs_test.go:67: 0. file system fs-0ca6069f9a0335762 available
        realefs_test.go:84: 1. Create: fsap-02c897c70fcdf8b73, state creating, token ack-efs-review-ap-1794994681252619000
        realefs_test.go:91: 2. second Create with the same UID (AccessPointAlreadyExists): ID fsap-02c897c70fcdf8b73 (same: true), state in the result: <nil>
        realefs_test.go:105: 3. ReadOne right after: err=(*requeue.RequeueNeededAfter)(nil)
        realefs_test.go:110: 4. sdkFind without ID: resource not found
        realefs_test.go:45: cleanup: DeleteAccessPoint fsap-02c897c70fcdf8b73: err=<nil>
        realefs_test.go:55: cleanup: DeleteFileSystem fs-0ca6069f9a0335762: err=<nil>
    --- FAIL: TestRealEFS_AccessPoint (15.50s)
    FAIL
    FAIL	github.com/aws-controllers-k8s/efs-controller/pkg/resource/access_point	16.065s
    FAIL
        realefs_test.go:43: 1. sdkCreate: fs-0dc0f015550748f89, state creating, token ack-efs-review-1794994720164818000
        realefs_test.go:60: 2. second sdkCreate with the same UID: ID fs-0dc0f015550748f89 (same: true)
        realefs_test.go:64: 3. sdkFind without ID: resource not found
        realefs_test.go:53: cleanup: DeleteFileSystem fs-0dc0f015550748f89: err=<nil>
    --- FAIL: TestRealEFS_FileSystemFoundByCreationToken (8.77s)
    FAIL
    FAIL	github.com/aws-controllers-k8s/efs-controller/pkg/resource/file_system	9.317s
    FAIL
    

    </details>

    4. The access point lookup only for a CR being deleted (6f1e116). The same test, changed for it (the source below is this version; beingDeleted is the helper from hooks_test.go): the read without an ID is made once for a CR that is not being deleted (step 4a) and then for one with a deletion timestamp (steps 4 to 6), and step 7 does what the runtime's deleteResource does for a CR deleted before the ID reached the status: ReadOne without an ID, then Delete of what it read. The file system test is unchanged and was run again on the same head.

    | | 6f1e116 |
    |---|---|
    | Read without an ID, CR not being deleted | NotFound, no lookup |
    | Read without an ID, CR being deleted | finds the access point by ClientToken |
    | The same with an unknown UID, or for a file system that does not exist | NotFound |
    | ReadOne without an ID, then Delete, CR being deleted | deletes the access point created for the CR; DescribeAccessPoints then returns AccessPointNotFound |
    | File system: second Create, read without an ID | as in run 3 |

    Everything the test created was deleted; afterwards the account had no file systems left in the region.

    <details><summary>Run 4 output, 6f1e116</summary>

        realefs_test.go:67: 0. file system fs-0cd4c43ae3fbdccc6 available
        realefs_test.go:84: 1. Create: fsap-0087c878eed320d9c, state creating, token ack-efs-review-ap-1795041539644570000
        realefs_test.go:91: 2. second Create with the same UID (AccessPointAlreadyExists): ID fsap-0087c878eed320d9c (same: true), state in the result: <nil>
        realefs_test.go:100: 3. ReadOne right after: requeue after 10s: "accesspoint in 'creating' state, requeuing until accesspoint is 'available'"
        realefs_test.go:109: 4a. sdkFind without ID, CR not being deleted: err=resource not found
        realefs_test.go:118: 4. sdkFind without ID in the status, CR being deleted: found fsap-0087c878eed320d9c (same: true), state available, err=<nil>
        realefs_test.go:127: 5. sdkFind with an unknown UID, CR being deleted: err=resource not found
        realefs_test.go:135: 6. sdkFind with a file system that does not exist, CR being deleted: err=resource not found
        realefs_test.go:166: 7. ReadOne without ID, CR being deleted, then Delete: deleted fsap-0087c878eed320d9c (same: true); DescribeAccessPoints after: err=operation error EFS: DescribeAccessPoints, https response error StatusCode: 404, RequestID: 98fd9842-ef97-41a8-9331-8494bbecbf42, AccessPointNotFound: Access point 'fsap-0087c878eed320d9c' does not exist.
        realefs_test.go:45: cleanup: DeleteAccessPoint fsap-0087c878eed320d9c: err=operation error EFS: DeleteAccessPoint, https response error StatusCode: 404, RequestID: be5f7923-3d01-4ad2-bb93-8df1b7302641, AccessPointNotFound: Access point 'fsap-0087c878eed320d9c' does not exist.
        realefs_test.go:55: cleanup: DeleteFileSystem fs-0cd4c43ae3fbdccc6: err=<nil>
    --- PASS: TestRealEFS_AccessPoint (19.32s)
    ok  	github.com/aws-controllers-k8s/efs-controller/pkg/resource/access_point	19.842s
        realefs_test.go:43: 1. sdkCreate: fs-0fcd32e2da8ca204e, state creating, token ack-efs-review-1795041531791550000
        realefs_test.go:60: 2. second sdkCreate with the same UID: ID fs-0fcd32e2da8ca204e (same: true)
        realefs_test.go:66: 3. sdkFind without ID in the status: found fs-0fcd32e2da8ca204e (same: true), state creating
        realefs_test.go:75: 4. sdkFind with an unknown UID: err=resource not found
        realefs_test.go:53: cleanup: DeleteFileSystem fs-0fcd32e2da8ca204e: err=<nil>
    --- PASS: TestRealEFS_FileSystemFoundByCreationToken (11.17s)
    ok  	github.com/aws-controllers-k8s/efs-controller/pkg/resource/file_system	11.665s
    

    </details>

    <details><summary>Run 3 and 4 test, <code>pkg/resource/access_point/realefs_test.go</code> (run 4 version; run 3 had no steps 4a and 7, and steps 4 to 6 read a CR not being deleted)</summary>

    //go:build realefs
    
    package access_point
    
    import (
    	"context"
    	"errors"
    	"fmt"
    	"testing"
    	"time"
    
    	ackerr "github.com/aws-controllers-k8s/runtime/pkg/errors"
    	ackmetrics "github.com/aws-controllers-k8s/runtime/pkg/metrics"
    	ackrequeue "github.com/aws-controllers-k8s/runtime/pkg/requeue"
    	"github.com/aws/aws-sdk-go-v2/aws"
    	"github.com/aws/aws-sdk-go-v2/config"
    	svcsdk "github.com/aws/aws-sdk-go-v2/service/efs"
    	svcsdktypes "github.com/aws/aws-sdk-go-v2/service/efs/types"
    	"k8s.io/apimachinery/pkg/types"
    
    	svcapitypes "github.com/aws-controllers-k8s/efs-controller/apis/v1alpha1"
    )
    
    func TestRealEFS_AccessPoint(t *testing.T) {
    	ctx := context.Background()
    	cfg, err := config.LoadDefaultConfig(ctx) // AWS_PROFILE and AWS_REGION from the environment
    	if err != nil {
    		t.Fatal(err)
    	}
    	client := svcsdk.NewFromConfig(cfg)
    	rm := &resourceManager{metrics: ackmetrics.NewMetrics("efs"), sdkapi: client}
    	tag := []svcsdktypes.Tag{{Key: aws.String("ack-efs-idempotency-test"), Value: aws.String("review")}}
    
    	fs, err := client.CreateFileSystem(ctx, &svcsdk.CreateFileSystemInput{
    		CreationToken: aws.String(fmt.Sprintf("ack-efs-review-fs-%d", time.Now().UnixNano())), Tags: tag,
    	})
    	if err != nil {
    		t.Fatal(err)
    	}
    	fsID := *fs.FileSystemId
    	var apIDs []string
    	t.Cleanup(func() {
    		for _, id := range apIDs {
    			_, err := client.DeleteAccessPoint(ctx, &svcsdk.DeleteAccessPointInput{AccessPointId: aws.String(id)})
    			t.Logf("cleanup: DeleteAccessPoint %s: err=%v", id, err)
    		}
    		for i := 0; i < 60; i++ {
    			out, _ := client.DescribeAccessPoints(ctx, &svcsdk.DescribeAccessPointsInput{FileSystemId: &fsID})
    			if out != nil && len(out.AccessPoints) == 0 {
    				break
    			}
    			time.Sleep(5 * time.Second)
    		}
    		_, err := client.DeleteFileSystem(ctx, &svcsdk.DeleteFileSystemInput{FileSystemId: &fsID})
    		t.Logf("cleanup: DeleteFileSystem %s: err=%v", fsID, err)
    	})
    	for i := 0; ; i++ {
    		out, err := client.DescribeFileSystems(ctx, &svcsdk.DescribeFileSystemsInput{FileSystemId: &fsID})
    		if err == nil && out.FileSystems[0].LifeCycleState == svcsdktypes.LifeCycleStateAvailable {
    			break
    		}
    		if i > 60 {
    			t.Fatalf("file system %s not available", fsID)
    		}
    		time.Sleep(5 * time.Second)
    	}
    	t.Logf("0. file system %s available", fsID)
    
    	uid := fmt.Sprintf("ack-efs-review-ap-%d", time.Now().UnixNano())
    	cr := func() *resource {
    		ko := &svcapitypes.AccessPoint{}
    		ko.UID = types.UID(uid)
    		ko.Spec.FileSystemID = aws.String(fsID)
    		ko.Spec.Tags = []*svcapitypes.Tag{{Key: aws.String("ack-efs-idempotency-test"), Value: aws.String("review")}}
    		return &resource{ko}
    	}
    
    	created, err := rm.Create(ctx, cr())
    	if err != nil {
    		t.Fatalf("Create: %v", err)
    	}
    	apID := *created.(*resource).ko.Status.AccessPointID
    	apIDs = append(apIDs, apID)
    	t.Logf("1. Create: %s, state %s, token %s", apID, aws.ToString(created.(*resource).ko.Status.LifeCycleState), uid)
    
    	again, err := rm.Create(ctx, cr())
    	if err != nil {
    		t.Fatalf("second Create: %v", err)
    	}
    	againID := *again.(*resource).ko.Status.AccessPointID
    	t.Logf("2. second Create with the same UID (AccessPointAlreadyExists): ID %s (same: %v), state in the result: %v",
    		againID, againID == apID, again.(*resource).ko.Status.LifeCycleState)
    
    	_, err = rm.ReadOne(ctx, again)
    	var requeue *ackrequeue.RequeueNeededAfter
    	switch {
    	case err == nil:
    		t.Logf("3. ReadOne right after: no error (the access point was already available)")
    	case errors.As(err, &requeue) && requeue != nil:
    		t.Logf("3. ReadOne right after: requeue after %s: %q", requeue.Duration(), requeue.Error())
    		if requeue.Duration() <= 0 {
    			t.Errorf("requeue after %s, want a non-zero duration", requeue.Duration())
    		}
    	default:
    		t.Errorf("3. ReadOne right after: err=%#v", err)
    	}
    
    	_, err = rm.sdkFind(ctx, cr())
    	t.Logf("4a. sdkFind without ID, CR not being deleted: err=%v", err)
    	if err != ackerr.NotFound {
    		t.Errorf("sdkFind without ID, not being deleted: err=%v, want NotFound", err)
    	}
    
    	found, err := rm.sdkFind(ctx, beingDeleted(cr()))
    	if err != nil && !errors.As(err, &requeue) {
    		t.Fatalf("4. sdkFind without ID, CR being deleted: %v", err)
    	}
    	t.Logf("4. sdkFind without ID in the status, CR being deleted: found %s (same: %v), state %s, err=%v",
    		aws.ToString(found.ko.Status.AccessPointID), aws.ToString(found.ko.Status.AccessPointID) == apID, aws.ToString(found.ko.Status.LifeCycleState), err)
    	if aws.ToString(found.ko.Status.AccessPointID) != apID {
    		t.Errorf("sdkFind found %v, want %s", found.ko.Status.AccessPointID, apID)
    	}
    
    	other := beingDeleted(cr())
    	other.ko.UID = types.UID(uid + "-other")
    	_, err = rm.sdkFind(ctx, other)
    	t.Logf("5. sdkFind with an unknown UID, CR being deleted: err=%v", err)
    	if err != ackerr.NotFound {
    		t.Errorf("sdkFind with an unknown UID: err=%v, want NotFound", err)
    	}
    
    	gone := beingDeleted(cr())
    	gone.ko.Spec.FileSystemID = aws.String("fs-0000000000000000f")
    	_, err = rm.sdkFind(ctx, gone)
    	t.Logf("6. sdkFind with a file system that does not exist, CR being deleted: err=%v", err)
    	if err != ackerr.NotFound {
    		t.Errorf("sdkFind with a missing file system: err=%v, want NotFound", err)
    	}
    
    	// What the runtime's deleteResource does for a CR deleted before the ID
    	// reached the status: ReadOne, then Delete what it read. ReadOne asks for
    	// a requeue while the access point is not available yet.
    	var observed *resource
    	for i := 0; ; i++ {
    		read, err := rm.ReadOne(ctx, beingDeleted(cr()))
    		if err == nil {
    			observed = read.(*resource)
    			break
    		}
    		if !errors.As(err, &requeue) || i > 24 {
    			t.Fatalf("7. ReadOne without ID, CR being deleted: %v", err)
    		}
    		time.Sleep(5 * time.Second)
    	}
    	if _, err := rm.Delete(ctx, observed); err != nil {
    		t.Fatalf("7. Delete: %v", err)
    	}
    	var apNotFound *svcsdktypes.AccessPointNotFound
    	for i := 0; i < 12; i++ {
    		_, err = client.DescribeAccessPoints(ctx, &svcsdk.DescribeAccessPointsInput{AccessPointId: aws.String(apID)})
    		if errors.As(err, &apNotFound) {
    			break
    		}
    		time.Sleep(5 * time.Second)
    	}
    	t.Logf("7. ReadOne without ID, CR being deleted, then Delete: deleted %s (same: %v); DescribeAccessPoints after: err=%v",
    		aws.ToString(observed.ko.Status.AccessPointID), aws.ToString(observed.ko.Status.AccessPointID) == apID, err)
    	if !errors.As(err, &apNotFound) {
    		t.Errorf("access point %s still there after Delete: err=%v", apID, err)
    	}
    }
    

    </details>

    <details><summary>Run 3 and 4 test, <code>pkg/resource/file_system/realefs_test.go</code></summary>

    //go:build realefs
    
    package file_system
    
    import (
    	"context"
    	"fmt"
    	"testing"
    	"time"
    
    	ackerr "github.com/aws-controllers-k8s/runtime/pkg/errors"
    	ackmetrics "github.com/aws-controllers-k8s/runtime/pkg/metrics"
    	"github.com/aws/aws-sdk-go-v2/aws"
    	"github.com/aws/aws-sdk-go-v2/config"
    	svcsdk "github.com/aws/aws-sdk-go-v2/service/efs"
    	"k8s.io/apimachinery/pkg/types"
    
    	svcapitypes "github.com/aws-controllers-k8s/efs-controller/apis/v1alpha1"
    )
    
    func TestRealEFS_FileSystemFoundByCreationToken(t *testing.T) {
    	ctx := context.Background()
    	cfg, err := config.LoadDefaultConfig(ctx) // AWS_PROFILE and AWS_REGION from the environment
    	if err != nil {
    		t.Fatal(err)
    	}
    	client := svcsdk.NewFromConfig(cfg)
    	rm := &resourceManager{metrics: ackmetrics.NewMetrics("efs"), sdkapi: client}
    
    	uid := fmt.Sprintf("ack-efs-review-%d", time.Now().UnixNano())
    	cr := func() *resource {
    		ko := &svcapitypes.FileSystem{}
    		ko.UID = types.UID(uid)
    		ko.Spec.Tags = []*svcapitypes.Tag{{Key: aws.String("ack-efs-idempotency-test"), Value: aws.String("review")}}
    		return &resource{ko}
    	}
    
    	created, err := rm.sdkCreate(ctx, cr())
    	if err != nil {
    		t.Fatalf("sdkCreate: %v", err)
    	}
    	id := *created.ko.Status.FileSystemID
    	t.Logf("1. sdkCreate: %s, state %s, token %s", id, aws.ToString(created.ko.Status.LifeCycleState), uid)
    	t.Cleanup(func() {
    		for i := 0; i < 60; i++ {
    			out, err := client.DescribeFileSystems(ctx, &svcsdk.DescribeFileSystemsInput{FileSystemId: &id})
    			if err == nil && len(out.FileSystems) == 1 && out.FileSystems[0].LifeCycleState == "available" {
    				break
    			}
    			time.Sleep(5 * time.Second)
    		}
    		_, err := client.DeleteFileSystem(ctx, &svcsdk.DeleteFileSystemInput{FileSystemId: &id})
    		t.Logf("cleanup: DeleteFileSystem %s: err=%v", id, err)
    	})
    
    	again, err := rm.sdkCreate(ctx, cr())
    	if err != nil {
    		t.Fatalf("second sdkCreate: %v", err)
    	}
    	t.Logf("2. second sdkCreate with the same UID: ID %s (same: %v)", *again.ko.Status.FileSystemID, *again.ko.Status.FileSystemID == id)
    
    	found, err := rm.sdkFind(ctx, cr())
    	if err != nil {
    		t.Fatalf("3. sdkFind without ID: %v", err)
    	}
    	t.Logf("3. sdkFind without ID in the status: found %s (same: %v), state %s",
    		aws.ToString(found.ko.Status.FileSystemID), aws.ToString(found.ko.Status.FileSystemID) == id, aws.ToString(found.ko.Status.LifeCycleState))
    	if aws.ToString(found.ko.Status.FileSystemID) != id {
    		t.Errorf("sdkFind found %v, want %s", found.ko.Status.FileSystemID, id)
    	}
    
    	other := cr()
    	other.ko.UID = types.UID(uid + "-other")
    	_, err = rm.sdkFind(ctx, other)
    	t.Logf("4. sdkFind with an unknown UID: err=%v", err)
    	if err != ackerr.NotFound {
    		t.Errorf("sdkFind with an unknown UID: err=%v, want NotFound", err)
    	}
    }
    

    </details>

    <details><summary>Scenario output, <code>main</code></summary>

    [07:26:06] variant base, tag e2e-base-072600, pod ack-efs-controller-7fb7c554fb-ml6kt, restarts 0
    [07:26:06] FileSystem fs-base applied
    [07:26:42] restarts: 1
    [07:26:42] crash line (previous container): arn:aws:elasticfilesystem:ap-southeast-1:111122223333:file-system/fs-09730fc28278c4819
    [07:26:42] "already created" lines after the restart: 0
    [07:26:42] CR status.fileSystemID: fs-0034cbeef90de6bf4
        ACK.ResourceSynced=True Resource synced successfully
        Ready=True Resource synced successfully
    [07:26:44] file systems tagged e2e-base-072600 in AWS: fs-0034cbeef90de6bf4:available fs-09730fc28278c4819:available 
    [07:26:44] AccessPoint ap-base applied
    [07:27:09] restarts: 2
    [07:27:09] crash line (previous container): arn:aws:elasticfilesystem:ap-southeast-1:111122223333:access-point/fsap-0a8688e7ff6bac5a0
    [07:27:09] "already created" lines after the restart: 0
    [07:27:09] CR status.accessPointID: fsap-0269dcbbc9881db30
        ACK.ReferencesResolved=True 
        ACK.ResourceSynced=True Resource synced successfully
        Ready=True Resource synced successfully
    [07:27:11] access points on fs-0034cbeef90de6bf4 in AWS: fsap-0a8688e7ff6bac5a0:available fsap-0269dcbbc9881db30:available 
    [07:27:12] file systems tagged e2e-base-072600 in AWS: fs-0034cbeef90de6bf4:available fs-09730fc28278c4819:available 
    [07:27:23] after deleting both CRs: CRs left: 
    [07:27:24] file systems tagged e2e-base-072600 left in AWS: fs-09730fc28278c4819:available 
    [07:27:27]   access points on fs-09730fc28278c4819:
    

    </details>

    <details><summary>Scenario output, this PR</summary>

    [07:28:01] variant fix, tag e2e-fix-072755, pod ack-efs-controller-6d6899b484-mhmrq, restarts 0
    [07:28:01] FileSystem fs-fix applied
    [07:28:37] restarts: 1
    [07:28:37] crash line (previous container): arn:aws:elasticfilesystem:ap-southeast-1:111122223333:file-system/fs-0feba524f72127709
    [07:28:37] "already created" lines after the restart: 1
    [07:28:37] CR status.fileSystemID: fs-0feba524f72127709
        ACK.ResourceSynced=True Resource synced successfully
        Ready=True Resource synced successfully
    [07:28:39] file systems tagged e2e-fix-072755 in AWS: fs-0feba524f72127709:available 
    [07:28:39] AccessPoint ap-fix applied
    [07:28:54] restarts: 2
    [07:28:54] crash line (previous container): arn:aws:elasticfilesystem:ap-southeast-1:111122223333:access-point/fsap-09fd788fb64b374a3
    [07:28:55] "already created" lines after the restart: 1
    [07:28:55] CR status.accessPointID: fsap-09fd788fb64b374a3
        ACK.ReferencesResolved=True 
        ACK.ResourceSynced=True Resource synced successfully
        Ready=True Resource synced successfully
    [07:28:56] access points on fs-0feba524f72127709 in AWS: fsap-09fd788fb64b374a3:available 
    [07:28:57] file systems tagged e2e-fix-072755 in AWS: fs-0feba524f72127709:available 
    [07:29:08] after deleting both CRs: CRs left: 
    [07:29:09] file systems tagged e2e-fix-072755 left in AWS:
    

    </details>

    <details><summary>Controller log after the second restart, this PR</summary>

    The runtime logs created new resource whenever sdkCreate returns no error, here right after the hook took the existing ID.

    2026-11-13T07:28:52.998Z	INFO	ackrt	access point already created for this resource, using it	{"kind": "AccessPoint", "namespace": "efs-e2e", "name": "ap-fix", "account": "111122223333", "role": "", "region": "ap-southeast-1", "is_adopted": false, "generation": 1, "id": "fsap-09fd788fb64b374a3"}
    2026-11-13T07:28:53.253Z	INFO	ackrt	created new resource	{"kind": "AccessPoint", "namespace": "efs-e2e", "name": "ap-fix", "account": "111122223333", "role": "", "region": "ap-southeast-1", "is_adopted": false, "generation": 1}
    

    </details>

    <details><summary>API check output</summary>

    CreateFileSystem #1: fs-06b46d3b288de87c2
    PASS 1. CreateFileSystem #2, same token: FileSystemAlreadyExists with FileSystemId fs-06b46d3b288de87c2
    CreateAccessPoint #1: fsap-079d678bac582c6a9
    PASS 2. CreateAccessPoint #2, same token: AccessPointAlreadyExists with AccessPointId fsap-079d678bac582c6a9
    INFO 3. CreateAccessPoint after DeleteAccessPoint, same token: a new access point fsap-07d2b800b4fe864c2 (the token is free again)
    PASS 3. CreateAccessPoint with <token>-<old id> (55 chars): a new access point fsap-0e69826d5348b3b72
    PASS 4. CreateFileSystem after DeleteFileSystem, same token: a new file system fs-049748887b2cebb7f
    cleanup: file system fs-049748887b2cebb7f
    cleanup: nothing tagged ack-efs-idempotency-test left
    

    </details>

    <details><summary>Runtime test build: exit once per kind right after <code>Create</code> (on runtime <code>main</code>, 283af82)</summary>

    diff --git a/pkg/runtime/reconciler.go b/pkg/runtime/reconciler.go
    index 0381a0b..2628cbb 100644
    --- a/pkg/runtime/reconciler.go
    +++ b/pkg/runtime/reconciler.go
    @@ -17,6 +17,7 @@ import (
     	"context"
     	"encoding/json"
     	"fmt"
    +	"os"
     	"strings"
     	"time"
     
    @@ -912,6 +913,20 @@ func (r *resourceReconciler) createResource(
     		return latest, err
     	}
     
    +	// E2E ONLY: die once per kind between Create and ReadOne, like a killed controller.
    +	if os.Getenv("ACK_E2E_CRASH_AFTER_CREATE") != "" {
    +		marker := "/crash/done-" + r.rd.GroupVersionKind().Kind
    +		if _, statErr := os.Stat(marker); statErr != nil {
    +			_ = os.WriteFile(marker, nil, 0o644)
    +			arn := ""
    +			if a := latest.Identifiers().ARN(); a != nil {
    +				arn = string(*a)
    +			}
    +			rlog.Info("E2E: crashing after create", "arn", arn)
    +			os.Exit(3)
    +		}
    +	}
    +
     	rlog.Enter("rm.ReadOne")
     	observed, err := rm.ReadOne(ctx, latest)
     	rlog.Exit("rm.ReadOne", err)
    

    </details>

    <details><summary>Controller deployment (credentials of the sandbox account in the <code>aws-creds</code> Secret; CRDs from <code>config/crd</code>)</summary>

    apiVersion: v1
    kind: ServiceAccount
    metadata: {name: ack-efs-controller, namespace: ack-system}
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata: {name: ack-efs-verify-admin}
    roleRef: {apiGroup: rbac.authorization.k8s.io, kind: ClusterRole, name: cluster-admin}
    subjects: [{kind: ServiceAccount, name: ack-efs-controller, namespace: ack-system}]
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata: {name: ack-efs-controller, namespace: ack-system}
    spec:
      replicas: 1
      selector: {matchLabels: {app: ack-efs}}
      template:
        metadata: {labels: {app: ack-efs}}
        spec:
          serviceAccountName: ack-efs-controller
          containers:
          - name: controller
            image: ack-efs-verify:IMAGE
            imagePullPolicy: Never
            args:
            - --aws-region=ap-southeast-1
            - --enable-development-logging
            - --log-level=debug
            - --enable-carm=false
            - --enable-leader-election=false
            env:
            - {name: ACK_SYSTEM_NAMESPACE, value: ack-system}
            - {name: ACK_E2E_CRASH_AFTER_CREATE, value: "1"}
            envFrom: [{secretRef: {name: aws-creds}}]
            volumeMounts: [{name: crash, mountPath: /crash}]
          volumes: [{name: crash, emptyDir: {}}]
    

    </details>

    <details><summary>Scenario script</summary>

    #!/bin/bash
    # usage: efs-crash.sh <base|fix>
    S=$(cd "$(dirname "$0")" && pwd)
    V=$1; NS=efs-e2e; OUT=$S/out-efs-$V.txt; : > $OUT
    TAG=e2e-$V-$(date -u +%H%M%S)
    log(){ echo "[$(date -u +%H:%M:%S)] $*" | tee -a $OUT; }
    awsc(){ command aws --region ap-southeast-1 "$@"; }
    tagged_fs(){ awsc efs describe-file-systems --query "FileSystems[?Tags[?Key=='ack-efs-idempotency-test' && Value=='$TAG']].[FileSystemId,LifeCycleState]" --output text | tr '\t\n' ': ' ; }
    aps_of(){ awsc efs describe-access-points --file-system-id $1 --query 'AccessPoints[].[AccessPointId,LifeCycleState]' --output text 2>&1 | tr '\t\n' ': '; }
    pod(){ kubectl -n ack-system get pod -l app=ack-efs -o jsonpath='{.items[0].metadata.name}'; }
    restarts(){ kubectl -n ack-system get pod -l app=ack-efs -o jsonpath='{.items[0].status.containerStatuses[0].restartCount}'; }
    synced(){ kubectl -n $NS get $1 $2 -o jsonpath='{.status.conditions[?(@.type=="ACK.ResourceSynced")].status}' 2>/dev/null; }
    conds(){ kubectl -n $NS get $1 $2 -o json | jq -r '.status.conditions[]? | "    \(.type)=\(.status) \(.message // "" | .[0:140])"' | tee -a $OUT; }
    wait_for(){ local what=$1 n=$2; shift 2; for i in $(seq 1 $n); do "$@" && return 0; sleep 5; done; log "TIMEOUT waiting for $what"; return 1; }
    
    kubectl create ns ack-system >/dev/null 2>&1; kubectl create ns $NS >/dev/null 2>&1
    sed "s/IMAGE/$V/" $S/deploy-efs.yaml | kubectl apply -f - >/dev/null
    kubectl -n ack-system rollout status deploy/ack-efs-controller --timeout=120s >/dev/null; sleep 5
    log "variant $V, tag $TAG, pod $(pod), restarts $(restarts)"
    
    # FileSystem
    cat <<Y | kubectl apply -f - >/dev/null
    apiVersion: efs.services.k8s.aws/v1alpha1
    kind: FileSystem
    metadata: {name: fs-$V, namespace: $NS}
    spec:
      tags:
      - {key: ack-efs-idempotency-test, value: $TAG}
      - {key: Name, value: ack-efs-e2e-$V}
    Y
    log "FileSystem fs-$V applied"
    wait_for "FileSystem synced after a restart" 60 bash -c "[ \"\$(kubectl -n ack-system get pod -l app=ack-efs -o jsonpath='{.items[0].status.containerStatuses[0].restartCount}')\" -ge 1 ] && [ \"\$(kubectl -n $NS get filesystem fs-$V -o jsonpath='{.status.conditions[?(@.type==\"ACK.ResourceSynced\")].status}')\" = True ]"
    log "restarts: $(restarts)"
    log "crash line (previous container): $(kubectl -n ack-system logs $(pod) --previous 2>/dev/null | grep 'E2E: crashing after create' | grep -o 'arn:[^\"]*' | head -1)"
    log "\"already created\" lines after the restart: $(kubectl -n ack-system logs $(pod) | grep -c 'already created for this resource')"
    FSID=$(kubectl -n $NS get filesystem fs-$V -o jsonpath='{.status.fileSystemID}')
    log "CR status.fileSystemID: $FSID"
    conds filesystem fs-$V
    log "file systems tagged $TAG in AWS: $(tagged_fs)"
    
    # AccessPoint
    cat <<Y | kubectl apply -f - >/dev/null
    apiVersion: efs.services.k8s.aws/v1alpha1
    kind: AccessPoint
    metadata: {name: ap-$V, namespace: $NS}
    spec:
      fileSystemRef: {from: {name: fs-$V}}
      tags:
      - {key: ack-efs-idempotency-test, value: $TAG}
    Y
    log "AccessPoint ap-$V applied"
    wait_for "AccessPoint synced after a second restart" 60 bash -c "[ \"\$(kubectl -n ack-system get pod -l app=ack-efs -o jsonpath='{.items[0].status.containerStatuses[0].restartCount}')\" -ge 2 ] && [ \"\$(kubectl -n $NS get accesspoint ap-$V -o jsonpath='{.status.conditions[?(@.type==\"ACK.ResourceSynced\")].status}')\" = True ]"
    log "restarts: $(restarts)"
    log "crash line (previous container): $(kubectl -n ack-system logs $(pod) --previous 2>/dev/null | grep 'E2E: crashing after create' | grep -o 'arn:[^\"]*' | head -1)"
    log "\"already created\" lines after the restart: $(kubectl -n ack-system logs $(pod) | grep -c 'already created for this resource')"
    log "CR status.accessPointID: $(kubectl -n $NS get accesspoint ap-$V -o jsonpath='{.status.accessPointID}')"
    conds accesspoint ap-$V
    log "access points on $FSID in AWS: $(aps_of $FSID)"
    log "file systems tagged $TAG in AWS: $(tagged_fs)"
    
    # delete the CRs
    kubectl -n $NS delete accesspoint ap-$V --wait=false >/dev/null
    wait_for "AccessPoint CR gone" 24 bash -c "! kubectl -n $NS get accesspoint ap-$V >/dev/null 2>&1"
    kubectl -n $NS delete filesystem fs-$V --wait=false >/dev/null
    wait_for "FileSystem CR gone" 24 bash -c "! kubectl -n $NS get filesystem fs-$V >/dev/null 2>&1"
    log "after deleting both CRs: CRs left: $(kubectl -n $NS get filesystem,accesspoint -o name 2>/dev/null | tr '\n' ' ')"
    log "file systems tagged $TAG left in AWS: $(tagged_fs)"
    for id in $(awsc efs describe-file-systems --query "FileSystems[?Tags[?Key=='ack-efs-idempotency-test' && Value=='$TAG']].FileSystemId" --output text); do log "  access points on $id: $(aps_of $id)"; done
    kubectl -n $NS get filesystem fs-$V -o json 2>/dev/null | jq -r '.status.conditions[]? | "    FS CR \(.type)=\(.status) \(.message // "" | .[0:160])"' | tee -a $OUT
    

    </details>

    <details><summary>API check program</summary>

    // efs-idempotency checks against the real EFS API what a stable
    // idempotency token in efs-controller relies on:
    //
    //  1. CreateFileSystem with a CreationToken EFS has seen returns
    //     FileSystemAlreadyExists carrying the ID of the first file system.
    //  2. CreateAccessPoint with a ClientToken EFS has seen returns
    //     AccessPointAlreadyExists carrying the ID of the first access point.
    //  3. After DeleteAccessPoint, the same ClientToken: a new access point, or
    //     AlreadyExists for the deleted one? (undocumented; the first version of
    //     the change added the old ID to the token in case the token stays taken,
    //     and this also checks that such a token makes a new access point)
    //  4. After DeleteFileSystem, the same CreationToken makes a new file system
    //     (documented).
    //
    // Everything it creates is tagged ack-efs-idempotency-test=<run id> and
    // deleted at the end; -cleanup deletes whatever a failed run left behind.
    // An empty file system and access points cost next to nothing; no VPC or
    // mount target is needed.
    package main
    
    import (
    	"context"
    	"errors"
    	"flag"
    	"fmt"
    	"os"
    	"time"
    
    	"github.com/aws/aws-sdk-go-v2/aws"
    	"github.com/aws/aws-sdk-go-v2/config"
    	"github.com/aws/aws-sdk-go-v2/service/efs"
    	efstypes "github.com/aws/aws-sdk-go-v2/service/efs/types"
    	"github.com/aws/aws-sdk-go-v2/service/sts"
    )
    
    const tagKey = "ack-efs-idempotency-test"
    
    var (
    	profile = flag.String("profile", "", "AWS profile (required)")
    	region  = flag.String("region", "", "AWS region (required)")
    	cleanup = flag.Bool("cleanup", false, "only delete what earlier runs left behind")
    	failed  = false
    )
    
    func main() {
    	flag.Parse()
    	if *profile == "" || *region == "" {
    		flag.Usage()
    		os.Exit(2)
    	}
    	ctx := context.Background()
    	cfg, err := config.LoadDefaultConfig(ctx, config.WithSharedConfigProfile(*profile), config.WithRegion(*region))
    	must(err)
    	id, err := sts.NewFromConfig(cfg).GetCallerIdentity(ctx, &sts.GetCallerIdentityInput{})
    	must(err)
    	fmt.Printf("account %s, region %s, as %s\n", *id.Account, *region, *id.Arn)
    	c := efs.NewFromConfig(cfg)
    
    	if *cleanup {
    		cleanupAll(ctx, c)
    		return
    	}
    	func() {
    		defer func() {
    			if r := recover(); r != nil {
    				fail("error: %v", r)
    			}
    		}()
    		run(ctx, c)
    	}()
    	cleanupAll(ctx, c)
    	if failed {
    		os.Exit(1)
    	}
    }
    
    func run(ctx context.Context, c *efs.Client) {
    	runID := time.Now().UTC().Format("20060102T150405Z")
    	tags := []efstypes.Tag{{Key: aws.String(tagKey), Value: aws.String(runID)}}
    	fsToken := "ack-efs-idem-fs-" + runID
    	apToken := "ack-efs-idem-ap-" + runID
    
    	// 1. file system, same token twice
    	fs1, err := c.CreateFileSystem(ctx, &efs.CreateFileSystemInput{CreationToken: &fsToken, Tags: tags})
    	must(err)
    	fmt.Printf("CreateFileSystem #1: %s\n", *fs1.FileSystemId)
    	_, err = c.CreateFileSystem(ctx, &efs.CreateFileSystemInput{CreationToken: &fsToken, Tags: tags})
    	var fsExists *efstypes.FileSystemAlreadyExists
    	switch {
    	case errors.As(err, &fsExists) && aws.ToString(fsExists.FileSystemId) == *fs1.FileSystemId:
    		pass("1. CreateFileSystem #2, same token: FileSystemAlreadyExists with FileSystemId %s", *fsExists.FileSystemId)
    	default:
    		fail("1. CreateFileSystem #2, same token: want FileSystemAlreadyExists with %s, got %v", *fs1.FileSystemId, describe(err, fsExists))
    	}
    	waitFileSystem(ctx, c, *fs1.FileSystemId, efstypes.LifeCycleStateAvailable)
    
    	// 2. access point, same token twice
    	ap1, err := c.CreateAccessPoint(ctx, &efs.CreateAccessPointInput{ClientToken: &apToken, FileSystemId: fs1.FileSystemId, Tags: tags})
    	must(err)
    	fmt.Printf("CreateAccessPoint #1: %s\n", *ap1.AccessPointId)
    	_, err = c.CreateAccessPoint(ctx, &efs.CreateAccessPointInput{ClientToken: &apToken, FileSystemId: fs1.FileSystemId, Tags: tags})
    	var apExists *efstypes.AccessPointAlreadyExists
    	switch {
    	case errors.As(err, &apExists) && aws.ToString(apExists.AccessPointId) == *ap1.AccessPointId:
    		pass("2. CreateAccessPoint #2, same token: AccessPointAlreadyExists with AccessPointId %s", *apExists.AccessPointId)
    	default:
    		fail("2. CreateAccessPoint #2, same token: want AccessPointAlreadyExists with %s, got %v", *ap1.AccessPointId, describe(err, apExists))
    	}
    
    	// 3. access point deleted, same token again
    	_, err = c.DeleteAccessPoint(ctx, &efs.DeleteAccessPointInput{AccessPointId: ap1.AccessPointId})
    	must(err)
    	waitAccessPointGone(ctx, c, *ap1.AccessPointId)
    	ap2, err := c.CreateAccessPoint(ctx, &efs.CreateAccessPointInput{ClientToken: &apToken, FileSystemId: fs1.FileSystemId, Tags: tags})
    	apExists = nil
    	switch {
    	case err == nil:
    		fmt.Printf("INFO 3. CreateAccessPoint after DeleteAccessPoint, same token: a new access point %s (the token is free again)\n", *ap2.AccessPointId)
    		_, err = c.DeleteAccessPoint(ctx, &efs.DeleteAccessPointInput{AccessPointId: ap2.AccessPointId})
    		must(err)
    		waitAccessPointGone(ctx, c, *ap2.AccessPointId)
    	case errors.As(err, &apExists):
    		fmt.Printf("INFO 3. CreateAccessPoint after DeleteAccessPoint, same token: AccessPointAlreadyExists with %s (the token stays taken; the old-ID suffix is needed)\n", aws.ToString(apExists.AccessPointId))
    	default:
    		fmt.Printf("INFO 3. CreateAccessPoint after DeleteAccessPoint, same token: %v\n", err)
    	}
    	// the token the controller sends when the status still holds the deleted ID
    	suffixed := apToken + "-" + *ap1.AccessPointId
    	ap3, err := c.CreateAccessPoint(ctx, &efs.CreateAccessPointInput{ClientToken: &suffixed, FileSystemId: fs1.FileSystemId, Tags: tags})
    	if err == nil {
    		pass("3. CreateAccessPoint with <token>-<old id> (%d chars): a new access point %s", len(suffixed), *ap3.AccessPointId)
    		_, err = c.DeleteAccessPoint(ctx, &efs.DeleteAccessPointInput{AccessPointId: ap3.AccessPointId})
    		must(err)
    		waitAccessPointGone(ctx, c, *ap3.AccessPointId)
    	} else {
    		fail("3. CreateAccessPoint with <token>-<old id>: %v", err)
    	}
    
    	// 4. file system deleted, same token again
    	_, err = c.DeleteFileSystem(ctx, &efs.DeleteFileSystemInput{FileSystemId: fs1.FileSystemId})
    	must(err)
    	waitFileSystemGone(ctx, c, *fs1.FileSystemId)
    	fs2, err := c.CreateFileSystem(ctx, &efs.CreateFileSystemInput{CreationToken: &fsToken, Tags: tags})
    	fsExists = nil
    	switch {
    	case err == nil:
    		pass("4. CreateFileSystem after DeleteFileSystem, same token: a new file system %s", *fs2.FileSystemId)
    	default:
    		fail("4. CreateFileSystem after DeleteFileSystem, same token: %v", describe(err, fsExists))
    	}
    }
    
    func describe[T any](err error, typed *T) string {
    	if typed != nil {
    		return fmt.Sprintf("%T %+v", typed, *typed)
    	}
    	return fmt.Sprintf("%v", err)
    }
    
    func cleanupAll(ctx context.Context, c *efs.Client) {
    	p := efs.NewDescribeFileSystemsPaginator(c, &efs.DescribeFileSystemsInput{})
    	for p.HasMorePages() {
    		page, err := p.NextPage(ctx)
    		must(err)
    		for _, fs := range page.FileSystems {
    			if !tagged(fs.Tags) || fs.LifeCycleState == efstypes.LifeCycleStateDeleting {
    				continue
    			}
    			aps, err := c.DescribeAccessPoints(ctx, &efs.DescribeAccessPointsInput{FileSystemId: fs.FileSystemId})
    			must(err)
    			for _, ap := range aps.AccessPoints {
    				fmt.Printf("cleanup: access point %s\n", *ap.AccessPointId)
    				_, err = c.DeleteAccessPoint(ctx, &efs.DeleteAccessPointInput{AccessPointId: ap.AccessPointId})
    				must(err)
    				waitAccessPointGone(ctx, c, *ap.AccessPointId)
    			}
    			fmt.Printf("cleanup: file system %s\n", *fs.FileSystemId)
    			_, err = c.DeleteFileSystem(ctx, &efs.DeleteFileSystemInput{FileSystemId: fs.FileSystemId})
    			must(err)
    			waitFileSystemGone(ctx, c, *fs.FileSystemId)
    		}
    	}
    	fmt.Println("cleanup: nothing tagged " + tagKey + " left")
    }
    
    func tagged(tags []efstypes.Tag) bool {
    	for _, t := range tags {
    		if aws.ToString(t.Key) == tagKey {
    			return true
    		}
    	}
    	return false
    }
    
    func waitFileSystem(ctx context.Context, c *efs.Client, id string, state efstypes.LifeCycleState) {
    	poll(func() bool {
    		out, err := c.DescribeFileSystems(ctx, &efs.DescribeFileSystemsInput{FileSystemId: &id})
    		must(err)
    		return out.FileSystems[0].LifeCycleState == state
    	}, "file system "+id+" "+string(state))
    }
    
    func waitFileSystemGone(ctx context.Context, c *efs.Client, id string) {
    	poll(func() bool {
    		_, err := c.DescribeFileSystems(ctx, &efs.DescribeFileSystemsInput{FileSystemId: &id})
    		var nf *efstypes.FileSystemNotFound
    		if errors.As(err, &nf) {
    			return true
    		}
    		must(err)
    		return false
    	}, "file system "+id+" deleted")
    }
    
    func waitAccessPointGone(ctx context.Context, c *efs.Client, id string) {
    	poll(func() bool {
    		_, err := c.DescribeAccessPoints(ctx, &efs.DescribeAccessPointsInput{AccessPointId: &id})
    		var nf *efstypes.AccessPointNotFound
    		if errors.As(err, &nf) {
    			return true
    		}
    		must(err)
    		return false
    	}, "access point "+id+" deleted")
    }
    
    func poll(done func() bool, what string) {
    	for deadline := time.Now().Add(5 * time.Minute); time.Now().Before(deadline); time.Sleep(3 * time.Second) {
    		if done() {
    			return
    		}
    	}
    	must(fmt.Errorf("timed out waiting for %s", what))
    }
    
    func pass(format string, args ...any) { fmt.Printf("PASS "+format+"\n", args...) }
    
    func fail(format string, args ...any) {
    	failed = true
    	fmt.Printf("FAIL "+format+"\n", args...)
    }
    
    func must(err error) {
    	if err != nil {
    		panic(err)
    	}
    }
    

    </details>

    By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

    🤖 Generated with Claude Code

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: blacksoxx Review duration: 9339m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.75) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.75 · 650 lines diff across 8 files
    0.75
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.075
    Real PR Conversation Timeline
    1 comments
    "Review active on #91"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 75.2% (HIGH) · Higher = larger blast radius
    75.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 29.7% · Safe to merge
    29.7%