-
Notifications
You must be signed in to change notification settings - Fork 206
fix: sort InferenceModelRewrite lists by (Namespace, Name) in tests #1917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for gateway-api-inference-extension ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
➜ 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
|
|
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
|
nirrozenbaum
left a comment
There was a problem hiding this 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:
gateway-api-inference-extension/pkg/epp/controller/inferencepool_reconciler_test.go
Line 199 in 664e4d4
| if diff := cmp.Diff(params.wantPods, gotPods, cmpopts.SortSlices(func(a, b string) bool { return a < b })); diff != "" { |
Signed-off-by: CYJiang <[email protected]>
| return a.Name < b.Name | ||
| } | ||
|
|
||
| if diff := cmp.Diff(wantRewrites, gotRewrites, cmpopts.SortSlices(less)); diff != "" { |
There was a problem hiding this comment.
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)
sgtm 😄 |
|
/lgtm Thanks! |
|
[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 |
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?: