Skip to content

Improve feature installation logs - #178

Merged
John Keech (jkeech) merged 7 commits into
mainfrom
jkeech/feature-logs
Sep 19, 2022
Merged

John Keech (jkeech) merged 7 commits into
mainfrom
jkeech/feature-logs

Conversation

@jkeech

Copy link
Copy Markdown
Contributor

Add a header to the output logs for each feature that is executed to provide info about the feature

Example:

#15 [dev_containers_target_stage 4/4] RUN cd /tmp/build-features/docker-in-docker_2 && chmod +x ./devcontainer-features-install.sh && ./devcontainer-features-install.sh
#15 0.521 ===========================================================================
#15 0.521 Feature       : Docker (Docker-in-Docker)
#15 0.521 Description   : Create child containers *inside* a container, independent from the host's docker instance. Installs Docker extension in the container along with needed CLIs.
#15 0.521 Id            : ghcr.io/devcontainers/features/docker-in-docker
#15 0.521 Version       : 1.0.4
#15 0.521 Documentation : https://github.com/devcontainers/features/tree/main/src/docker-in-docker
#15 0.521 Options       :
#15 0.521     VERSION=latest
#15 0.521     MOBY=true
#15 0.521     DOCKERDASHCOMPOSEVERSION=v1
#15 0.521 ===========================================================================
#15 0.669 DOCKER_MOBY_ARCHIVE_VERSION_CODENAMES=buster bullseye bionic focal jammy
#15 0.669 Distro codename  'bullseye'  matched filter  'buster bullseye bionic focal jammy'
#15 0.675 Running apt-get update...
#15 0.714 Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
...

In order to print out feature information in the middle of the docker build, we are now injecting a wrapper script as the command to RUN instead of directly invoking the feature's install.sh. The wrapper script prints the header, sources the devcontainer-features.env and then invokes the feature's install.sh. This simplifies the RUN command in the Dockerfile and gives us a nice spot to handle both before and after a feature executes.

If a feature fails to install, a clear error message is printed saying which feature failed with a pointer to the documentation for that feature. This is accomplished with trap on_exit EXIT that runs the on_exit() function before the script exits.

Added unit and e2e tests to cover the v2 feature install path.

Fixes: #170

@jkeech
John Keech (jkeech) requested a review from a team as a code owner September 17, 2022 03:29

@chrmarti Christof Marti (chrmarti) 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.

LGTM! Left a suggestion.

joshspicer
joshspicer previously approved these changes Sep 19, 2022

@joshspicer joshspicer 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.

woo!

@jkeech
John Keech (jkeech) merged commit deeb19b into main Sep 19, 2022
@jkeech
John Keech (jkeech) deleted the jkeech/feature-logs branch September 19, 2022 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants