Remove long deprecated NewImplWithStats (#2223)

This commit is contained in:
Matt Moore 2021-08-21 14:43:34 -07:00 committed by GitHub
parent 9c7fd8e14f
commit 6ef763ddee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 30 deletions

View File

@ -240,12 +240,6 @@ func NewImpl(r Reconciler, logger *zap.SugaredLogger, workQueueName string) *Imp
return NewImplFull(r, ControllerOptions{WorkQueueName: workQueueName, Logger: logger}) return NewImplFull(r, ControllerOptions{WorkQueueName: workQueueName, Logger: logger})
} }
// NewImplWithStats creates a controller.Impl with stats reporter.
// Deprecated: use NewImplFull.
func NewImplWithStats(r Reconciler, logger *zap.SugaredLogger, workQueueName string, reporter StatsReporter) *Impl {
return NewImplFull(r, ControllerOptions{WorkQueueName: workQueueName, Logger: logger, Reporter: reporter})
}
// NewImplFull accepts the full set of options available to all controllers. // NewImplFull accepts the full set of options available to all controllers.
// Deprecated: use NewContext instead. // Deprecated: use NewContext instead.
func NewImplFull(r Reconciler, options ControllerOptions) *Impl { func NewImplFull(r Reconciler, options ControllerOptions) *Impl {

View File

@ -726,20 +726,6 @@ func TestEnqueue(t *testing.T) {
} }
}) })
} }
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
impl := NewImplWithStats(&nopReconciler{}, TestLogger(t), "Testing", &FakeStatsReporter{})
test.work(impl)
impl.WorkQueue().ShutDown()
gotQueue := drainWorkQueue(impl.WorkQueue())
if diff := cmp.Diff(test.wantQueue, gotQueue); diff != "" {
t.Error("unexpected queue (-want +got):", diff)
}
})
}
} }
const ( const (
@ -765,7 +751,12 @@ func pollQ(q workqueue.RateLimitingInterface, sig chan int) func() (bool, error)
} }
func TestEnqueueAfter(t *testing.T) { func TestEnqueueAfter(t *testing.T) {
impl := NewImplWithStats(&nopReconciler{}, TestLogger(t), "Testing", &FakeStatsReporter{}) impl := NewImplFull(&nopReconciler{}, ControllerOptions{
Logger: TestLogger(t),
WorkQueueName: "Testing",
Reporter: &FakeStatsReporter{},
})
t.Cleanup(func() { t.Cleanup(func() {
impl.WorkQueue().ShutDown() impl.WorkQueue().ShutDown()
}) })
@ -827,7 +818,11 @@ func TestEnqueueAfter(t *testing.T) {
} }
func TestEnqueueKeyAfter(t *testing.T) { func TestEnqueueKeyAfter(t *testing.T) {
impl := NewImplWithStats(&nopReconciler{}, TestLogger(t), "Testing", &FakeStatsReporter{}) impl := NewImplFull(&nopReconciler{}, ControllerOptions{
Logger: TestLogger(t),
WorkQueueName: "Testing",
Reporter: &FakeStatsReporter{},
})
t.Cleanup(func() { t.Cleanup(func() {
impl.WorkQueue().ShutDown() impl.WorkQueue().ShutDown()
}) })
@ -885,7 +880,11 @@ func (cr *CountingReconciler) Reconcile(context.Context, string) error {
func TestStartAndShutdown(t *testing.T) { func TestStartAndShutdown(t *testing.T) {
r := &CountingReconciler{} r := &CountingReconciler{}
impl := NewImplWithStats(r, TestLogger(t), "Testing", &FakeStatsReporter{}) impl := NewImplFull(&nopReconciler{}, ControllerOptions{
Logger: TestLogger(t),
WorkQueueName: "Testing",
Reporter: &FakeStatsReporter{},
})
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
doneCh := make(chan struct{}) doneCh := make(chan struct{})
@ -951,7 +950,11 @@ func TestStartAndShutdownWithLeaderAwareNoElection(t *testing.T) {
}, },
}, },
} }
impl := NewImplWithStats(r, TestLogger(t), "Testing", &FakeStatsReporter{}) impl := NewImplFull(r, ControllerOptions{
Logger: TestLogger(t),
WorkQueueName: "Testing",
Reporter: &FakeStatsReporter{},
})
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
doneCh := make(chan struct{}) doneCh := make(chan struct{})
@ -1019,7 +1022,11 @@ func TestStartAndShutdownWithLeaderAwareWithLostElection(t *testing.T) {
}, },
) )
impl := NewImplWithStats(r, TestLogger(t), "Testing", &FakeStatsReporter{}) impl := NewImplFull(&nopReconciler{}, ControllerOptions{
Logger: TestLogger(t),
WorkQueueName: "Testing",
Reporter: &FakeStatsReporter{},
})
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
ctx = leaderelection.WithStandardLeaderElectorBuilder(ctx, kc, cc) ctx = leaderelection.WithStandardLeaderElectorBuilder(ctx, kc, cc)
@ -1059,7 +1066,11 @@ func TestStartAndShutdownWithLeaderAwareWithLostElection(t *testing.T) {
func TestStartAndShutdownWithWork(t *testing.T) { func TestStartAndShutdownWithWork(t *testing.T) {
r := &CountingReconciler{} r := &CountingReconciler{}
reporter := &FakeStatsReporter{} reporter := &FakeStatsReporter{}
impl := NewImplWithStats(r, TestLogger(t), "Testing", reporter) impl := NewImplFull(r, ControllerOptions{
Logger: TestLogger(t),
WorkQueueName: "Testing",
Reporter: reporter,
})
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
doneCh := make(chan struct{}) doneCh := make(chan struct{})
@ -1159,7 +1170,11 @@ func TestStartAndShutdownWithErroringWork(t *testing.T) {
item := types.NamespacedName{Namespace: "", Name: "bar"} item := types.NamespacedName{Namespace: "", Name: "bar"}
impl := NewImplWithStats(&errorReconciler{}, TestLogger(t), "Testing", &FakeStatsReporter{}) impl := NewImplFull(&errorReconciler{}, ControllerOptions{
Logger: TestLogger(t),
WorkQueueName: "Testing",
Reporter: &FakeStatsReporter{},
})
impl.EnqueueKey(item) impl.EnqueueKey(item)
ctx, cancel := context.WithTimeout(context.Background(), testTimeout) ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
@ -1214,7 +1229,11 @@ func (er *permanentErrorReconciler) Reconcile(context.Context, string) error {
func TestStartAndShutdownWithPermanentErroringWork(t *testing.T) { func TestStartAndShutdownWithPermanentErroringWork(t *testing.T) {
r := &permanentErrorReconciler{} r := &permanentErrorReconciler{}
reporter := &FakeStatsReporter{} reporter := &FakeStatsReporter{}
impl := NewImplWithStats(r, TestLogger(t), "Testing", reporter) impl := NewImplFull(r, ControllerOptions{
Logger: TestLogger(t),
WorkQueueName: "Testing",
Reporter: reporter,
})
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
doneCh := make(chan struct{}) doneCh := make(chan struct{})
@ -1278,7 +1297,11 @@ func TestStartAndShutdownWithRequeuingWork(t *testing.T) {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
r := &requeueAfterReconciler{duration: test.duration} r := &requeueAfterReconciler{duration: test.duration}
reporter := &FakeStatsReporter{} reporter := &FakeStatsReporter{}
impl := NewImplWithStats(r, TestLogger(t), "Testing", reporter) impl := NewImplFull(r, ControllerOptions{
Logger: TestLogger(t),
WorkQueueName: "Testing",
Reporter: reporter,
})
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
doneCh := make(chan struct{}) doneCh := make(chan struct{})
@ -1373,7 +1396,11 @@ func (*fakeStore) List() []interface{} {
func TestImplGlobalResync(t *testing.T) { func TestImplGlobalResync(t *testing.T) {
r := &CountingReconciler{} r := &CountingReconciler{}
impl := NewImplWithStats(r, TestLogger(t), "Testing", &FakeStatsReporter{}) impl := NewImplFull(r, ControllerOptions{
Logger: TestLogger(t),
WorkQueueName: "Testing",
Reporter: &FakeStatsReporter{},
})
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
doneCh := make(chan struct{}) doneCh := make(chan struct{})