-
Notifications
You must be signed in to change notification settings - Fork 448
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 worker error silent #863
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,8 +149,9 @@ func (s *sidecarInjector) Mutate(pod *v1.Pod, namespace string) (*v1.Pod, error) | |
return nil, err | ||
} | ||
args := getMetricsCollectorArgs(trialName, metricName, trial.Spec.MetricsCollector) | ||
sidecarContainerName := getSidecarContainerName(trial.Spec.MetricsCollector.Collector.Kind) | ||
injectContainer := v1.Container{ | ||
Name: mccommon.MetricCollectorContainerName, | ||
Name: sidecarContainerName, | ||
Image: image, | ||
Args: args, | ||
ImagePullPolicy: v1.PullIfNotPresent, | ||
|
@@ -161,7 +162,7 @@ func (s *sidecarInjector) Mutate(pod *v1.Pod, namespace string) (*v1.Pod, error) | |
|
||
if mountPath, pathKind := getMountPath(trial.Spec.MetricsCollector); mountPath != "" { | ||
wrapWorkerContainer(mutatedPod, kind, mountPath, trial.Spec.MetricsCollector) | ||
if err = mutateVolume(mutatedPod, kind, mountPath, pathKind); err != nil { | ||
if err = mutateVolume(mutatedPod, kind, mountPath, sidecarContainerName, pathKind); err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
@@ -244,7 +245,7 @@ func wrapWorkerContainer(pod *v1.Pod, jobKind, metricsFile string, mc common.Met | |
if c.Args != nil { | ||
args = append(args, c.Args...) | ||
} | ||
redirectStr := fmt.Sprintf(" 2>&1 | tee %s", metricsFile) | ||
redirectStr := fmt.Sprintf("1>%s 2>&1", metricsFile) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do we let users know that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SGTM There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SGTM |
||
args = append(args, redirectStr) | ||
argsStr := strings.Join(args, " ") | ||
c.Command = command | ||
|
@@ -275,7 +276,7 @@ func isWorkerContainer(jobKind string, index int, c v1.Container) bool { | |
return false | ||
} | ||
|
||
func mutateVolume(pod *v1.Pod, jobKind, mountPath string, pathKind common.FileSystemKind) error { | ||
func mutateVolume(pod *v1.Pod, jobKind, mountPath, sidecarContainerName string, pathKind common.FileSystemKind) error { | ||
metricsVol := v1.Volume{ | ||
Name: common.MetricsVolume, | ||
VolumeSource: v1.VolumeSource{ | ||
|
@@ -293,7 +294,7 @@ func mutateVolume(pod *v1.Pod, jobKind, mountPath string, pathKind common.FileSy | |
index_list := []int{} | ||
for i, c := range pod.Spec.Containers { | ||
shouldMount := false | ||
if c.Name == mccommon.MetricCollectorContainerName { | ||
if c.Name == sidecarContainerName { | ||
shouldMount = true | ||
} else { | ||
shouldMount = isWorkerContainer(jobKind, i, c) | ||
|
@@ -314,3 +315,11 @@ func mutateVolume(pod *v1.Pod, jobKind, mountPath string, pathKind common.FileSy | |
|
||
return nil | ||
} | ||
|
||
func getSidecarContainerName(cKind common.CollectorKind) string { | ||
if cKind == common.StdOutCollector || cKind == common.FileCollector { | ||
return mccommon.MetricLoggerCollectorContainerName | ||
} else { | ||
return mccommon.MetricCollectorContainerName | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use the third-party tool such as https://github.com/hpcloud/tail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, I can update it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you signal the completion of tail logs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we doesn't need know the completion of tail logs, when the worker container exit, metrics collector main process will start to collect and parse the file, and then exit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering if there is a chance to miss certain worker container logs in this case.