Commit Graph

37 Commits

Author SHA1 Message Date
James Sturtevant
d9ff8ebef5 support multi-arch images for windows via ctr
Signed-off-by: James Sturtevant <jstur@microsoft.com>
2021-03-31 15:50:01 -07:00
Derek McGowan
c4bff3d17c
Merge pull request #4943 from AkihiroSuda/platforms-literallyonly
platforms: add subarchless version of Only()
2021-01-20 17:27:43 -08:00
Jason Hall
363f2c392c Derive cpuinfo as needed, instead of at init-time
This changes platforms.Parse to hit /proc to look up CPU info only when
it's needed, instead of in init(). This makes the package a bit easier
for other packages to consume, especially clients that don't call
platforms.Parse or need to lookup CPU info.

Signed-off-by: Jason Hall <jasonhall@redhat.com>
2021-01-19 14:10:39 -05:00
Akihiro Suda
e22ce0fa03
platforms: add subarchless version of Only()
`OnlyStrict()` returns a match comparer for a single platform.

Unlike `Only()`, `OnlyStrict()` does not match sub platforms.
So, "arm/vN" will not match "arm/vM" where M < N, and "amd64" will not also match "386".

`OnlyStrict()` matches non-canonical forms. So, "arm64" matches "arm/64/v8".

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-01-15 14:58:14 +09:00
Tianon Gravi
4073aaa7a9 Allow arm64 to fallback to arm (v8, v7, v6, v5)
This isn't supported by *all* arm64 chips, but it is common enough that I think it's worth an explicit fallback.  I think it will be more common for images to have arm64 support without arm support, but even if a user has an arm64 chip that does not support arm32, having it fail to run the arm32 image is an acceptable compromise (because it's non-trivial to detect arm32 support without running a binary, AFAIK).

Also, before this change the failure would've simply been "no such image" instead of "failed to run" so I think it's pretty reasonable to allow it to try the additional 32bit set of images just in case one of them actually does work (like it will on many popular chips like 64bit Raspberry Pis and AWS Graviton).

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
2021-01-13 09:19:08 -08:00
Tianon Gravi
5fa5f15de5 Add amd64->386 fallback
Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
2021-01-11 16:18:19 -08:00
Tianon Gravi
9072b09145 Refactor platforms.Only with a "platformVector" helper
This improves the hard-coded list of ARM fallbacks in the `platform.Only` implementation (by doing a descending loop over variant numbers instead, which is all the hard-coded list was doing).

Making this a separate function can then more easily be recursive later for handling an `arm64`->`arm` fallback (or similar), but I think it makes the code a lot more clear too (so we're calculating a vector of platforms separately from building a matcher object).

This also makes a minor adjustment in `TestImagePullWithDistSourceLabel` which had an implicit assumption that `platforms.Only` would only ever result in a single suitable manifest, which isn't strictly true (and is likely failing as-is when run on any 32bit `arm` system that's `v6` or higher, which this fixes 😅).

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
2020-12-28 14:11:14 -08:00
Tianon Gravi
66a3f2cbc7 Add platforms.Only test
This adds a test for `platforms.Only` (previously untested, as far as I can tell).

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
2020-12-23 14:54:16 -08:00
Kazuyoshi Kato
bb8aac38a0 Do not hardcode "amd64" on LCOW and Windows-related files
Fixes #3281.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2020-11-09 13:39:07 -08:00
Tianon Gravi
2055e12953 Add RPi1/RPi0 workaround
On the very popular Raspberry Pi 1 and Zero devices, the CPU is actually ARMv6, but the chip happens to support the feature bit the kernel uses to differentiate v6/v7, so it gets reported as "CPU architecture: 7" and thus fails to run many of the images that get pulled.

To account for this very popular edge case, this also checks "model name" which on these chips will begin with "ARMv6-compatible" -- we could also check uname, but getCPUInfo is already handy, low overhead, and mirrors the code before this.

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
2020-09-04 14:19:37 -07:00
Tonis Tiigi
7119a2a152 platforms: don’t log arm variant error on darwin
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2020-07-14 08:16:14 -07:00
Phil Estes
89de113de9
Support 32-bit userspace on 64-bit ARM cores
Don't rely on /proc/cpuinfo denoting a 64-bit ARMv8 processor if the
runtime detected GOARCH == arm. This allows aarch64 32-bit userspace
distros to run containers properly via a 32-bit runtime.

Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2020-02-13 00:10:01 -05:00
Shengjing Zhu
90cd777a6c platforms: fill default arm variant when parse platform specifier
arm has been supported, but something is missing, causes test failure

    --- FAIL: TestParseSelector/linux (0.00s)
        platforms_test.go:292: arm support not fully implemented: not implemented
    --- FAIL: TestParseSelector/macOS (0.00s)
        platforms_test.go:292: arm support not fully implemented: not implemented

Signed-off-by: Shengjing Zhu <zhsj@debian.org>
2020-01-08 13:35:49 +08:00
sayaoailun
726dcaea50 update cpuinfo to make variant matches aarch64 and so on
Signed-off-by: sayaoailun <guojianwei007@126.com>
2019-11-30 23:48:10 +08:00
Derek McGowan
672b86acf8
Merge pull request #3624 from tklauser/platforms-update
platforms: update known OS and arch values
2019-09-05 16:53:37 -07:00
Tobias Klauser
c8cb864ce0 platforms: update known OS and arch values
Update the lists in isKnownOS and isKnownOS according to goosList and
goarchList taken from Go 1.13, see
https://github.com/golang/go/blob/release-branch.go1.13/src/go/build/syslist.go

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2019-09-05 14:15:43 +02:00
chentanjun
8788af7f8d modify-document-duplicate-word
Signed-off-by: chentanjun <2799194073@qq.com>
2019-09-05 09:10:19 +08:00
chentanjun
92a5b08a68 fix-grammar-mistake
Signed-off-by: chentanjun <2799194073@qq.com>
2019-08-28 16:10:08 +08:00
Jaime Caamaño Ruiz
ad25c1a9c3 Improve ARM platform matching
This commit improves ARM platform matching in two instances:

* Some old kernels reported the CPU architecture of arm64 cpus as
  Aarch64 [1].
* In cases where the user is running with armv8 cpu and kernel but amrhf
  user land (so armhf containerd), a possibility given the compatibility
  of armv8 with armv7.

[1] https://elixir.bootlin.com/linux/v3.14.29/source/arch/arm64/kernel/setup.c#L420

Signed-off-by: Jaime Caamaño Ruiz <jcaamano@suse.com>
2019-05-10 16:27:20 +02:00
Jiri Appl
e6529f4ebc Add support to detect ARM variant on Windows
ARM variant detection logic was authored originally with
POSIX OS in mind. This change leaves POSIX code path unaltered
and adds support to detect ARM variant on Windows by leveraging
runtime.goarch.

Signed-off-by: Jiri Appl <jiria@microsoft.com>
2018-10-10 14:17:11 -07:00
Justin Terry (VM)
0110b3c0bc Introduce the Windows lcow diff/snaphotter
Implements the Windows lcow differ/snapshotter responsible for managing
the creation and lifetime of lcow containers on Windows.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-08-28 13:51:04 -07:00
Derek McGowan
9edcfcc1cb
Add platform match comparer interface
Adds a new platform interface for matching and comparing platforms.
This new interface allows both filtering and ordering of platforms
to support running multiple platform and choosing the best platform.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-08-27 00:11:46 -07:00
Ian Campbell
c83f9773bc platforms: Add MustParse
This function is analogous to `regexp.MustCompile` and can simplify production
of a `Platform` from a hard-coded strings, e.g. for global variable
initialisation.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
2018-08-15 11:30:46 +01:00
Derek McGowan
db3c5afc6d
Normalize arm64 to an empty variant
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-06-23 16:35:46 -07:00
Derek McGowan
37ab93e2c8
Fix arm platform matching
The normalization was being inconsistently applied causing a
failure to match some platforms in manifest lists.
Fix the matcher and normalization to be more consistent and
add changes to parser to prevent the defaulted variants from being
set in the platform structure.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-06-21 17:07:58 -07:00
Jess Valarezo
ac8008437a update platforms Parse to return platform spec, decouple matcher
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2018-02-27 14:21:49 -08:00
Kunal Kushwaha
b12c3215a0 Licence header added
Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
2018-02-19 10:32:26 +09:00
Wei Chen
cbc33018b3 ctr: Add a test file to test cpu getCpuVariant
Change-Id: Id9558de2e41b08c41cf7d4b458774e99e24515a0
Signed-off-by: Wei Chen <Wei.Chen@arm.com>
Signed-off-by: Penny Zheng <Penny.Zheng@arm.com>
2017-12-20 14:50:20 +08:00
Wei Chen
2517e13a5e ctr: Add Variant field to default test expected result
This test case should cover the variant field now, as we have
add Variant to default value of spec.platform.

Change-Id: I8359007d40a4b8f6a072510fff2ba604a062afa1
Signed-off-by: Wei Chen <Wei.Chen@arm.com>
Signed-off-by: Penny Zheng <Penny.Zheng@arm.com>
2017-12-20 14:50:01 +08:00
Wei Chen
3192b36ab9 ctr: Add variant to ARM's DefaultSpec string
The variant is required for platform match while pulling images
for ARM platforms. Currently, the cpuVariant only would be assigned
on linux/arm|arm64 platforms. Other platforms this variable would
be empty. So we can use this cpuVariant to initialize the Variant
field.

Change-Id: Ic065be9b502f1e662445daa61a0973bf56385b37
Signed-off-by: Wei Chen <Wei.Chen@arm.com>
Signed-off-by: Penny Zheng <Penny.Zheng@arm.com>
2017-12-20 14:49:56 +08:00
Wei Chen
a047abb1f6 ctr: Identify the platform.variant for ARM platforms
In the commit "26329b2b8d7fd4e290b2b0f0163547f2d79bb817",
dmcgowan/fix-pull-multi-arch, PR#1535. The containerd has enabled the pull
multi-arch image support. But the platform.variant field of OCI for ARM
hadn't been ready at that time, so all ARM images could not pull successfully.

"
docker.io/library/hello-world:latest:
resolved       |++++++++++++++++++++++++++++++++++++++|
index-sha256:3644c0788e3d3823f9e97f757f01d2ddc6eb5458df9d801:
done           |++++++++++++++++++++++++++++++++++++++|
elapsed: 5.1 s
total:  2.7 Ki (533.0 B/s)
unpacking sha256:3d3823f9e97f757f01d2ddc6eb5458df9d801...
ctr: : manifest not found: not found
"

In this patch we'll detect the ARM variants from /proc/cpuinfo. Because Linux
kernel has already detected the ABI, ISA and Features for us. We don't need to
parse them from registers again.

Change-Id: I479b34bf3f52df9f7a6b3c77718b7d316dbf7f69
Signed-off-by: Wei Chen <Wei.Chen@arm.com>
Signed-off-by: Penny Zheng <Penny.Zheng@arm.com>
2017-12-20 14:49:51 +08:00
Wei Chen
4355ba2f83 ctr: Add helpers to database to check Linux and ARM arch
On ARM platforms, we have to prepare the variant for spec.platform.
Currently, this action would only work on Linux/ARM system. We
introduce these two helpers to check running system's OS and Arch.

Change-Id: Iff14087699219413779dd6caf1bf9524db1cc19e
Signed-off-by: Wei Chen <Wei.Chen@arm.com>
2017-12-20 14:49:45 +08:00
Daniel Nephin
fe5bb4a0fc Update platform tests to use the defaultOS
fix tests on windows

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-11-15 14:31:50 -05:00
Stephen J Day
9163377123
platforms: provide simpler function for common use
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-09-20 11:56:59 -07:00
Stephen J Day
775f7cea47
platforms: update format for platform specifier
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-09-13 11:41:45 -07:00
Stephen J Day
94f6be5f10
platforms: implement matcher support
Matching support is now implemented in the platforms package. The
`Parse` function now returns a matcher object that can be used to
match OCI platform specifications. We define this as an interface to
allow the creation of helpers oriented around platform selection.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-09-08 19:22:29 -07:00
Stephen J Day
fb0688362c
platforms: define selectors for platforms
For supporting selection of images and runtimes in the containerized
world, there is thin support for selecting objects by platform. This
package defines a syntax to display to users that can express specific
platforms in addition to wild cards for matching platforms.

The plan is to extend this to provide support for parsing flag
arguments and displaying platform types for images. This package will
also provide a configurable matcher to allow match of platforms against
arbitrary targets, invariant to the Go compilation.

The internals are based the OCI Image Spec model.

This changeset is being submitted for feedback on the approach before
this gets larger. Specifically, review the unit tests and raise any
concerns.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-09-08 15:05:21 -07:00