Skip to content

Commit

Permalink
Avoid making copy of runPolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
mszadkow committed Sep 12, 2024
1 parent 353d505 commit e57b7c3
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pkg/controller.v1/common/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ func (jc *JobController) calcPGMinResources(minMember int32, replicas map[apiv1.
return CalcPGMinResources(minMember, replicas, jc.PriorityClassLister.Get)
}

func (jc *JobController) ManagedByExternalController(rp apiv1.RunPolicy) *string {
if controllerName := rp.ManagedBy; controllerName != nil && *controllerName != apiv1.KubeflowJobsController {
func (jc *JobController) ManagedByExternalController(controllerName *string) *string {
if controllerName != nil && *controllerName != apiv1.KubeflowJobsController {
return controllerName
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller.v1/common/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func TestManagedByExternalController(T *testing.T) {
ManagedBy: tc.managedBy,
}

if got := jobController.ManagedByExternalController(*runPolicy); got != nil {
if got := jobController.ManagedByExternalController(runPolicy.ManagedBy); got != nil {
if !tc.wantResult {
t.Errorf("Unwanted manager controller: %s\n", *got)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller.v1/mpi/mpijob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (jc *MPIJobReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
return ctrl.Result{}, client.IgnoreNotFound(err)
}

if manager := jc.ManagedByExternalController(mpijob.Spec.RunPolicy); manager != nil {
if manager := jc.ManagedByExternalController(mpijob.Spec.RunPolicy.ManagedBy); manager != nil {
logger.Info("Skipping MPIJob managed by a custom controller", "managed-by", manager)
return ctrl.Result{}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller.v1/paddlepaddle/paddlepaddle_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (r *PaddleJobReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
return ctrl.Result{}, client.IgnoreNotFound(err)
}

if manager := r.ManagedByExternalController(paddlejob.Spec.RunPolicy); manager != nil {
if manager := r.ManagedByExternalController(paddlejob.Spec.RunPolicy.ManagedBy); manager != nil {
logger.Info("Skipping PaddleJob managed by a custom controller", "managed-by", manager)
return ctrl.Result{}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller.v1/pytorch/pytorchjob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (r *PyTorchJobReconciler) Reconcile(ctx context.Context, req ctrl.Request)
return ctrl.Result{}, client.IgnoreNotFound(err)
}

if manager := r.ManagedByExternalController(pytorchjob.Spec.RunPolicy); manager != nil {
if manager := r.ManagedByExternalController(pytorchjob.Spec.RunPolicy.ManagedBy); manager != nil {
logger.Info("Skipping PyTorchJob managed by a custom controller", "managed-by", manager)
return ctrl.Result{}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller.v1/tensorflow/tfjob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (r *TFJobReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
return ctrl.Result{}, client.IgnoreNotFound(err)
}

if manager := r.ManagedByExternalController(tfjob.Spec.RunPolicy); manager != nil {
if manager := r.ManagedByExternalController(tfjob.Spec.RunPolicy.ManagedBy); manager != nil {
logger.Info("Skipping TFJob managed by a custom controller", "managed-by", manager)
return ctrl.Result{}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller.v1/xgboost/xgboostjob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (r *XGBoostJobReconciler) Reconcile(ctx context.Context, req ctrl.Request)
return ctrl.Result{}, client.IgnoreNotFound(err)
}

if manager := r.ManagedByExternalController(xgboostjob.Spec.RunPolicy); manager != nil {
if manager := r.ManagedByExternalController(xgboostjob.Spec.RunPolicy.ManagedBy); manager != nil {
logger.Info("Skipping XGBoostJob managed by a custom controller", "managed-by", manager)
return ctrl.Result{}, nil
}
Expand Down

0 comments on commit e57b7c3

Please sign in to comment.