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

chore: Merge back v2.0.8 #5655

Merged
merged 2 commits into from
Jul 11, 2024
Merged
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
10 changes: 5 additions & 5 deletions pkg/testworkflows/testworkflowcontroller/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type ContainerLog struct {
// getContainerLogsStream is getting logs stream, and tries to reinitialize the stream on EOF.
// EOF may happen not only on the actual container end, but also in case of the log rotation.
// @see {@link https://stackoverflow.com/a/68673451}
func getContainerLogsStream(ctx context.Context, clientSet kubernetes.Interface, namespace, podName, containerName string, pod Channel[*corev1.Pod], since *time.Time) (io.Reader, error) {
func getContainerLogsStream(ctx context.Context, clientSet kubernetes.Interface, namespace, podName, containerName string, follow bool, pod Channel[*corev1.Pod], since *time.Time) (io.Reader, error) {
// Fail immediately if the context is finished
if ctx.Err() != nil {
return nil, ctx.Err()
Expand All @@ -58,7 +58,7 @@ func getContainerLogsStream(ctx context.Context, clientSet kubernetes.Interface,
// Create logs stream request
req := clientSet.CoreV1().Pods(namespace).GetLogs(podName, &corev1.PodLogOptions{
Container: containerName,
Follow: true,
Follow: follow,
Timestamps: true,
SinceTime: sinceTime,
})
Expand Down Expand Up @@ -103,7 +103,7 @@ func getContainerLogsStream(ctx context.Context, clientSet kubernetes.Interface,
return stream, nil
}

func WatchContainerLogs(parentCtx context.Context, clientSet kubernetes.Interface, namespace, podName, containerName string, bufferSize int, pod Channel[*corev1.Pod]) Channel[ContainerLog] {
func WatchContainerLogs(parentCtx context.Context, clientSet kubernetes.Interface, namespace, podName, containerName string, follow bool, bufferSize int, pod Channel[*corev1.Pod]) Channel[ContainerLog] {
ctx, ctxCancel := context.WithCancel(parentCtx)
w := newChannel[ContainerLog](ctx, bufferSize)

Expand All @@ -119,7 +119,7 @@ func WatchContainerLogs(parentCtx context.Context, clientSet kubernetes.Interfac
var since *time.Time

// Create logs stream request
stream, err := getContainerLogsStream(ctx, clientSet, namespace, podName, containerName, pod, since)
stream, err := getContainerLogsStream(ctx, clientSet, namespace, podName, containerName, follow, pod, since)
hadAnyContent := false
if err == io.EOF {
return
Expand Down Expand Up @@ -241,7 +241,7 @@ func WatchContainerLogs(parentCtx context.Context, clientSet kubernetes.Interfac
}
// Reinitialize logs stream
since = common.Ptr(tsReader.ts.Add(1))
stream, err = getContainerLogsStream(ctx, clientSet, namespace, podName, containerName, pod, since)
stream, err = getContainerLogsStream(ctx, clientSet, namespace, podName, containerName, follow, pod, since)
if err != nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/testworkflows/testworkflowcontroller/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

const (
KubernetesLogTimeFormat = "2006-01-02T15:04:05.999999999Z"
KubernetesLogTimeFormat = "2006-01-02T15:04:05.000000000Z"
KubernetesTimezoneLogTimeFormat = KubernetesLogTimeFormat + "07:00"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func WatchInstrumentedPod(parentCtx context.Context, clientSet kubernetes.Interf

// Watch the container logs
follow := common.ResolvePtr(opts.Follow, true) && !state.IsFinished(ref)
for v := range WatchContainerLogs(ctx, clientSet, podObj.Namespace, podObj.Name, ref, 10, pod).Channel() {
for v := range WatchContainerLogs(ctx, clientSet, podObj.Namespace, podObj.Name, ref, follow, 10, pod).Channel() {
if v.Error != nil {
s.Error(v.Error)
} else if v.Value.Output != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/testworkflows/testworkflowprocessor/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func (c *container) Resolve(m ...expressions.Machine) error {
}
env := c.Env()
name = name[4:]
for i := range env {
for i := len(env) - 1; i >= 0; i-- {
if env[i].Name == name && env[i].ValueFrom == nil {
value, err := expressions.EvalTemplate(env[i].Value)
if err == nil {
Expand Down
Loading