send job succeeded condition to channel

pull/3479/head
Timofey Kirillov 8 years ago
parent 7d52779027
commit fa6e96af14

@ -164,8 +164,16 @@ func (pod *PodWatchMonitor) WatchContainerLogs(containerName string) error {
} }
func (pod *PodWatchMonitor) Watch() error { func (pod *PodWatchMonitor) Watch() error {
for i := range pod.ContainersNames { allContainersNames := make([]string, 0)
containerName := pod.ContainersNames[i] for _, containerName := range pod.InitContainersNames {
allContainersNames = append(allContainersNames, containerName)
}
for _, containerName := range pod.ContainersNames {
allContainersNames = append(allContainersNames, containerName)
}
for i := range allContainersNames {
containerName := allContainersNames[i]
go func() { go func() {
err := pod.WatchContainerLogs(containerName) err := pod.WatchContainerLogs(containerName)
if err != nil { if err != nil {
@ -197,6 +205,7 @@ func (pod *PodWatchMonitor) Watch() error {
return true, fmt.Errorf("Expected %s to be a *core.Pod, got %T", pod.ResourceName, e.Object) return true, fmt.Errorf("Expected %s to be a *core.Pod, got %T", pod.ResourceName, e.Object)
} }
// TODO: enable InitContainerStatuses
for _, cs := range object.Status.ContainerStatuses { for _, cs := range object.Status.ContainerStatuses {
oldState := pod.ContainerMonitorStates[cs.Name] oldState := pod.ContainerMonitorStates[cs.Name]
@ -296,6 +305,8 @@ func (job *JobWatchMonitor) Watch() error {
job.Kube.Log("%s: Jobs active: %d, jobs failed: %d, jobs succeeded: %d", job.ResourceName, object.Status.Active, object.Status.Failed, object.Status.Succeeded) job.Kube.Log("%s: Jobs active: %d, jobs failed: %d, jobs succeeded: %d", job.ResourceName, object.Status.Active, object.Status.Failed, object.Status.Succeeded)
job.Succeeded <- true
return true, nil return true, nil
} else if c.Type == batch.JobFailed && c.Status == core.ConditionTrue { } else if c.Type == batch.JobFailed && c.Status == core.ConditionTrue {
oldState := job.State oldState := job.State
@ -455,8 +466,8 @@ func (c *Client) watchJobTillDone(jobInfo *resource.Info, watchFeed WatchFeed, t
select { select {
case <-job.Started: case <-job.Started:
c.Log("Job %s started", job.ResourceName) c.Log("Job %s started", job.ResourceName)
// TODO watchFeed
case <-job.Succeeded: case <-job.Succeeded:
c.Log("Job %s succeeded", job.ResourceName)
return nil return nil
case err := <-job.Error: case err := <-job.Error:
return err return err

Loading…
Cancel
Save