Compare commits

..

1 Commits

Author SHA1 Message Date
Kubernetes Publisher
f3a17ade26 Update dependencies to v0.20.15-rc.0 tag 2021-12-15 21:33:59 +00:00
4 changed files with 9 additions and 52 deletions

8
go.mod
View File

@@ -26,14 +26,14 @@ require (
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
k8s.io/api v0.20.16-rc.0
k8s.io/apimachinery v0.20.16-rc.0
k8s.io/api v0.20.15-rc.0
k8s.io/apimachinery v0.20.15-rc.0
k8s.io/klog/v2 v2.4.0
k8s.io/utils v0.0.0-20201110183641-67b214c5f920
sigs.k8s.io/yaml v1.2.0
)
replace (
k8s.io/api => k8s.io/api v0.20.16-rc.0
k8s.io/apimachinery => k8s.io/apimachinery v0.20.16-rc.0
k8s.io/api => k8s.io/api v0.20.15-rc.0
k8s.io/apimachinery => k8s.io/apimachinery v0.20.15-rc.0
)

8
go.sum
View File

@@ -425,10 +425,10 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
k8s.io/api v0.20.16-rc.0 h1:I05QjjPM/2wHa8+75N2lZi01xzfMukbWxp7Y/bhviWM=
k8s.io/api v0.20.16-rc.0/go.mod h1:5Qt9j0A/X8FSv8dy05tvPjnPoDlGXN9vdc42r7BihZ4=
k8s.io/apimachinery v0.20.16-rc.0 h1:F89ET0h3pExXucRFpNqx3tJcQi87xpt6eQqMuoxYpJY=
k8s.io/apimachinery v0.20.16-rc.0/go.mod h1:4KFiDSxCoGviCiRk9kTXIROsIf4VSGkVYjVJjJln3pg=
k8s.io/api v0.20.15-rc.0 h1:xjLH2OtyX/H7UFRg9sKOUDR1FCNau2uY1/1bdV5uJjM=
k8s.io/api v0.20.15-rc.0/go.mod h1:dSrrkWq7+Pcw3Bf5wHU5SwEb1YkuDi8I37SesMYqvEU=
k8s.io/apimachinery v0.20.15-rc.0 h1:iC5tpfCz0/3HIv7TOI0FoaEAB/Ohkf2qposYAqTmdpM=
k8s.io/apimachinery v0.20.15-rc.0/go.mod h1:4KFiDSxCoGviCiRk9kTXIROsIf4VSGkVYjVJjJln3pg=
k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
k8s.io/klog/v2 v2.4.0 h1:7+X0fUguPyrKEC4WjH8iGDg3laWgMo5tMnRTIGTTxGQ=

View File

@@ -149,10 +149,7 @@ func (q *Type) Get() (item interface{}, shutdown bool) {
return nil, true
}
item = q.queue[0]
// The underlying array still exists and reference this object, so the object will not be garbage collected.
q.queue[0] = nil
q.queue = q.queue[1:]
item, q.queue = q.queue[0], q.queue[1:]
q.metrics.get(item)

View File

@@ -17,13 +17,10 @@ limitations under the License.
package workqueue_test
import (
"runtime"
"sync"
"sync/atomic"
"testing"
"time"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/util/workqueue"
)
@@ -162,40 +159,3 @@ func TestReinsert(t *testing.T) {
t.Errorf("Expected queue to be empty. Has %v items", a)
}
}
// TestGarbageCollection ensures that objects that are added then removed from the queue are
// able to be garbage collected.
func TestGarbageCollection(t *testing.T) {
type bigObject struct {
data []byte
}
leakQueue := workqueue.New()
t.Cleanup(func() {
// Make sure leakQueue doesn't go out of scope too early
runtime.KeepAlive(leakQueue)
})
c := &bigObject{data: []byte("hello")}
mustGarbageCollect(t, c)
leakQueue.Add(c)
o, _ := leakQueue.Get()
leakQueue.Done(o)
}
// mustGarbageCollect asserts than an object was garbage collected by the end of the test.
// The input must be a pointer to an object.
func mustGarbageCollect(t *testing.T, i interface{}) {
t.Helper()
var collected int32 = 0
runtime.SetFinalizer(i, func(x interface{}) {
atomic.StoreInt32(&collected, 1)
})
t.Cleanup(func() {
if err := wait.PollImmediate(time.Millisecond*100, wait.ForeverTestTimeout, func() (done bool, err error) {
// Trigger GC explicitly, otherwise we may need to wait a long time for it to run
runtime.GC()
return atomic.LoadInt32(&collected) == 1, nil
}); err != nil {
t.Errorf("object was not garbage collected")
}
})
}