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

Add architecture support #13239

Merged
merged 11 commits into from
Sep 27, 2023
Merged

Conversation

chrisroberts
Copy link
Member

This PR adds box architecture support. It introduces a new setting to
the vm configuration within the Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.box = "box-name"
  config.vm.box_architecture = "amd64"
end

In most circumstances, this setting will not be needed. By default it
is set to a special value of :auto. The behavior when set to :auto is
as follows: Vagrant will determine the architecture of the host and automatically
request it from the box repository. If architecture information is available in
the repository metadata and a matching architecture was not found, Vagrant will
look for a box with an architecture of "unknown" and flagged as the default
architecture. This behavior allows Vagrant to continue working correctly with
boxes currently published on Vagrant Cloud that do not include architecture
information.

The box_architecture setting can also be set to nil, which will prevent
any architecture filtering being performed, and the box flagged as the default
architecture will be used.

The box collection will now unpack boxes based on architecture. Special handling
is done when box_architecture is set to :auto which prevents Vagrant from
not properly detecting boxes installed without architecture support.

The vagrant cloud commands have been updated to include architecture support
where required. These updates are dependent on hashicorp/vagrant_cloud#82

Fixes: #12610

vancluever
vancluever previously approved these changes Jul 28, 2023
Copy link
Contributor

@vancluever vancluever left a comment

Choose a reason for hiding this comment

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

Great work! 🎉

test/unit/vagrant/util/platform_test.rb Outdated Show resolved Hide resolved
Introduce support for handling box architecture. Adds a new
`box_architecture` setting that defaults to `:auto` which will perform
automatic detection of the host system, but can be overridden with a
custom value. Can also be set to `nil` which will result in it fetching
the box flagged with the default architecture within the metadata.

Box collection has been modified to allow existing boxes already
downloaded and unpacked to still function as expected when architecture
information is not available.
When expanding the box url, prefer the API endpoint which is updated to
include provider architecture information. Test the API endpoint and the
legacy endpoint and use which ever is valid, with the API taking
precedence. This allows Vagrant to continue with non Vagrant Cloud
servers that do not implement the API endpoint.
With the initial layout of `provider/architecture`, after installing a
box with architecture support downgrading Vagrant would result in it
being unable to process the box collection. Swapping the layout to be
`architecture/provider` allows downgrades to still properly process the
box collection.
When the reported architecture is unknown and the provider is listed as
the default architecture, add the box without architecture information
so it is installed without architecture information on the path within
the collection.
@chrisroberts chrisroberts merged commit d5f12fd into hashicorp:main Sep 27, 2023
12 checks passed
@chrisroberts chrisroberts deleted the architecture-aware branch September 27, 2023 20:24
@websafe
Copy link

websafe commented Sep 27, 2023

Great! Thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement Request: CPU architecture aware box handling
3 participants