redhat-developer / odo

odo - Developer-focused CLI for fast & iterative container-based application development on Podman and Kubernetes. Implementation of the open Devfile standard.
https://odo.dev
Apache License 2.0
787 stars 243 forks source link

odo telemetry prompt can interfere with bash commands #7145

Closed amisevsk closed 6 months ago

amisevsk commented 11 months ago

/kind bug

What versions of software are you using?

Operating System: Linux

Output of odo version: odo v3.15.0 (10b5e8a8f)

How did you run odo exactly?

With the goal of getting the current odo version:

odo version --client | grep -Eo 'v?[0-9]+\.[0-9]+\.[0-9]+'

(on first run, before seeing telemetry prompt)

Actual behavior

The command hangs indefinitely and cannot be cancelled (i.e. ctrl+c does not work).

Expected behavior

Either odo should prompt for telemetry on stderr (instead of stdout) so that users see the prompt in these cases, or it should avoid prompting when output is redirected to a file/pipe.

Any logs, error output, etc?

Can be reproduced with the following Dockerfile

FROM registry.access.redhat.com/ubi8-minimal:8.8-860

RUN microdnf install -y curl \
    && curl -L https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/odo/v3.15.0/odo-linux-amd64 -o /usr/local/bin/odo \
    && chmod a+x /usr/local/bin/odo \
    && microdnf -y clean all

RUN echo -e '#!/bin/bash \n\
             odo version --client | grep -Eo "v?[0-9]+\.[0-9]+\.[0-9]+" \n\
             exec "$@"' > /entrypoint.sh \
    && chmod a+x /entrypoint.sh

ENTRYPOINT [ "/entrypoint.sh" ]

If I build an image from this Dockerfile, then

More background

The Web Terminal Operator includes odo as part of its built-in tooling. In order to be able to list the software and versions installed, the web-terminal-tooling container generates a "installed-versions.txt" file at startup using the above command, which can hang if e.g. it is run from an interactive prompt.

As a workaround, we just close stdin before calling the script, which avoids the issue.

rm3l commented 10 months ago

/area telemetry /remove-status needs-triage

Hi @amisevsk,

Thanks for reporting this issue.

While I agree it makes sense for odo to avoid prompting when the output is piped or redirected to a file, I'd like to suggest two more things:

Would that work for you?

github-actions[bot] commented 7 months ago

A friendly reminder that this issue had no activity for 90 days. Stale issues will be closed after an additional 30 days of inactivity.

github-actions[bot] commented 6 months ago

This issue was closed because it has been inactive for 30 days since being marked as stale.