Skip to content

OCPBUGS-54247: Debug pod logs outputs the shell prompt duplicitly at the top of the logs. #14919

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
9 changes: 7 additions & 2 deletions frontend/public/components/utils/resource-log.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,6 @@ export const ResourceLog: React.FC<ResourceLogProps> = ({
const [namespaceUID, setNamespaceUID] = React.useState('');
const [podLogLinks, setPodLogLinks] = React.useState();
const [content, setContent] = React.useState('');

const [logType, setLogType] = React.useState<LogTypeStatus>(LOG_TYPE_CURRENT);
const [hasPreviousLogs, setPreviousLogs] = React.useState(false);

Expand Down Expand Up @@ -631,6 +630,7 @@ export const ResourceLog: React.FC<ResourceLogProps> = ({
}, [containerName, resource.kind, resource.status]);

const startWebSocket = React.useCallback(() => {
let initialShellPrompt = true;
// Handler for websocket onopen event
const onOpen = () => {
buffer.current.clear();
Expand All @@ -647,6 +647,11 @@ export const ResourceLog: React.FC<ResourceLogProps> = ({
// Handler for websocket onmessage event
const onMessage = (msg) => {
if (msg) {
// Workaround for Websocket sending the shell prompt twice on the first log line
if (initialShellPrompt) {
initialShellPrompt = false;
return;
}
clearTimeout(timeoutIdRef.current);
const text = Base64.decode(msg);
countRef.current += buffer.current.ingest(text);
Expand All @@ -656,7 +661,7 @@ export const ResourceLog: React.FC<ResourceLogProps> = ({
countRef.current = 0;
setLines(
buffer.current.getTail() === ''
? [...buffer.current.getLines()]
? [...[buffer.current.getLines()]]
: [...buffer.current.getLines(), buffer.current.getTail()],
);
setHasTruncated(buffer.current.getHasTruncated());
Expand Down