Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
fix ReconcilePods
Browse files Browse the repository at this point in the history
  • Loading branch information
zw0610 committed Nov 11, 2021
1 parent 60c5d31 commit 4b8e22e
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/common/v1/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type ControllerInterface interface {
// ReconcilePods checks and updates pods for each given ReplicaSpec.
// It will requeue the job in case of an error while creating/deleting pods.
// Common implementation will be provided and User can still override this to implement their own reconcile logic
ReconcilePods(job interface{}, jobStatus *JobStatus, pods []*v1.Pod, rtype string, spec *ReplicaSpec,
ReconcilePods(job interface{}, jobStatus *JobStatus, pods []*v1.Pod, rtype ReplicaType, spec *ReplicaSpec,
replicas map[ReplicaType]*ReplicaSpec) error

// ReconcileServices checks and updates services for each given ReplicaSpec.
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller.v1/common/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (jc *JobController) ReconcileJobs(

// Diff current active pods/services with replicas.
for rtype, spec := range replicas {
err := jc.Controller.ReconcilePods(metaObject, &jobStatus, pods, string(rtype), spec, replicas)
err := jc.Controller.ReconcilePods(metaObject, &jobStatus, pods, rtype, spec, replicas)
if err != nil {
log.Warnf("ReconcilePods error %v", err)
return err
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller.v1/common/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,11 @@ func (jc *JobController) ReconcilePods(
job interface{},
jobStatus *apiv1.JobStatus,
pods []*v1.Pod,
rtype string,
rType apiv1.ReplicaType,
spec *apiv1.ReplicaSpec,
replicas map[apiv1.ReplicaType]*apiv1.ReplicaSpec) error {

rtype := string(rType)
metaObject, ok := job.(metav1.Object)
if !ok {
return fmt.Errorf("job is not a metav1.Object type")
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler.v1/common/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ type PodInterface interface {
job client.Object,
jobStatus *commonv1.JobStatus,
pods []*corev1.Pod,
rtype string,
rtype commonv1.ReplicaType,
spec *commonv1.ReplicaSpec,
replicas map[commonv1.ReplicaType]*commonv1.ReplicaSpec) error

Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler.v1/common/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (r *KubeflowJobReconciler) ReconcileJob(
for rtype, spec := range replicas {
core.InitializeReplicaStatuses(status, string(rtype))

err = r.ReconcilePods(ctx, job, status, pods, string(rtype), spec, replicas)
err = r.ReconcilePods(ctx, job, status, pods, rtype, spec, replicas)
if err != nil {
logrus.Warnf(ErrReconcilePodsTemplate, err)
return err
Expand Down
3 changes: 2 additions & 1 deletion pkg/reconciler.v1/common/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@ func (r *KubeflowPodReconciler) ReconcilePods(
job client.Object,
jobStatus *commonv1.JobStatus,
pods []*corev1.Pod,
rtype string,
rType commonv1.ReplicaType,
spec *commonv1.ReplicaSpec,
replicas map[commonv1.ReplicaType]*commonv1.ReplicaSpec) error {

rtype := string(rType)
// Convert ReplicaType to lower string.
logger := commonutil.LoggerForReplica(job, rtype)
// Get all pods for the type rt.
Expand Down

0 comments on commit 4b8e22e

Please sign in to comment.