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

rancher - use vz instead of qemu on M3 macOS >=13.3 #78

Merged
merged 5 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.40
0.1.41
2 changes: 1 addition & 1 deletion formula/ih-core.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class IhCore < Formula
VERSION="0.1.40"
VERSION="0.1.41"
desc "Brew formula for installing core tools used at Included Health engineering."
homepage "https://github.com/ConsultingMD/homebrew-ih-public"
license "CC BY-NC-ND 4.0"
Expand Down
27 changes: 26 additions & 1 deletion lib/core/rancher/step.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ function ih::setup::core.rancher::test() {
return 1
fi

# Use vz (requires macOS >=13.3) instead of qemu on M3 macs to resolve issues.
# More details: https://github.com/lima-vm/lima/issues/1996
local macos_version=$(ih::arch::get_macos_version)
if ih::arch::is_m3_mac; then
if (( $(echo "$macos_version < 13.3" | bc -l) )); then
ih::log::error "macOS version 13.3 or higher is required for M3 Macs."
return 1
elif ! grep -q "<string>vz</string>" "$PLIST_DST"; then
ih::log::debug "The PLIST file needs to be updated to use 'vz' for M3 Macs."
return 1
fi
fi

return 0
}

Expand All @@ -63,7 +76,7 @@ function ih::setup::core.rancher::install() {

echo "A configuration file for Rancher Desktop will be copied to your system"
echo "You may be required to enter your password"
sudo cp "${THIS_DIR}/io.rancherdesktop.profile.defaults.plist" "$HOME/Library/Preferences/io.rancherdesktop.profile.defaults.plist"
sudo cp "${THIS_DIR}/io.rancherdesktop.profile.defaults.plist" "$PLIST_DST"

# Check if Rancher was installed manually
brew list rancher >/dev/null 2>&1
Expand Down Expand Up @@ -120,6 +133,18 @@ function ih::setup::core.rancher::install() {
fi
fi

# Use vz (requires macOS >=13.3) instead of qemu on M3 macs to resolve issues.
# More details: https://github.com/lima-vm/lima/issues/1996
if ih::arch::is_m3_mac; then
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Planning to only make this switch for m3 mac users for now, since vz is still "experimental" according to the docs. I think a few of the platform team people are going to try using it on non-M3 macs and see if it breaks anything.

if (( $(echo "$macos_version < 13.3" | bc -l) )); then
ih::log::error "macOS version 13.3 or higher is required for M3 Macs."
return 1 # Abort the installation for M3 Macs
elif ! grep -q "<string>vz</string>" "$PLIST_DST"; then
ih::log::debug "Updating PLIST to use 'vz' for Virtualization for M3 Macs."
sudo sed -i '' 's/<string>qemu<\/string>/<string>vz<\/string>/g' "$PLIST_DST"
fi
fi

echo "Rancher Desktop has been installed successfully"
else
ih::log::warn "Could not install Rancher Desktop"
Expand Down
9 changes: 9 additions & 0 deletions lib/utils/arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@ ih::arch::ibrew() {
ih::arch::mbrew() {
/opt/homebrew/bin/brew "${@}"
}

ih::arch::get_macos_version() {
sw_vers -productVersion | awk -F '.' '{ printf("%d.%d\n", $1, $2) }'
}

ih::arch::is_m3_mac() {
local hw_model=$(sysctl -n machdep.cpu.brand_string)
[[ "$hw_model" == *"M3"* ]]
}