Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
eedorenko committed Dec 10, 2024
1 parent 4b7f112 commit 65c6eb5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
8 changes: 8 additions & 0 deletions controllers/schedulingpolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const (
ReconcilerField = "spec.reconciler"
NamespaceServiceField = "spec.namespaceService"
DeploymentTargetField = "spec.deploymentTarget"
EnvironmentField = "spec.environment"
)

// +kubebuilder:rbac:groups=scheduler.kalypso.io,resources=schedulingpolicies,verbs=get;list;watch;create;update;patch;delete
Expand Down Expand Up @@ -267,6 +268,13 @@ func (r *SchedulingPolicyReconciler) SetupWithManager(mgr ctrl.Manager) error {
return err
}

// Add the field index for the environmrnt in the deployment target
if err := mgr.GetFieldIndexer().IndexField(context.Background(), &schedulerv1alpha1.DeploymentTarget{}, EnvironmentField, func(rawObj client.Object) []string {
return []string{rawObj.(*schedulerv1alpha1.DeploymentTarget).Spec.Environment}
}); err != nil {
return err
}

return ctrl.NewControllerManagedBy(mgr).
For(&schedulerv1alpha1.SchedulingPolicy{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
Owns(&schedulerv1alpha1.Assignment{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
Expand Down
16 changes: 0 additions & 16 deletions controllers/workload_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ type WorkloadReconciler struct {
Scheme *runtime.Scheme
}

const (
EnvironmentField = "spec.environment"
)

// +kubebuilder:rbac:groups=scheduler.kalypso.io,resources=workloads,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=scheduler.kalypso.io,resources=workloads/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=scheduler.kalypso.io,resources=workloads/finalizers,verbs=update
Expand Down Expand Up @@ -240,18 +236,6 @@ func (h *WorkloadReconciler) manageFailure(ctx context.Context, logger logr.Logg

// SetupWithManager sets up the controller with the Manager.
func (r *WorkloadReconciler) SetupWithManager(mgr ctrl.Manager) error {
// Add the field index for the environmrnt in the deployment target
if err := mgr.GetFieldIndexer().IndexField(context.Background(), &schedulerv1alpha1.DeploymentTarget{}, EnvironmentField, func(rawObj client.Object) []string {
return []string{rawObj.(*schedulerv1alpha1.DeploymentTarget).Spec.Environment}
}); err != nil {
return err
}

// if err := mgr.GetFieldIndexer().IndexField(context.Background(), &schedulerv1alpha1.Assignment{}, DeploymentTargetField, func(rawObj client.Object) []string {
// return []string{rawObj.(*schedulerv1alpha1.Assignment).Spec.DeploymentTarget}
// }); err != nil {
// return err
// }

return ctrl.NewControllerManagedBy(mgr).
For(&schedulerv1alpha1.Workload{}).
Expand Down

0 comments on commit 65c6eb5

Please # to comment.