Skip to content

fix(plugins/ray): disable ANSI color codes and Ray Data progress bars in pod logs#7504

Open
1fanwang wants to merge 1 commit into
flyteorg:mainfrom
1fanwang:fix/ray-disable-log-noise
Open

fix(plugins/ray): disable ANSI color codes and Ray Data progress bars in pod logs#7504
1fanwang wants to merge 1 commit into
flyteorg:mainfrom
1fanwang:fix/ray-disable-log-noise

Conversation

@1fanwang

Copy link
Copy Markdown
Contributor

Why are the changes needed?

Ray decorates its output for an interactive terminal: actor/task log lines get ANSI-colored prefixes, and Ray Data prints tqdm-style progress bars. Flyte collects Ray pod stdout to a non-interactive log sink, where these render as unreadable escape-sequence noise (e.g. \x1b[2m\x1b[36m(pid=...)\x1b[0m) and repeated progress-bar frames, hurting log readability and search.

What changes were proposed in this pull request?

Set two environment variables on the Ray head and worker containers to turn off the terminal-oriented decorations:

  • RAY_COLOR_PREFIX=0 — disables ANSI color in log prefixes
  • RAY_DATA_DISABLE_PROGRESS_BARS=1 — disables Ray Data progress bars

They sit alongside the existing RAY_DISABLE_DOCKER_CPU_WARNING env and are no-ops on Ray builds that don't read them.

How was this patch tested?

Added TestBuildResourceRay_DisablesLogNoiseEnv, which builds the RayJob resource and asserts both env vars are set on the head and worker containers.

Reproduce:

go test ./flyteplugins/go/tasks/plugins/k8s/ray/ -run TestBuildResourceRay_DisablesLogNoiseEnv -v

Before:

--- FAIL: TestBuildResourceRay_DisablesLogNoiseEnv
    head container must set RAY_COLOR_PREFIX=0
    worker container must set RAY_COLOR_PREFIX=0
    head container must set RAY_DATA_DISABLE_PROGRESS_BARS=1
    worker container must set RAY_DATA_DISABLE_PROGRESS_BARS=1

After:

ok  github.com/flyteorg/flyte/v2/flyteplugins/go/tasks/plugins/k8s/ray

Labels

fixed

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

… in pod logs

Signed-off-by: 1fanwang <1fannnw@gmail.com>
Copilot AI review requested due to automatic review settings June 11, 2026 17:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds default Ray environment variables to reduce log noise in head/worker pods, and verifies the behavior via a new unit test.

Changes:

  • Set RAY_COLOR_PREFIX=0 and RAY_DATA_DISABLE_PROGRESS_BARS=1 on Ray head pods.
  • Set the same log-noise env vars on Ray worker pods.
  • Add a unit test asserting these env vars are present on both head and worker containers.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
flyteplugins/go/tasks/plugins/k8s/ray/ray.go Adds env vars to Ray head/worker pod templates to reduce ANSI/progress-bar log noise.
flyteplugins/go/tasks/plugins/k8s/ray/ray_test.go Adds coverage ensuring the new env vars are applied to both head and worker pod specs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +233 to +236
RayResource, err := rayJobResourceHandler.BuildResource(context.TODO(), rayCtx)
assert.Nil(t, err)
ray, ok := RayResource.(*rayv1.RayJob)
assert.True(t, ok)
Comment on lines +233 to +236
RayResource, err := rayJobResourceHandler.BuildResource(context.TODO(), rayCtx)
assert.Nil(t, err)
ray, ok := RayResource.(*rayv1.RayJob)
assert.True(t, ok)
}

headContainers := ray.Spec.RayClusterSpec.HeadGroupSpec.Template.Spec.Containers
workerContainers := ray.Spec.RayClusterSpec.WorkerGroupSpecs[0].Template.Spec.Containers
Comment on lines +238 to +247
hasEnv := func(containers []corev1.Container, name, value string) bool {
for _, c := range containers {
for _, e := range c.Env {
if e.Name == name && e.Value == value {
return true
}
}
}
return false
}
Comment on lines +412 to +421
// Disable Ray's terminal-oriented log decorations (ANSI-colored log prefixes and
// Ray Data progress bars) so logs collected from non-interactive pods stay readable.
{
Name: "RAY_COLOR_PREFIX",
Value: "0",
},
{
Name: "RAY_DATA_DISABLE_PROGRESS_BARS",
Value: "1",
},

@pingsutw pingsutw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, are you running v2 Flyte on the internal cluster?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants