Skip to content

Commit

Permalink
event: Add
Browse files Browse the repository at this point in the history
Signed-off-by: Ce Gao <[email protected]>
  • Loading branch information
gaocegege committed Jun 13, 2018
1 parent 510279f commit ffbdbac
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/controller.v2/controller_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ import (
)

const (
// tfConfig is the environment variable name of TensorFlow cluster spec.
tfConfig = "TF_CONFIG"

// podTemplateRestartPolicyReason is the warning reason when the restart
// policy is setted in pod template.
podTemplateRestartPolicyReason = "SettedPodTemplateRestartPolicy"
)

// reconcilePods checks and updates pods for each given TFReplicaSpec.
Expand Down Expand Up @@ -152,6 +157,13 @@ func (tc *TFJobController) createNewPod(tfjob *tfv1alpha2.TFJob, rt, index strin
return err
}

// Submit a warning event if the user specifies restart policy for
// the pod template. We recommend to set it from the replica level.
if podTemplate.Spec.RestartPolicy != v1.RestartPolicy("") {
errMsg := "Restart policy in pod template may be override by restart policy in replica spec"
loggerForReplica(tfjob, rt).Warning(errMsg)
tc.recorder.Event(tfjob, v1.EventTypeWarning, podTemplateRestartPolicyReason, errMsg)
}
if spec.RestartPolicy == tfv1alpha2.RestartPolicyExitCode {
podTemplate.Spec.RestartPolicy = v1.RestartPolicyNever
} else if spec.RestartPolicy == tfv1alpha2.RestartPolicy("") {
Expand Down

0 comments on commit ffbdbac

Please sign in to comment.