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

[preview-install] Add user-friendly output #10695

Merged
merged 1 commit into from
Jun 17, 2022
Merged

Conversation

Pothulapati
Copy link
Contributor

@Pothulapati Pothulapati commented Jun 16, 2022

Description

This PR adds user friendly output to the preview install
docker container by adding a new program prettylog that
looks at the output of the entry-point.sh and just adds status
updates and spinners.

This feels easier instead of adding the same status updates in
bash.

The status updates are also kept as simple as possible and
any additional instructions (URL, and certs) will be added
to the documentation instead of here. Feel free to post here
if you think it would be better to have them here in the
script.

Signed-off-by: Tarun Pothulapati tarun@gitpod.io

Related Issue(s)

Part of #9075

How to test

Run docker run --privileged --name gitpod --rm -it -v /tmp/gitpod:/var/gitpod eu.gcr.io/gitpod-core-dev/build/preview-install:tar-preview-output.5

Release Notes

[preview-install] Add user-friendly output

Documentation

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-tar-preview-output.4 because the annotations in the pull request description changed
(with .werft/ from main)

@github-actions github-actions bot added the team: delivery Issue belongs to the self-hosted team label Jun 16, 2022
@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-tar-preview-output.6 because the annotations in the pull request description changed
(with .werft/ from main)

for f in /var/lib/rancher/k3s/server/manifests/gitpod/*PersistentVolumeClaim*.yaml; do yq e -i '.spec.storageClassName="local-path"' "$f"; done
# Set `volumeClassTemplate` so that each replica creates its own PVC
yq eval-all -i ". as \$item ireduce ({}; . *+ \$item)" /var/lib/rancher/k3s/server/manifests/gitpod/*_StatefulSet_messagebus.yaml /app/manifests/messagebus.yaml
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, Guessing we might not actually need this, will try and revert back!

@@ -5,6 +5,10 @@

set -ex

if [ "$1" != "logging" ]; then
$0 logging 2>&1 | /prettylog
Copy link
Contributor

Choose a reason for hiding this comment

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

If I'm reading this correctly, we're re-launching this script in order to redirect all logs to /prettylog, correct?

If we are relaunching the script with the intent described above, we can use exec to redirect stdout/stderr, with something like this:

exec > >(/prettylog) 2>&1

This way we don't need to relaunch the script; we can launch /prettylog with process substitution and redirect stderr/stdout with exec.

This is another approach to the problem, but isn't necessarily better or worse. If you like the above approach we can adopt it; if what you have is more readable then let's keep it as-is. 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Following up on this, we're also relying on the set -e to exit this script upon error, and we're relying on /entrypoint.sh and prettylog to exit with a non-zero exit value. When the user hits ctrl-c to kill the container, the forked processes exit non-zero then the behavior of set -e in the parent process kicks in and terminates the script.

If the set -e is removed for whatever reason, then when the forked processes exit we'll proceed to run this script again, which isn't intended. I think this code will be a little bit more correct to have an exit after $0 logging; that way changes in exit codes or other behaviors won't accidentally run the script twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This way we don't need to relaunch the script; we can launch /prettylog with process substitution and redirect stderr/stdout with exec.

I tried doing this but I get an error stating that In POSIX sh, process substition is undefined which makes sense as its a sh script, and not bash. This is important to work with the tini in the leeway.Dockerfile. (I tried replacing it with bash but couldn't get far)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ach, Bourne shell strikes again! Thanks for investigating this!

Part of #9075

This PR adds user friendly output to the preview install
docker container by adding a new program prettylog that
looks at the output of the entry-point.sh and just adds status
updates and spinners.

This feels easier instead of adding the same status updates in
bash.

The status updates are also kept as simple as possible and
any additional instructions (URL, and certs) will be added
to the documentation instead of here. Feel free to post here
if you think it would be better to have them here in the
script.

Signed-off-by: Tarun Pothulapati <tarun@gitpod.io>
@roboquat roboquat merged commit 12d4b39 into main Jun 17, 2022
@roboquat roboquat deleted the tar/preview-output branch June 17, 2022 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note size/L team: delivery Issue belongs to the self-hosted team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants