deployment controller: use contextual logging

This commit is contained in:
ZhangKe10140699
2022-11-02 09:37:38 +08:00
parent 69465d2949
commit 66bda6c092
15 changed files with 329 additions and 184 deletions

View File

@@ -23,10 +23,11 @@ import (
"time"
apps "k8s.io/api/apps/v1"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/fake"
"k8s.io/client-go/util/workqueue"
"k8s.io/klog/v2/ktesting"
"k8s.io/kubernetes/pkg/controller/deployment/util"
)
@@ -176,7 +177,10 @@ func TestRequeueStuckDeployment(t *testing.T) {
if test.nowFn != nil {
nowFn = test.nowFn
}
got := dc.requeueStuckDeployment(test.d, test.status)
_, ctx := ktesting.NewTestContext(t)
ctx, cancel := context.WithCancel(ctx)
defer cancel()
got := dc.requeueStuckDeployment(ctx, test.d, test.status)
if got != test.expected {
t.Errorf("%s: got duration: %v, expected duration: %v", test.name, got, test.expected)
}
@@ -330,8 +334,8 @@ func TestSyncRolloutStatus(t *testing.T) {
if test.newRS != nil {
test.allRSs = append(test.allRSs, test.newRS)
}
err := dc.syncRolloutStatus(context.TODO(), test.allRSs, test.newRS, test.d)
_, ctx := ktesting.NewTestContext(t)
err := dc.syncRolloutStatus(ctx, test.allRSs, test.newRS, test.d)
if err != nil {
t.Error(err)
}