Skip to content

Conversation

@googs1025
Copy link
Member

Fix flaky test failure in TestInferenceModelRewriteReconciler/Add_to_existing
caused by unordered datastore returns. Kubernetes resources are unordered, so comparisons should be order-agnostic.

What type of PR is this?
/kind flake

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes None

Does this PR introduce a user-facing change?:

None

@k8s-ci-robot k8s-ci-robot added the kind/flake Categorizes issue or PR as related to a flaky test. label Dec 1, 2025
@netlify
Copy link

netlify bot commented Dec 1, 2025

Deploy Preview for gateway-api-inference-extension ready!

Name Link
🔨 Latest commit 5f794da
🔍 Latest deploy log https://app.netlify.com/projects/gateway-api-inference-extension/deploys/692d76308c241900078e3d9b
😎 Deploy Preview https://deploy-preview-1917--gateway-api-inference-extension.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot k8s-ci-robot requested a review from ahg-g December 1, 2025 02:45
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 1, 2025
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Dec 1, 2025
@googs1025
Copy link
Member Author

➜  controller git:(fix/script) ✗ go test -run TestInferenceModelRewriteReconciler/Add_to_existing -o inference_rewrite_stress.test

PASS
ok      sigs.k8s.io/gateway-api-inference-extension/pkg/epp/controller  1.591s
➜  controller git:(fix/script) ✗ stress -p 10 ./inference_rewrite_stress.test                                                     

/var/folders/j3/b8896xf92g7d60x2ghdpcnd40000gn/T/go-stress-20251201T104158-2291629586
--- FAIL: TestInferenceModelRewriteReconciler (0.11s)
    --- FAIL: TestInferenceModelRewriteReconciler/Add_to_existing (0.00s)
        inferencemodelrewrite_reconciler_test.go:218: Unexpected diff (+got/-want): rewrites:  []*v1alpha2.InferenceModelRewrite{
                &{
                        TypeMeta: {},
                        ObjectMeta: v1.ObjectMeta{
            -                   Name:         "rewrite1",
            +                   Name:         "rewrite2",
                                GenerateName: "",
                                Namespace:    "ns1",
                                ... // 2 identical fields
                                ResourceVersion:            "999",
                                Generation:                 0,
            -                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:40 +0800 CST"},
            +                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:41 +0800 CST"},
                                DeletionTimestamp:          nil,
                                DeletionGracePeriodSeconds: nil,
                                ... // 5 identical fields
                        },
                        Spec:   {PoolRef: &{Group: "inference.networking.k8s.io", Name: "test-pool1"}},
                        Status: {},
                },
                &{
                        TypeMeta: {},
                        ObjectMeta: v1.ObjectMeta{
            -                   Name:         "rewrite2",
            +                   Name:         "rewrite1",
                                GenerateName: "",
                                Namespace:    "ns1",
                                ... // 2 identical fields
                                ResourceVersion:            "999",
                                Generation:                 0,
            -                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:41 +0800 CST"},
            +                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:40 +0800 CST"},
                                DeletionTimestamp:          nil,
                                DeletionGracePeriodSeconds: nil,
                                ... // 5 identical fields
                        },
                        Spec:   {PoolRef: &{Group: "inference.networking.k8s.io", Name: "test-pool1"}},

…

/var/folders/j3/b8896xf92g7d60x2ghdpcnd40000gn/T/go-stress-20251201T104158-925102269
--- FAIL: TestInferenceModelRewriteReconciler (0.14s)
    --- FAIL: TestInferenceModelRewriteReconciler/Add_to_existing (0.00s)
        inferencemodelrewrite_reconciler_test.go:218: Unexpected diff (+got/-want): rewrites:  []*v1alpha2.InferenceModelRewrite{
                &{
                        TypeMeta: {},
                        ObjectMeta: v1.ObjectMeta{
            -                   Name:         "rewrite1",
            +                   Name:         "rewrite2",
                                GenerateName: "",
                                Namespace:    "ns1",
                                ... // 2 identical fields
                                ResourceVersion:            "999",
                                Generation:                 0,
            -                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:40 +0800 CST"},
            +                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:41 +0800 CST"},
                                DeletionTimestamp:          nil,
                                DeletionGracePeriodSeconds: nil,
                                ... // 5 identical fields
                        },
                        Spec:   {PoolRef: &{Group: "inference.networking.k8s.io", Name: "test-pool1"}},
                        Status: {},
                },
                &{
                        TypeMeta: {},
                        ObjectMeta: v1.ObjectMeta{
            -                   Name:         "rewrite2",
            +                   Name:         "rewrite1",
                                GenerateName: "",
                                Namespace:    "ns1",
                                ... // 2 identical fields
                                ResourceVersion:            "999",
                                Generation:                 0,
            -                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:41 +0800 CST"},
            +                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:40 +0800 CST"},
                                DeletionTimestamp:          nil,
                                DeletionGracePeriodSeconds: nil,
                                ... // 5 identical fields
                        },
                        Spec:   {PoolRef: &{Group: "inference.networking.k8s.io", Name: "test-pool1"}},

…

/var/folders/j3/b8896xf92g7d60x2ghdpcnd40000gn/T/go-stress-20251201T104158-2352707636
--- FAIL: TestInferenceModelRewriteReconciler (0.13s)
    --- FAIL: TestInferenceModelRewriteReconciler/Add_to_existing (0.00s)
        inferencemodelrewrite_reconciler_test.go:218: Unexpected diff (+got/-want): rewrites:  []*v1alpha2.InferenceModelRewrite{
                &{
                        TypeMeta: {},
                        ObjectMeta: v1.ObjectMeta{
            -                   Name:         "rewrite1",
            +                   Name:         "rewrite2",
                                GenerateName: "",
                                Namespace:    "ns1",
                                ... // 2 identical fields
                                ResourceVersion:            "999",
                                Generation:                 0,
            -                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:40 +0800 CST"},
            +                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:41 +0800 CST"},
                                DeletionTimestamp:          nil,
                                DeletionGracePeriodSeconds: nil,
                                ... // 5 identical fields
                        },
                        Spec:   {PoolRef: &{Group: "inference.networking.k8s.io", Name: "test-pool1"}},
                        Status: {},
                },
                &{
                        TypeMeta: {},
                        ObjectMeta: v1.ObjectMeta{
            -                   Name:         "rewrite2",
            +                   Name:         "rewrite1",
                                GenerateName: "",
                                Namespace:    "ns1",
                                ... // 2 identical fields
                                ResourceVersion:            "999",
                                Generation:                 0,
            -                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:41 +0800 CST"},
            +                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:40 +0800 CST"},
                                DeletionTimestamp:          nil,
                                DeletionGracePeriodSeconds: nil,
                                ... // 5 identical fields
                        },
                        Spec:   {PoolRef: &{Group: "inference.networking.k8s.io", Name: "test-pool1"}},

…

/var/folders/j3/b8896xf92g7d60x2ghdpcnd40000gn/T/go-stress-20251201T104158-2575921367
--- FAIL: TestInferenceModelRewriteReconciler (0.10s)
    --- FAIL: TestInferenceModelRewriteReconciler/Add_to_existing (0.00s)
        inferencemodelrewrite_reconciler_test.go:218: Unexpected diff (+got/-want): rewrites:  []*v1alpha2.InferenceModelRewrite{
                &{
                        TypeMeta: {},
                        ObjectMeta: v1.ObjectMeta{
            -                   Name:         "rewrite1",
            +                   Name:         "rewrite2",
                                GenerateName: "",
                                Namespace:    "ns1",
                                ... // 2 identical fields
                                ResourceVersion:            "999",
                                Generation:                 0,
            -                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:40 +0800 CST"},
            +                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:41 +0800 CST"},
                                DeletionTimestamp:          nil,
                                DeletionGracePeriodSeconds: nil,
                                ... // 5 identical fields
                        },
                        Spec:   {PoolRef: &{Group: "inference.networking.k8s.io", Name: "test-pool1"}},
                        Status: {},
                },
                &{
                        TypeMeta: {},
                        ObjectMeta: v1.ObjectMeta{
            -                   Name:         "rewrite2",
            +                   Name:         "rewrite1",
                                GenerateName: "",
                                Namespace:    "ns1",
                                ... // 2 identical fields
                                ResourceVersion:            "999",
                                Generation:                 0,
            -                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:41 +0800 CST"},
            +                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:40 +0800 CST"},
                                DeletionTimestamp:          nil,
                                DeletionGracePeriodSeconds: nil,
                                ... // 5 identical fields
                        },
                        Spec:   {PoolRef: &{Group: "inference.networking.k8s.io", Name: "test-pool1"}},

…

/var/folders/j3/b8896xf92g7d60x2ghdpcnd40000gn/T/go-stress-20251201T104158-564319220
--- FAIL: TestInferenceModelRewriteReconciler (0.16s)
    --- FAIL: TestInferenceModelRewriteReconciler/Add_to_existing (0.00s)
        inferencemodelrewrite_reconciler_test.go:218: Unexpected diff (+got/-want): rewrites:  []*v1alpha2.InferenceModelRewrite{
                &{
                        TypeMeta: {},
                        ObjectMeta: v1.ObjectMeta{
            -                   Name:         "rewrite1",
            +                   Name:         "rewrite2",
                                GenerateName: "",
                                Namespace:    "ns1",
                                ... // 2 identical fields
                                ResourceVersion:            "999",
                                Generation:                 0,
            -                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:40 +0800 CST"},
            +                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:41 +0800 CST"},
                                DeletionTimestamp:          nil,
                                DeletionGracePeriodSeconds: nil,
                                ... // 5 identical fields
                        },
                        Spec:   {PoolRef: &{Group: "inference.networking.k8s.io", Name: "test-pool1"}},
                        Status: {},
                },
                &{
                        TypeMeta: {},
                        ObjectMeta: v1.ObjectMeta{
            -                   Name:         "rewrite2",
            +                   Name:         "rewrite1",
                                GenerateName: "",
                                Namespace:    "ns1",
                                ... // 2 identical fields
                                ResourceVersion:            "999",
                                Generation:                 0,
            -                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:41 +0800 CST"},
            +                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:40 +0800 CST"},
                                DeletionTimestamp:          nil,
                                DeletionGracePeriodSeconds: nil,
                                ... // 5 identical fields
                        },
                        Spec:   {PoolRef: &{Group: "inference.networking.k8s.io", Name: "test-pool1"}},

…

/var/folders/j3/b8896xf92g7d60x2ghdpcnd40000gn/T/go-stress-20251201T104158-3220757661
--- FAIL: TestInferenceModelRewriteReconciler (0.13s)
    --- FAIL: TestInferenceModelRewriteReconciler/Add_to_existing (0.00s)
        inferencemodelrewrite_reconciler_test.go:218: Unexpected diff (+got/-want): rewrites:  []*v1alpha2.InferenceModelRewrite{
                &{
                        TypeMeta: {},
                        ObjectMeta: v1.ObjectMeta{
            -                   Name:         "rewrite1",
            +                   Name:         "rewrite2",
                                GenerateName: "",
                                Namespace:    "ns1",
                                ... // 2 identical fields
                                ResourceVersion:            "999",
                                Generation:                 0,
            -                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:40 +0800 CST"},
            +                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:41 +0800 CST"},
                                DeletionTimestamp:          nil,
                                DeletionGracePeriodSeconds: nil,
                                ... // 5 identical fields
                        },
                        Spec:   {PoolRef: &{Group: "inference.networking.k8s.io", Name: "test-pool1"}},
                        Status: {},
                },
                &{
                        TypeMeta: {},
                        ObjectMeta: v1.ObjectMeta{
            -                   Name:         "rewrite2",
            +                   Name:         "rewrite1",
                                GenerateName: "",
                                Namespace:    "ns1",
                                ... // 2 identical fields
                                ResourceVersion:            "999",
                                Generation:                 0,
            -                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:41 +0800 CST"},
            +                   CreationTimestamp:          v1.Time{Time: s"1970-01-01 08:16:40 +0800 CST"},
                                DeletionTimestamp:          nil,
                                DeletionGracePeriodSeconds: nil,
                                ... // 5 identical fields
                        },
                        Spec:   {PoolRef: &{Group: "inference.networking.k8s.io", Name: "test-pool1"}},

…

…
5s: 170 runs so far, 20 failures (11.76%), 10 active

@googs1025
Copy link
Member Author

after fix:

➜  controller git:(fix/fake) ✗ go test -run TestInferenceModelRewriteReconciler/Add_to_existing -o inference_rewrite_stress.test

PASS
ok      sigs.k8s.io/gateway-api-inference-extension/pkg/epp/controller  2.234s
➜  controller git:(fix/fake) ✗ stress -p 10 ./inference_rewrite_stress.test                                                     
5s: 191 runs so far, 0 failures, 10 active
10s: 385 runs so far, 0 failures, 10 active
15s: 577 runs so far, 0 failures, 10 active
20s: 775 runs so far, 0 failures, 10 active

25s: 966 runs so far, 0 failures, 10 active
30s: 1169 runs so far, 0 failures, 10 active
35s: 1372 runs so far, 0 failures, 10 active
40s: 1566 runs so far, 0 failures, 10 active
45s: 1758 runs so far, 0 failures, 10 active
50s: 1954 runs so far, 0 failures, 10 active
55s: 2145 runs so far, 0 failures, 10 active

Copy link
Contributor

@nirrozenbaum nirrozenbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@googs1025 thanks for catching and fixing this issue.
can we switch to using cmpopts.SortSlices instead of copying and sorting new slices?
see example here:

if diff := cmp.Diff(params.wantPods, gotPods, cmpopts.SortSlices(func(a, b string) bool { return a < b })); diff != "" {

return a.Name < b.Name
}

if diff := cmp.Diff(wantRewrites, gotRewrites, cmpopts.SortSlices(less)); diff != "" {
Copy link
Member Author

@googs1025 googs1025 Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch to use cmpopts.SortSlices(less)

@googs1025
Copy link
Member Author

@googs1025 thanks for catching and fixing this issue. can we switch to using cmpopts.SortSlices instead of copying and sorting new slices? see example here:

if diff := cmp.Diff(params.wantPods, gotPods, cmpopts.SortSlices(func(a, b string) bool { return a < b })); diff != "" {

sgtm 😄

@nirrozenbaum
Copy link
Contributor

/lgtm
/approve

Thanks!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 1, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: googs1025, nirrozenbaum

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 1, 2025
@k8s-ci-robot k8s-ci-robot merged commit db8e7be into kubernetes-sigs:main Dec 1, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/flake Categorizes issue or PR as related to a flaky test. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants