Skip to content

Commit

Permalink
Adds warning for running podman on Apple Silicon (redhat-developer#5629)
Browse files Browse the repository at this point in the history
<!--
Thank you for opening a PR! Here are some things you need to know before submitting:

1. Please read our developer guideline: https://github.com/redhat-developer/odo/wiki/Dev:-odo-Dev-Guidelines
2. Label this PR accordingly with the '/kind' line
3. Ensure you have written and ran the appropriate tests: https://github.com/redhat-developer/odo/wiki/Dev:-Writing-and-running-tests
4. Read how we approve and LGTM each PR: https://github.com/redhat-developer/odo/wiki/Pull-Requests:-Review-guideline

Documentation:

If you are pushing a change to documentation, please read: https://github.com/redhat-developer/odo/wiki/Documentation:-Contributing
-->

**What type of PR is this:**

<!--
Add one of the following kinds:
/kind bug
/kind cleanup
/kind tests
/kind documentation

Feel free to use other [labels](https://github.com/redhat-developer/odo/labels) as needed. However one of the above labels must be present or the PR will not be reviewed. This instruction is for reviewers as well.
-->

/kind feature

**What does this PR do / why we need it:**

Warns the user if we are trying to run Podman on Mac M1. As we are
unable to build x86 images natively unless using the workaround.

**Which issue(s) this PR fixes:**
<!--
Specifying the issue will automatically close it when this PR is merged
-->

Fixes redhat-developer#5597

**PR acceptance criteria:**

- [X] Unit test

- [X] Integration test

- [X] Documentation

**How to test changes / Special notes to the reviewer:**

Run it on a M1 mac :)

Signed-off-by: Charlie Drage <[email protected]>
  • Loading branch information
cdrage committed Aug 31, 2022
1 parent 41da730 commit 2f17521
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/devfile/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ func selectBackend() (Backend, error) {
podmanCmd = "podman"
}
if _, err := lookPathCmd(podmanCmd); err == nil {

// Podman does NOT build x86 images on Apple Silicon / M1 and we must *WARN* the user that this will not work.
// There is a temporary workaround in order to build x86 images on Apple Silicon / M1 by running the following commands:
// podman machine ssh sudo rpm-ostree install qemu-user-static
// podman machine ssh sudo systemctl reboot
//
// The problem is that Fedora CoreOS does not have qemu-user-static installed by default,
// and the workaround is to install it manually as the dependencies need to be integrated into the Fedora ecosystem
// The open discussion is here: https://github.com/containers/podman/discussions/12899
//
// TODO: Remove this warning when Podman natively supports x86 images on Apple Silicon / M1.
if log.IsAppleSilicon() {
log.Warning("WARNING: Building images on Apple Silicon / M1 is not (yet) supported natively on Podman")
log.Warning("There is however a temporary workaround: https://github.com/containers/podman/discussions/12899")
}
return NewDockerCompatibleBackend(podmanCmd), nil
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/log/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,11 @@ func IsDebug() bool {
return false
}

// IsAppleSilicon returns true if we are on a Mac M1 / Apple Silicon natively
func IsAppleSilicon() bool {
return runtime.GOOS == "darwin" && (strings.HasPrefix(runtime.GOARCH, "arm") || strings.HasPrefix(runtime.GOARCH, "arm64"))
}

// GetStdout gets the appropriate stdout from the OS. If it's Linux, it will use
// the go-colorable library in order to fix any and all color ASCII issues.
// TODO: Test needs to be added once we get Windows testing available on TravisCI / CI platform.
Expand Down

0 comments on commit 2f17521

Please sign in to comment.