Skip to content

Commit 339ef51

Browse files
committed
[WIP] adapt to controller-runtime's SDK change
1 parent af973ed commit 339ef51

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

pkg/controllers/elasticquota_controller.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ import (
3333
"sigs.k8s.io/controller-runtime/pkg/controller"
3434
"sigs.k8s.io/controller-runtime/pkg/handler"
3535
"sigs.k8s.io/controller-runtime/pkg/log"
36-
"sigs.k8s.io/controller-runtime/pkg/source"
37-
3836
schedv1alpha1 "sigs.k8s.io/scheduler-plugins/apis/scheduling/v1alpha1"
3937
)
4038

@@ -173,7 +171,7 @@ func newZeroUsed(eq *schedv1alpha1.ElasticQuota) v1.ResourceList {
173171
func (r *ElasticQuotaReconciler) SetupWithManager(mgr ctrl.Manager) error {
174172
r.recorder = mgr.GetEventRecorderFor("ElasticQuotaController")
175173
return ctrl.NewControllerManagedBy(mgr).
176-
Watches(&source.Kind{Type: &v1.Pod{}}, &handler.EnqueueRequestForObject{}).
174+
Watches(&v1.Pod{}, &handler.EnqueueRequestForObject{}).
177175
For(&schedv1alpha1.ElasticQuota{}).
178176
WithOptions(controller.Options{MaxConcurrentReconciles: r.Workers}).
179177
Complete(r)

pkg/controllers/podgroup_controller.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ import (
3636
"sigs.k8s.io/controller-runtime/pkg/controller"
3737
"sigs.k8s.io/controller-runtime/pkg/handler"
3838
"sigs.k8s.io/controller-runtime/pkg/log"
39-
"sigs.k8s.io/controller-runtime/pkg/source"
40-
4139
schedv1alpha1 "sigs.k8s.io/scheduler-plugins/apis/scheduling/v1alpha1"
4240
"sigs.k8s.io/scheduler-plugins/pkg/util"
4341
)
@@ -191,14 +189,13 @@ func (r *PodGroupReconciler) SetupWithManager(mgr ctrl.Manager) error {
191189
r.log = mgr.GetLogger()
192190

193191
return ctrl.NewControllerManagedBy(mgr).
194-
Watches(&source.Kind{Type: &v1.Pod{}},
195-
handler.EnqueueRequestsFromMapFunc(r.podToPodGroup)).
192+
Watches(&v1.Pod{}, handler.EnqueueRequestsFromMapFunc(r.podToPodGroup)).
196193
For(&schedv1alpha1.PodGroup{}).
197194
WithOptions(controller.Options{MaxConcurrentReconciles: r.Workers}).
198195
Complete(r)
199196
}
200197

201-
func (r *PodGroupReconciler) podToPodGroup(obj client.Object) []ctrl.Request {
198+
func (r *PodGroupReconciler) podToPodGroup(ctx context.Context, obj client.Object) []ctrl.Request {
202199
pod, ok := obj.(*v1.Pod)
203200
if !ok {
204201
return nil

pkg/controllers/podgroup_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func Test_Run(t *testing.T) {
166166
}
167167
for _, p := range ps {
168168
kClient.Status().Update(ctx, p)
169-
reqs := controller.podToPodGroup(p)
169+
reqs := controller.podToPodGroup(ctx, p)
170170
for _, req := range reqs {
171171
if _, err := controller.Reconcile(ctx, req); err != nil {
172172
t.Errorf("reconcile: (%v)", err)

0 commit comments

Comments
 (0)