Skip to content
Open
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
11 changes: 9 additions & 2 deletions pkg/cli/admin/mustgather/mustgather.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func NewMustGatherCommand(f kcmdutil.Factory, streams genericiooptions.IOStreams
cmd.Flags().MarkHidden("keep")
cmd.Flags().StringVar(&o.SinceTime, "since-time", o.SinceTime, "Only return logs after a specific date (RFC3339). Defaults to all logs. Plugins are encouraged but not required to support this. Only one of since-time / since may be used. This may not be applied to all commands in must-gather image (e.g. not every command complies with RFC3339, the use might be limited, etc.).")
cmd.Flags().DurationVar(&o.Since, "since", o.Since, "Only return logs newer than a relative duration like 5s, 2m, or 3h. Defaults to all logs. Plugins are encouraged but not required to support this. Only one of since-time / since may be used.")
cmd.Flags().BoolVar(&o.PullAlways, "pull-always", false, "If true, always pull the gather image.")

return cmd
}
Expand Down Expand Up @@ -355,6 +356,7 @@ type MustGatherOptions struct {
Keep bool
Since time.Duration
SinceTime string
PullAlways bool

RsyncRshCmd string

Expand Down Expand Up @@ -942,6 +944,11 @@ func (o *MustGatherOptions) newPod(node, image string, hasMaster bool) *corev1.P
cleanedSourceDir := path.Clean(o.SourceDir)
volumeUsageChecker := fmt.Sprintf(volumeUsageCheckerScript, cleanedSourceDir, cleanedSourceDir, o.VolumePercentage, o.VolumePercentage, executedCommand)

imagePullPolicy := corev1.PullIfNotPresent
if o.PullAlways {
imagePullPolicy = corev1.PullAlways
}

ret := &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "must-gather-",
Expand All @@ -968,7 +975,7 @@ func (o *MustGatherOptions) newPod(node, image string, hasMaster bool) *corev1.P
{
Name: gatherContainerName,
Image: image,
ImagePullPolicy: corev1.PullIfNotPresent,
ImagePullPolicy: imagePullPolicy,
// always force disk flush to ensure that all data gathered is accessible in the copy container
Command: []string{"/bin/bash", "-c", fmt.Sprintf("%s & %s; sync", volumeUsageChecker, executedCommand)},
Env: []corev1.EnvVar{
Expand Down Expand Up @@ -1001,7 +1008,7 @@ func (o *MustGatherOptions) newPod(node, image string, hasMaster bool) *corev1.P
{
Name: "copy",
Image: image,
ImagePullPolicy: corev1.PullIfNotPresent,
ImagePullPolicy: imagePullPolicy,
Command: []string{"/bin/bash", "-c", "trap : TERM INT; sleep infinity & wait"},
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
VolumeMounts: []corev1.VolumeMount{
Expand Down