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

Fallback to installing AMD64 plugins on Windows #615

Merged

Conversation

marckhouzam
Copy link
Contributor

@marckhouzam marckhouzam commented Dec 15, 2023

What this PR does / why we need it

Although the CLI will be available for Windows ARM64, the vast majority of plugins are not, and therefore an ARM64 CLI will not be able to install most plugins.

Thanks to Windows 11's emulator available on Windows ARM64 machines, it is possible to run AMD64 binaries.

This PR teaches a Windows ARM64 CLI that if a plugin is not available for Windows ARM64, it should instead install the Windows AMD64 version. With this approach, it now becomes possible to use a Windows ARM64 CLI to its full potential.

Note that this approach is already used for DarwinARM64 but cannot be used for Linux as there is no standard emulator for AMD64 binaries. For Linux, plugins will need to be published for ARM64 before the platform is supported properly.

Which issue(s) this PR fixes

Part of #357

Describe testing done for PR

I started a Windows 11 ARM64 machine on Azure.

# Confirm the CLI binary is ARM64
PS C:\Users\kmarc> .\tanzu.exe version
version: v1.2.0-dev
buildDate: 2023-12-09
sha: 4dd0090dc
arch: arm64

# Try to install many plugins, none of which are available for Windows ARM64.
# The AMD64 version will be installed instead.
PS C:\Users\kmarc> .\tanzu.exe plugin install --group vmware-tkg/default
[i] The tanzu cli essential plugins have not been installed and are being installed now. The install may take a few seconds.
[i] Installing plugins from plugin group 'vmware-tanzucli/essentials:v1.0.0'
[i] Installing plugin 'telemetry:v1.1.0' with target 'global'

[i] The following plugins will be installed from plugin group 'vmware-tkg/default:v2.4.1'
  NAME                TARGET      VERSION
  isolated-cluster    global      v0.31.1
  management-cluster  kubernetes  v0.31.1
  package             kubernetes  v0.31.1
  pinniped-auth       global      v0.31.1
  secret              kubernetes  v0.31.1
  telemetry           kubernetes  v0.31.1
[i] Installing plugin 'isolated-cluster:v0.31.1' with target 'global'
[i] Installing plugin 'management-cluster:v0.31.1' with target 'kubernetes'
[i] Installing plugin 'package:v0.31.1' with target 'kubernetes'
[i] Installing plugin 'pinniped-auth:v0.31.1' with target 'global'
[i] Installing plugin 'secret:v0.31.1' with target 'kubernetes'
[i] Installing plugin 'telemetry:v0.31.1' with target 'kubernetes'
[ok] successfully installed all plugins from group 'vmware-tkg/default:v2.4.1'

# All plugins of the group are installed.
# Note that the builder:v1.2.0-dev plugin was installed in another test and is actually built for ARM64
PS C:\Users\kmarc> .\tanzu.exe plugin list
Standalone Plugins
  NAME                DESCRIPTION                                                        TARGET      VERSION     STATUS
  builder             Build Tanzu components                                             global      v1.2.0-dev  installed
  isolated-cluster    Prepopulating images/bundle for internet-restricted environments   global      v0.31.1     installed
  pinniped-auth       Pinniped authentication operations (usually not directly invoked)  global      v0.31.1     installed
  telemetry           configure cluster-wide settings for vmware tanzu telemetry         global      v1.1.0      installed
  test                Test the CLI                                                       global      v1.2.0-dev  installed
  management-cluster  Kubernetes management cluster operations                           kubernetes  v0.31.1     installed
  package             Tanzu package management                                           kubernetes  v0.31.1     installed
  secret              Tanzu secret management                                            kubernetes  v0.31.1     installed
  telemetry           configure cluster-wide settings for vmware tanzu telemetry         kubernetes  v0.31.1     installed

# The builder plugin was an ARM64 build I installed in a previous test
PS C:\Users\kmarc> .\tanzu.exe builder info
{"name":"builder","description":"Build Tanzu components","target":"global","version":"v1.2.0-dev","buildSHA":"efe2c930f-dirty","digest":"","group":"Admin","docURL":"","completionType":0,"pluginRuntimeVersion":"v1.1.0","binaryArch":"arm64"}

# The below plugins execute properly although they are AMD64 (since there was no ARM64 build for those)
PS C:\Users\kmarc> .\tanzu.exe telemetry info
{"name":"telemetry","description":"configure cluster-wide settings for vmware tanzu telemetry","target":"global","version":"v1.1.0","buildSHA":"4a19b20","digest":"","group":"Run","docURL":"","completionType":0,"pluginRuntimeVersion":"v1.0.0-dev.0.20230712185745-27ac1d59d87f"}

PS C:\Users\kmarc> .\tanzu.exe secret info
{"name":"secret","description":"Tanzu secret management","target":"kubernetes","version":"v0.31.1","buildSHA":"a517edd3c-dirty","digest":"","group":"Run","docURL":"","completionType":0,"pluginRuntimeVersion":"v0.90.0-beta.0"}
PS C:\Users\kmarc> .\tanzu.exe package version
v0.31.1

Make sure AMD64 plugins still get installed on ARM64 Darwin machine:

# Make sure the CLI is for ARM64
$ tz version
version: v1.2.0-dev
buildDate: 2023-12-09
sha: 4dd0090dc
arch: arm64

# The builder exists for ARM64
$ tz plugin install builder
[i] Plugin 'builder:v1.1.0' with target 'global' is already installed. Reinitializing...
[ok] successfully installed 'builder' plugin
$ tz builder info
{"name":"builder","description":"Build Tanzu components","target":"global","version":"v1.1.0","buildSHA":"d0679f5a","digest":"","group":"Admin","docURL":"","completionType":0,"pluginRuntimeVersion":"v1.1.0","binaryArch":"arm64"}

# The secret plugin also exists for Darwin ARM64
$ tz plugin install secret
[i] Installing plugin 'secret:v0.32.0' with target 'kubernetes' (from cache)
[ok] successfully installed 'secret' plugin
$ file ~/Library/Application\ Support/tanzu-cli/secret/v0.32.0_309e1f9b32a012e9866d81f03378c246c8995444c9aa1a0ececaabf16f3e9c0e_kubernetes
/Users/kmarc/Library/Application Support/tanzu-cli/secret/v0.32.0_309e1f9b32a012e9866d81f03378c246c8995444c9aa1a0ececaabf16f3e9c0e_kubernetes: Mach-O 64-bit executable arm64

# The management-cluster plugin does not exist for Darwin ARM64
$ tz plugin install management-cluster --target k8s
[i] Plugin 'management-cluster:v0.31.1' with target 'kubernetes' is already installed. Reinitializing...
[ok] successfully installed 'management-cluster' plugin

$ file ~/Library/Application\ Support/tanzu-cli/management-cluster/v0.31.1_6a7dafd18ae8a9090151dcd0c8e1279ae393933af464ac9c82f7f174432a4d37_kubernetes
/Users/kmarc/Library/Application Support/tanzu-cli/management-cluster/v0.31.1_6a7dafd18ae8a9090151dcd0c8e1279ae393933af464ac9c82f7f174432a4d37_kubernetes: Mach-O 64-bit executable x86_64

Release note

Allow to install all plugins on Windows 11 running on ARM64 by installing the AMD64 version if the ARM64 version of the plugin is not available.

Additional information

Special notes for your reviewer

This approach will work on Windows 11 but not on Windows 10.
We have to decide what we want to do to help users understand this limitation.
Some ideas we discussed:

  1. have the CLI detect it is running on Windows 10 and print some kind of warning.
  2. Document the limitation in the release notes - this should be done no matter what
  3. name the WindowsARM64 CLI binary something like "tanzu-cli-windows-arm64-windows11.zip"

Issues with point 1

  1. It seems difficult to figure out which version of Windows is currently being run.
  2. How are we going to test this on a Windows 10 ARM64? Such a machine is not available in Azure.

@marckhouzam marckhouzam requested a review from a team as a code owner December 15, 2023 03:09
@marckhouzam marckhouzam added this to the v1.2.0 milestone Dec 15, 2023
@marckhouzam marckhouzam added the kind/feature Categorizes issue or PR as related to a new feature label Dec 15, 2023
Copy link
Contributor

@anujc25 anujc25 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks

Although the CLI is available for Windows ARM64, the vast majority of
plugins are not, and therefore an ARM64 CLI will not be able to install
most plugins.

Thanks to Windows 11's emulator available on Windows ARM64 machines,
it is possible to run AMD64 binaries.

This commit teaches a Windows ARM64 CLI that if a plugin is not
available for Windows ARM64, it should instead install the Windows AMD64
version. With this approach, it now becomes possible to use a Windows
ARM64 CLI to its full potential.

Note that this approach cannot be used for Linux as there is no standard
emulator for AMD64 binaries.  For Linux, plugins will need to be
published for ARM64.

Signed-off-by: Marc Khouzam <[email protected]>
@marckhouzam marckhouzam force-pushed the feat/fallbackAMD64Windows branch from 4e2026b to 64226e0 Compare December 21, 2023 13:20
@marckhouzam marckhouzam merged commit 65c0ae0 into vmware-tanzu:main Dec 21, 2023
7 checks passed
@marckhouzam marckhouzam deleted the feat/fallbackAMD64Windows branch December 21, 2023 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-not-required kind/feature Categorizes issue or PR as related to a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants