Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Stuchinskii committed Nov 14, 2023
1 parent 3b15bd9 commit 53a8d24
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
10 changes: 1 addition & 9 deletions pkg/controller/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,7 @@ func SetupControllers(mgr ctrl.Manager, qManager *queue.Manager, cc *cache.Cache
if err := cqRec.SetupWithManager(mgr); err != nil {
return "ClusterQueue", err
}
wlRec := NewWorkloadReconciler(
mgr.GetClient(),
qManager,
cc,
mgr.GetEventRecorderFor("workload-controller"),
WithWorkloadUpdateWatchers(qRec, cqRec),
WithPodsReadyTimeout(podsReadyTimeout(cfg)),
)
if err := wlRec.SetupWithManager(mgr); err != nil {
if err := NewWorkloadReconciler(mgr.GetClient(), qManager, cc, WithWorkloadUpdateWatchers(qRec, cqRec), WithPodsReadyTimeout(podsReadyTimeout(cfg))).SetupWithManager(mgr); err != nil {
return "Workload", err
}
return "", nil
Expand Down
12 changes: 3 additions & 9 deletions pkg/controller/core/workload_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/tools/record"
"k8s.io/client-go/util/workqueue"
"k8s.io/klog/v2"
"k8s.io/utils/clock"
Expand Down Expand Up @@ -94,12 +93,11 @@ type WorkloadReconciler struct {
queues *queue.Manager
cache *cache.Cache
client client.Client
record record.EventRecorder
watchers []WorkloadUpdateWatcher
podsReadyTimeout *time.Duration
}

func NewWorkloadReconciler(client client.Client, queues *queue.Manager, cache *cache.Cache, record record.EventRecorder, opts ...Option) *WorkloadReconciler {
func NewWorkloadReconciler(client client.Client, queues *queue.Manager, cache *cache.Cache, opts ...Option) *WorkloadReconciler {
options := defaultOptions
for _, opt := range opts {
opt(&options)
Expand All @@ -110,7 +108,6 @@ func NewWorkloadReconciler(client client.Client, queues *queue.Manager, cache *c
client: client,
queues: queues,
cache: cache,
record: record,
watchers: options.watchers,
podsReadyTimeout: options.podsReadyTimeout,
}
Expand Down Expand Up @@ -219,11 +216,8 @@ func (r *WorkloadReconciler) reconcileSyncAdmissionChecks(ctx context.Context, w
log := ctrl.LoggerFrom(ctx)
log.V(3).Info("The workload needs admission checks updates", "clusterQueue", klog.KRef("", cqName), "admissionChecks", queueAdmissionChecks)
wl.Status.AdmissionChecks = newChecks
if err := r.client.Status().Update(ctx, wl); err != nil {
return true, client.IgnoreNotFound(err)
}
r.record.Eventf(wl, corev1.EventTypeNormal, "AdmissionChecksChanged", "Updated the list of admission checks for the workload, based on the clusterQueue %s", cqName)
return true, nil
err := r.client.Status().Update(ctx, wl)
return true, client.IgnoreNotFound(err)
}
return false, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func managerSetup(mgr manager.Manager, ctx context.Context) {
err = provisioning.SetupIndexer(ctx, mgr.GetFieldIndexer())
gomega.Expect(err).NotTo(gomega.HaveOccurred())

reconciler := provisioning.NewController(mgr.GetClient(), mgr.GetEventRecorderFor("admission-checks-controller"))
reconciler := provisioning.NewController(mgr.GetClient(), mgr.GetEventRecorderFor("kueue-provisioning-request-controller"))
err = reconciler.SetupWithManager(mgr)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
}
Expand Down

0 comments on commit 53a8d24

Please sign in to comment.