Skip to content

Refactor platforms.Only with a "platformVector" helper#4891

Merged
dmcgowan merged 1 commit intocontainerd:masterfrom
tianon:generic-arm-vector
Dec 29, 2020
Merged

Refactor platforms.Only with a "platformVector" helper#4891
dmcgowan merged 1 commit intocontainerd:masterfrom
tianon:generic-arm-vector

Conversation

@tianon
Copy link
Copy Markdown
Member

@tianon tianon commented Dec 28, 2020

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 😅).

Additionally, this makes singlePlatformComparer unused, so rather than switch implementations when len(vector) == 1, I opted to remove it because there really shouldn't be much overhead in looping over a single vector list item vs just using/comparing it directly (but I'm happy to revert/adjust if that's preferred).

This splits off another bit from #4528 which should be (hopefully?) less controversial as well. 😄 ❤️

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 <[email protected]>
@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Dec 28, 2020

Build succeeded.

Copy link
Copy Markdown
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Member

@dmcgowan dmcgowan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dmcgowan dmcgowan merged commit 9067796 into containerd:master Dec 29, 2020
@tianon tianon deleted the generic-arm-vector branch December 29, 2020 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants