Skip to content

Commit 31aa566

Browse files
luolanzonerenovate[bot]antoninbas
authored
Automated cherry pick of #7448: fix(deps): update module github.com/stretchr/testify to v1.11.1 #7433 to update module github.com/spf13/pflag to v1.0.10 #7469 Fix typo in TestPreventDefunctRuleReuse (#7886)
* fix(deps): update module github.com/stretchr/testify to v1.11.1 (main) (#7448) * fix(deps): update module github.com/stretchr/testify to v1.11.1 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Fix race conditions in unit tests The tests were not correct to begin with, and a change in the `assert.Eventually` implementation exposed the bug: stretchr/testify#1427 Signed-off-by: Antonin Bas <antonin.bas@broadcom.com> --------- Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Signed-off-by: Antonin Bas <antonin.bas@broadcom.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Antonin Bas <antonin.bas@broadcom.com> * fix(deps): update module github.com/spf13/pflag to v1.0.10 (#7433) Signed-off-by: Lan Luo <lan.luo@broadcom.com> * [Flaky unit test] Fix typo in TestPreventDefunctRuleReuse (#7469) The test had an invalid usage of assert.EventuallyWithT: the assertions included in the condition function applied to the outer *testing.T instead of to the condition function parameter. After #7448, the test started failing due to the change in the implementation of assert.EventuallyWithT. Signed-off-by: Antonin Bas <antonin.bas@broadcom.com> --------- Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Signed-off-by: Antonin Bas <antonin.bas@broadcom.com> Signed-off-by: Lan Luo <lan.luo@broadcom.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Antonin Bas <antonin.bas@broadcom.com>
1 parent f6bbf2c commit 31aa566

6 files changed

Lines changed: 38 additions & 25 deletions

File tree

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ require (
4848
github.com/prometheus/client_golang v1.20.5
4949
github.com/prometheus/common v0.62.0
5050
github.com/sirupsen/logrus v1.9.3
51-
github.com/spf13/afero v1.14.0
52-
github.com/spf13/cobra v1.9.1
53-
github.com/spf13/pflag v1.0.6
54-
github.com/stretchr/testify v1.10.0
51+
github.com/spf13/afero v1.15.0
52+
github.com/spf13/cobra v1.10.1
53+
github.com/spf13/pflag v1.0.10
54+
github.com/stretchr/testify v1.11.1
5555
github.com/ti-mo/conntrack v0.5.2
5656
github.com/vishvananda/netlink v1.3.1
5757
github.com/vmware/go-ipfix v0.16.0

go.sum

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -712,25 +712,26 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO
712712
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
713713
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
714714
github.com/spf13/afero v1.4.1/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
715-
github.com/spf13/afero v1.14.0 h1:9tH6MapGnn/j0eb0yIXiLjERO8RB6xIVZRDCX7PtqWA=
716-
github.com/spf13/afero v1.14.0/go.mod h1:acJQ8t0ohCGuMN3O+Pv0V0hgMxNYDlvdk+VTfyZmbYo=
715+
github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
716+
github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg=
717717
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
718718
github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA=
719719
github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48=
720720
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
721721
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
722722
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
723-
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
724-
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
723+
github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s=
724+
github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0=
725725
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
726726
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
727727
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
728728
github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
729729
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
730730
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
731731
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
732-
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
733-
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
732+
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
733+
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
734+
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
734735
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
735736
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
736737
github.com/spf13/viper v1.16.0 h1:rGGH0XDZhdUOryiDWjmIvUSWpbNqisK8Wk0Vyefw8hc=
@@ -754,8 +755,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
754755
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
755756
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
756757
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
757-
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
758-
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
758+
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
759+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
759760
github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8=
760761
github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
761762
github.com/ti-mo/conntrack v0.5.2 h1:PQ7MCdFjniEiTJT+qsAysREUsT5iH62/VNyhkB06HOI=

pkg/agent/ipassigner/linkmonitor/link_monitor_linux_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ func Test_linkMonitor_listAndWatchLinks(t *testing.T) {
277277
for _, l := range tt.eventHandlers {
278278
assert.Equal(t, l.expectedLinkEvents, l.getReceivedLinkEvents())
279279
}
280+
d.mutex.RLock()
281+
defer d.mutex.RUnlock()
280282
assert.ElementsMatch(t, tt.expectedExistingLinks, d.linkNames.UnsortedList())
281283
},
282284
1*time.Second, 100*time.Millisecond, "timeout waiting for link events",

pkg/agent/nodeportlocal/k8s/npl_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ func TestPreventDefunctRuleReuse(t *testing.T) {
10771077
if !assert.NoError(t, err) {
10781078
return
10791079
}
1080-
assert.EventuallyWithT(t, func(c *assert.CollectT) {
1080+
assert.EventuallyWithT(t, func(t *assert.CollectT) {
10811081
obj, exists, err := testData.svcInformer.GetIndexer().GetByKey(testSvc.Namespace + "/" + testSvc.Name)
10821082
if !assert.NoError(t, err) || !assert.True(t, exists) {
10831083
return

pkg/antctl/raw/multicluster/get/join_config_test.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package get
1616

1717
import (
1818
"bytes"
19-
"fmt"
2019
"log"
2120
"os"
2221
"testing"
@@ -171,24 +170,24 @@ func TestJoinConfig(t *testing.T) {
171170

172171
func TestOptValidate(t *testing.T) {
173172
tests := []struct {
174-
name string
175-
opts *joinConfigOptions
176-
err error
173+
name string
174+
opts *joinConfigOptions
175+
errStr string
177176
}{
178177
{
179178
name: "no Namespace",
180179
opts: &joinConfigOptions{
181180
k8sClient: fake.NewClientBuilder().WithScheme(mcscheme.Scheme).Build(),
182181
},
183-
err: fmt.Errorf("Namespace must be specified"),
182+
errStr: "Namespace must be specified",
184183
},
185184
{
186185
name: "Namespace specified",
187186
opts: &joinConfigOptions{
188187
namespace: "ns1",
189188
k8sClient: fake.NewClientBuilder().WithScheme(mcscheme.Scheme).Build(),
190189
},
191-
err: nil,
190+
errStr: "",
192191
},
193192
{
194193
name: "token specified",
@@ -197,22 +196,26 @@ func TestOptValidate(t *testing.T) {
197196
memberToken: "token1",
198197
k8sClient: fake.NewClientBuilder().WithScheme(mcscheme.Scheme).Build(),
199198
},
200-
err: nil,
199+
errStr: "",
201200
},
202201
{
203202
name: "K8s client error",
204203
opts: &joinConfigOptions{
205204
namespace: "ns1",
206205
},
207-
err: fmt.Errorf("flag accessed but not defined: kubeconfig"),
206+
errStr: "flag accessed but not defined: kubeconfig",
208207
},
209208
}
210209

211210
cmd := &cobra.Command{}
212211
for _, tt := range tests {
213212
t.Run(tt.name, func(t *testing.T) {
214213
err := tt.opts.validateAndComplete(cmd)
215-
assert.Equal(t, tt.err, err)
214+
if tt.errStr == "" {
215+
assert.NoError(t, err)
216+
} else {
217+
assert.EqualError(t, err, tt.errStr)
218+
}
216219
})
217220
}
218221
}

pkg/apiserver/registry/system/supportbundle/rest.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ type supportBundleREST struct {
111111
mode string
112112
statusLocker sync.RWMutex
113113
cancelFunc context.CancelFunc
114-
cache *systemv1beta1.SupportBundle
114+
// cache stores the "current" or most recent SupportBundle resource. Because Get returns
115+
// this value directly, it is important for the supportBundleREST implementation *not* to
116+
// mutate fields in the SupportBundle object once it has been assigned to cache, in order to
117+
// ensure thread-safety. Otherwise, we would have a race with Get callers.
118+
cache *systemv1beta1.SupportBundle
115119

116120
ovsCtlClient ovsctl.OVSCtlClient
117121
aq agentquerier.AgentQuerier
@@ -154,8 +158,11 @@ func (r *supportBundleREST) Create(ctx context.Context, obj runtime.Object, _ re
154158
r.statusLocker.Lock()
155159
defer r.statusLocker.Unlock()
156160
if err != nil {
157-
klog.Errorf("Error when collecting supportBundle: %v", err)
158-
r.cache.Status = systemv1beta1.SupportBundleStatusNone
161+
klog.ErrorS(err, "Error when collecting supportBundle")
162+
r.cache = &systemv1beta1.SupportBundle{
163+
ObjectMeta: metav1.ObjectMeta{Name: r.mode},
164+
Status: systemv1beta1.SupportBundleStatusNone,
165+
}
159166
return
160167
}
161168
select {

0 commit comments

Comments
 (0)