operator-registry icon indicating copy to clipboard operation
operator-registry copied to clipboard

opm index add fails on Apple Silicone

Open bo0ts opened this issue 4 years ago • 6 comments

I get the following running this on an MacBook with M1:

opm index add -c docker --debug \
   --bundles my-reg.com/my-bundle:v0.0.126 \
   --from-index my-reg.com/my-index:v1.0.125 \
   --tag my-reg.com/my-index:v1.0.126

ERRO[0000] failure getting variant                       error="getCPUInfo for OS darwin: not implemented"
INFO[0000] building the index                            bundles="[my-reg.com/my-bundle:v0.0.126]"
INFO[0000] Pulling previous image my-reg.com/my-index:v1.0.125 to get metadata  bundles="[my-reg.com/my-bundle:v0.0.126]"
INFO[0000] running /usr/local/bin/docker pull my-reg.com/my-index:v1.0.125  bundles="[my-reg.com/my-bundle:v0.0.126]"
INFO[0000] running /usr/local/bin/docker pull my-reg.com/my-index:v1.0.125  bundles="[my-reg.com/my-bundle:v0.0.126]"
INFO[0001] Getting label data from previous image        bundles="[my-reg.com/my-bundle:v0.0.126]"
INFO[0001] running docker inspect                        bundles="[my-reg.com/my-bundle:v0.0.126]"
DEBU[0001] [docker inspect my-reg.com/my-index:v1.0.125]  bundles="[my-reg.com/my-bundle:v0.0.126]"
INFO[0001] running docker create                         bundles="[my-reg.com/my-bundle:v0.0.126]"
DEBU[0001] [docker create my-reg.com/my-index:v1.0.125 ]  bundles="[my-reg.com/my-bundle:v0.0.126]"
INFO[0002] running docker cp                             bundles="[my-reg.com/my-bundle:v0.0.126]"
DEBU[0002] [docker cp WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
e9edf293087e2a540affe9916b384bebeec27c5d322d5162a653c047564cd9eb:/. index_tmp_888660411]  bundles="[my-reg.com/my-bundle:v0.0.126]"
ERRO[0002] Error: No such container:path: WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
e9edf293087e2a540affe9916b384bebeec27c5d322d5162a653c047564cd9eb:/.  bundles="[my-reg.com/my-bundle:v0.0.126]"
Error: error copying container directory Error: No such container:path: WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
e9edf293087e2a540affe9916b384bebeec27c5d322d5162a653c047564cd9eb:/.
: exit status 1
Usage:
  opm index add [flags]
   ... and more -h ...

The WARNING should be of no consequence, but it seems that it is messing up docker invocations.

opm version
ERRO[0000] failure getting variant                       error="getCPUInfo for OS darwin: not implemented"
Version: version.Version{OpmVersion:"v1.17.0-28-ge29651f8", GitCommit:"e29651f8", BuildDate:"2021-05-04T09:02:04Z", GoOs:"darwin", GoArch:"arm64"}

operator-sdk version
operator-sdk version: "v1.6.2", commit: "b131ca8ec77c96b9898470eba9560c30af0f23f3", kubernetes version: "v1.19.4", go version: "go1.16.3", GOOS: "darwin", GOARCH: "arm

bo0ts avatar May 06 '21 08:05 bo0ts

@bo0ts opm does not support cross-platform index image manipulation with the index subcommand.

It looks like your my-reg.com/my-index:v1.0.125 is a linux/amd64 image, but Mac M1 is darwin/arm64. opm does not support passing a plumbing docker's --platform flag, so there's no way to override that.

Can you try re-running that command with the --generate flag and then manually build the image yourself using the generated Dockerfile. With this approach, you can call docker yourself with the --platform=linux/amd64 flag.

joelanford avatar May 17 '21 17:05 joelanford

We also just hit this issue when building multi-architecture index images for s390x and amd64 using docker-ce @ 20.10.8

Passing the --generate flag doesn't stop the ERROR logs from surfacing and the overall path through this approach can be tricky.

Adding the --permissive flag allowed the error to be ignored, but I worry about this causing "silent" failures in the future. Would it be possible to pass the --platform flag when the container tool used is docker?

I'd imagine that's a relatively simple fix?

ivandov avatar Sep 08 '21 20:09 ivandov

Also, it seems the --generate only runs towards the end of the process, and therefore even passing that flag in doesn't output a Dockerfile to do a manual build from.

ivandov avatar Sep 09 '21 21:09 ivandov

As of the next release (its already on master), the opm index and opm registry commands are deprecated, so I think its unlikely that we'll be adding new features (e.g. support for running on the darwin/arm64 platform) to those commands.

@ivandov Is your issue also with how this works on darwin/arm64 machines? If so, I think the workaround would be to use opm index --generate on a supported platform, and then stick to opm registry + docker build commands if you need to get this working on a Mac M1 machine.

joelanford avatar Sep 09 '21 21:09 joelanford

@joelanford my issue is not for darwin/arm64 machines, however I believed the underlying root cause was the same as this issue.

If you'd prefer, I can open a new issue to track this specific change. In my case, as far as I've seen, the opm index --generate flag wasn't outputting the desired dockerfile because part of the process was failing before it even got to the point of generating the Dockerfile.

ivandov avatar Sep 13 '21 14:09 ivandov

@ivandov - Would you mind opening a separate issue for that? Please include:

  1. The command you're running.
  2. The output you're seeing.
  3. What you expect to see.
  4. The version of opm you're using.
  5. The platform on which you are running opm.
  6. The platform you're trying to build the index image for.

joelanford avatar Sep 13 '21 14:09 joelanford

closing this since the resolution was to open a separate issue

grokspawn avatar Sep 23 '22 20:09 grokspawn