Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the bugs due to refactoring code #776

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/controller.v2/tfcontroller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (tc *TFJobController) reconcilePods(
}
if pod.Status.Phase == v1.PodFailed && train_util.IsRetryableExitCode(exitCode) {
logger.Infof("Need to restart the pod: %s-%d", rt, index)
if err := tc.PodControl.DeletePod(pod.Namespace, pod.Name, tfjob); err != nil {
if err := tc.JobController.PodControl.DeletePod(pod.Namespace, pod.Name, tfjob); err != nil {
return err
}
restart = true
Expand Down Expand Up @@ -171,7 +171,7 @@ func (tc *TFJobController) createNewPod(tfjob *tfv1alpha2.TFJob, rt, index strin
}
setRestartPolicy(podTemplate, spec)

err = tc.PodControl.CreatePodsWithControllerRef(tfjob.Namespace, podTemplate, tfjob, controllerRef)
err = tc.JobController.PodControl.CreatePodsWithControllerRef(tfjob.Namespace, podTemplate, tfjob, controllerRef)
if err != nil && errors.IsTimeout(err) {
// Pod is created but its initialization has timed out.
// If the initialization is successful eventually, the
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller.v2/tfcontroller/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (tc *TFJobController) createNewService(tfjob *tfv1alpha2.TFJob, rtype tfv1a
service.Name = jobcontroller.GenGeneralName(tfjob.Name, rt, index)
service.Labels = labels

err = tc.ServiceControl.CreateServicesWithControllerRef(tfjob.Namespace, service, tfjob, controllerRef)
err = tc.JobController.ServiceControl.CreateServicesWithControllerRef(tfjob.Namespace, service, tfjob, controllerRef)
if err != nil && errors.IsTimeout(err) {
// Service is created but its initialization has timed out.
// If the initialization is successful eventually, the
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller.v2/tfcontroller/tfcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func (tc *TFJobController) syncTFJob(key string) (bool, error) {
tfjobNeedsSync := tc.satisfiedExpectations(tfjob)

if tc.Config.EnableGangScheduling {
_, err := tc.SyncPdb(tfjob)
_, err := tc.JobController.SyncPdb(tfjob)
if err != nil {
logger.Warnf("Sync pdb %v: %v", tfjob.Name, err)
}
Expand Down Expand Up @@ -333,14 +333,14 @@ func (tc *TFJobController) reconcileTFJobs(tfjob *tfv1alpha2.TFJob) error {
logger := tflogger.LoggerForJob(tfjob)
logger.Infof("Reconcile TFJobs %s", tfjob.Name)

pods, err := tc.GetPodsForJob(tfjob)
pods, err := tc.JobController.GetPodsForJob(tfjob)

if err != nil {
logger.Warnf("getPodsForTFJob error %v", err)
return err
}

services, err := tc.GetServicesForJob(tfjob)
services, err := tc.JobController.GetServicesForJob(tfjob)

if err != nil {
logger.Warnf("getServicesForTFJob error %v", err)
Expand All @@ -359,7 +359,7 @@ func (tc *TFJobController) reconcileTFJobs(tfjob *tfv1alpha2.TFJob) error {

if tc.Config.EnableGangScheduling {
tc.Recorder.Event(tfjob, v1.EventTypeNormal, "JobTerminated", "Job is terminated, deleting pdb")
if err := tc.DeletePdb(tfjob); err != nil {
if err := tc.JobController.DeletePdb(tfjob); err != nil {
tc.Recorder.Eventf(tfjob, v1.EventTypeWarning, "FailedDeletePdb", "Error deleting: %v", err)
return err
} else {
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller.v2/tfcontroller/tfjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ func (tc *TFJobController) deletePodsAndServices(tfJob *tfv1alpha2.TFJob, pods [
if *tfJob.Spec.CleanPodPolicy == tfv1alpha2.CleanPodPolicyRunning && pod.Status.Phase != v1.PodRunning {
continue
}
if err := tc.PodControl.DeletePod(pod.Namespace, pod.Name, tfJob); err != nil {
if err := tc.JobController.PodControl.DeletePod(pod.Namespace, pod.Name, tfJob); err != nil {
return err
}
// Pod and service have the same name, thus the service could be deleted using pod's name.
if err := tc.ServiceControl.DeleteService(pod.Namespace, pod.Name, tfJob); err != nil {
if err := tc.JobController.ServiceControl.DeleteService(pod.Namespace, pod.Name, tfJob); err != nil {
return err
}
}
Expand Down