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

Features should provide a meaningful error message if it's not supported by a devcontainer image #765

Open
robv8r opened this issue Nov 26, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@robv8r
Copy link

robv8r commented Nov 26, 2023

Most Features are only supported on Debian-based devcontainer images. Adding these features to an Alpine or Red Hat devcontainer often results in error messages such as "dpkg: not found."

An error message stating that the OS isn't supported would be more intuitive.

Given that the common-utils script already supports this (see below), it shouldn't be difficult to adapt in other features.

Requiring such a "preamble" may encourage developers to support other base devcontainer images, much like common-utils does.

# Bring in ID, ID_LIKE, VERSION_ID, VERSION_CODENAME
. /etc/os-release
# Get an adjusted ID independent of distro variants
if [ "${ID}" = "debian" ] || [ "${ID_LIKE}" = "debian" ]; then
    ADJUSTED_ID="debian"
elif [[ "${ID}" = "rhel" || "${ID}" = "fedora" || "${ID}" = "mariner" || "${ID_LIKE}" = *"rhel"* || "${ID_LIKE}" = *"fedora"* || "${ID_LIKE}" = *"mariner"* ]]; then
    ADJUSTED_ID="rhel"
elif [ "${ID}" = "alpine" ]; then
    ADJUSTED_ID="alpine"
else
    echo "Linux distro ${ID} not supported."
    exit 1
fi
@samruddhikhandale
Copy link
Member

Hi 👋

Thanks for raising this issue.
We do have the OS support mentioned in the README.md files (example), but I can see how that can be easily missed.

Adding error messages for unsupported OS makes complete sense to me 👍
@robv8r If you are interested, feel free to contribute a PR with the changes. We appreciate all the support from the community, thank you!

@samruddhikhandale samruddhikhandale added the enhancement New feature or request label Nov 28, 2023
@robv8r
Copy link
Author

robv8r commented Nov 29, 2023

Currently, there are three officially supported devcontainers:

  • mcr.microsoft.com/devcontainers/base:ubuntu
  • mcr.microsoft.com/devcontainers/base:debian
  • mcr.microsoft.com/devcontainers/base:alpine

The following images are included in automated testing:

  • ubuntu:focal
  • ubuntu:jammy
  • debian:11
  • debian:12
  • mcr.microsoft.com/devcontainers/base:ubuntu
  • mcr.microsoft.com/devcontainers/base:debian

When testing the "OS Not Supported Feature, should Alpine be included in the above list of tested images?

Following the above pattern, these images would be included:

  • alpine:3.17
  • alpine:3.18
  • mcr.microsoft.com/devcontainers/base:alpine

While the Alpine devcontainer base image includes bash, the alpine Docker Hub images do not. Because the install.sh files for features are typically written for bash, they would fail to execute on the alpine Docker Hub images.

Should we include only the Alpine devcontainer base image or should we follow common-utils approach by using #!/bin/sh for install.sh and install bash if it doesn't already exist?

Much like common-utils, this would require a second file with either #!/bin/bash or #!/usr/bin/env bash.

While this may be outside the scope of the "Operating System Not Supported Feature", I feel that choosing an appropriate testing strategy is important before getting started.

As always, constructive feedback is welcome.

@robv8r
Copy link
Author

robv8r commented Nov 29, 2023

If anyone has suggestions for testing "the inability to install a feature," I'm all ears.

@joshuanianji
Copy link

This spec proposal for supported Architectures/OS (devcontainers/spec#58) seems to be similar to what you're looking for, although it's in backlog right now. I like the idea of common-util's "preamble" script, although there are already so many features that requiring something new might be difficult to enforce.

Another idea (which is also a proposal) would be to have this preamble be a feature library (see: spec/proposals/feature-library.md) so it's easier to add.

For the time being, I think I'll just use your preamble idea for the features I support. I do admit I don't really think of Alpine/non-debian or ubuntu images when making features though, maybe I'll add some support when I have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants