Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 2081678

Summary: ANSI color modification carried over to pods without ANSI color code defined
Product: OpenShift Container Platform Reporter: Simon Reber <sreber>
Component: Management ConsoleAssignee: Yadan Pei <yapei>
Status: CLOSED WONTFIX QA Contact: Yanping Zhang <yanpzhan>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.10CC: jcaiani, jhadvig, juntwang, simon.reber, yapei
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-04-30 18:04:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Simon Reber 2022-05-04 11:01:44 UTC
Description of problem:

Starting with OpenShift Container Platform 4, ANSI color support was added in the OpenShift Container Platform 4 - Console (see https://github.com/openshift/console/pull/10486)

This works well, until an application does not end ANSI color modification with `\e[0m`. If that is not done logs from other pods will show the ANSI color modification from the last line that had it specified, even when those pods don't define ANSI color code.

> apiVersion: v1
> kind: Pod
> metadata:
>   name: coloring
>   labels:
>     purpose: coloring
> spec:
>   containers:
>   - args:
>     - -c
>     - |
>       # trying color scheme
>       echo -e "\e[31mRed Text\e[0m"
>       echo -e "\e[42mGreen Background\e[0m"
>       echo -e "\e[0;35mPurple"
>       echo -e "No coloring"
>       sleep 9999
>     command:
>     - /bin/bash
>     name: color-container
>     image: registry.redhat.io/ubi8/toolbox:8.5
>   restartPolicy: OnFailure
The above pod is missing `\e[0m` at the end of `echo -e "\e[0;35mPurple"` meaning `echo -e "No coloring"` will also be purple (which sort of can be expected). But when now moving to `openshift-ingress` `namespace` in the OpenShift Container Platform 4 - Console and watching `router` logs, they also show purple, even though the `router` does not have ANSI color modification in the logs.

> apiVersion: v1
> kind: Pod
> metadata:
>   name: coloring
>   labels:
>     purpose: coloring
> spec:
>   containers:
>   - args:
>     - -c
>     - |
>       # trying color scheme
>       echo -e "\e[31mRed Text\e[0m"
>       echo -e "\e[42mGreen Background\e[0m"
>       echo -e "\e[0;35mPurple\e[0m"
>       echo -e "No coloring"
>       sleep 9999
>     command:
>     - /bin/bash
>     name: color-container
>     image: registry.redhat.io/ubi8/toolbox:8.5
>   restartPolicy: OnFailure

This pod has the expected `\e[0m` at the end of `echo -e "\e[0;35mPurple\e[0m"` and shows the expected behavior. Also no carry over of ANSI color modification to other pods.

Version-Release number of selected component (if applicable):

 - OpenShift Container Platform 4.10.9
 - OpenShift Container Platform 4.11.0-0.nightly-2022-04-26-181148

How reproducible:

 - Always

Steps to Reproduce:
1. Install OpenShift Container Platform 4.10 or later
2. Create the pod as shown below

> apiVersion: v1
> kind: Pod
> metadata:
>   name: coloring
>   labels:
>     purpose: coloring
> spec:
>   containers:
>   - args:
>     - -c
>     - |
>       # trying color scheme
>       echo -e "\e[31mRed Text\e[0m"
>       echo -e "\e[42mGreen Background\e[0m"
>       echo -e "\e[0;35mPurple"
>       echo -e "No coloring"
>       sleep 9999
>     command:
>     - /bin/bash
>     name: color-container
>     image: registry.redhat.io/ubi8/toolbox:8.5
>   restartPolicy: OnFailure

3. Access it's log in the OpenShift Container Platform 4 - Console and validate that after `Purple` output all following lines are colored `Purple`

4. Move to `openshift-ingress` `namespace` and inspect `router` logs which will also show up `Purple`

Actual results:

If ANSI color modification is not ended, the last color code is carried over to the next pod logs

Expected results:

No carry over of unfinished ANSI color modification to other pods and potentially forcefully end ANSI color modification if not specified.

Additional info:

Comment 4 Juntao Wang 2022-05-04 20:17:13 UTC
This is a PatternFly Log Viewer extension bug. The logs will not reset ANSI styles when switching.
There is a fix in PF: https://github.com/patternfly/patternfly-react/pull/7355
When the PR is merged and the new version is released, bumping to the latest PF log viewer version should be able to fix this issue. I will post the target version here after it's released.

Comment 5 Juntao Wang 2022-05-06 20:23:11 UTC
The new version of PF log viewer is @patternfly/react-log-viewer.3, bump to this version could fix the issue.

Comment 8 Joe Caiani 2022-08-22 21:26:11 UTC
patternfly/react-log-viewer is on 4.76.8. This bug was fixed when the pf packages were updated for 4.56.3 here: https://github.com/openshift/console/pull/11489

Comment 9 Joe Caiani 2022-08-22 21:27:56 UTC
@simon.reber this should be fixed in 4.11

Comment 11 Yanping Zhang 2022-09-21 08:26:59 UTC
Checked on ocp 4.11 clusters with payload 4.11.5 and 4.11.0-0.nightly-arm64-2022-09-20-200648, and on ocp 4.12 cluster with payload 4.12.0-0.nightly-2022-09-20-095559.
Steps to verify:
1.Create pod with yaml:
 apiVersion: v1
 kind: Pod
 metadata:
   name: coloring
   labels:
     purpose: coloring
 spec:
   containers:
   - args:
     - -c
     - |
       # trying color scheme
       echo -e "\e[31mRed Text\e[0m"
       echo -e "\e[42mGreen Background\e[0m"
       echo -e "\e[0;35mPurple"
       echo -e "No coloring"
       sleep 9999
     command:
     - /bin/bash
     name: color-container
     image: registry.redhat.io/ubi8/toolbox:8.5
     restartPolicy: OnFailure
2.After pod is running, check the pod's log, after `Purple` output all following lines are colored `Purple` in the pod log.
3.Check other pod's log, eg, in `openshift-ingress` `namespace` and inspect `router` logs, the logs color is normal, not purple now.
The bug is fixed.

Comment 12 Rory Thrasher 2024-04-30 18:04:53 UTC
OCP is no longer using Bugzilla and this bug appears to have been left in an orphaned state. If the bug is still relevant, please open a new issue in the OCPBUGS Jira project: https://issues.redhat.com/projects/OCPBUGS/summary