Skip to content

Commit

Permalink
Fix Docker Volume Issues on M2/M3 Macs by Enabling VZ Emulation and v…
Browse files Browse the repository at this point in the history
…irtiofs (#90)

This PR addresses the Docker volume issues encountered by users on M2
and M3 Macs, as reported in this thread:
rancher-sandbox/rancher-desktop#1209

@cobbr2 just had a rough time with this one on his m2 mac. He was seeing
similar permission errors when trying to mount host volumes, preventing
services like PostgreSQL from starting correctly.

We were able to resolve the underlying issue by switching from the
default QEMU emulation to VZ (Virtualization.framework) and enabling
virtiofs for file sharing between the host and the guest VM.

The PR reintroduces the necessary configuration changes that were
previously removed, as these are still required for M2 and M3 Macs
running Rancher Desktop. This also adds the fix to prevent needing to
manually select virtiofs to get it working too.
  • Loading branch information
pb-dod authored Apr 11, 2024
1 parent edb253a commit b3df8cd
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.50
0.1.51
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.50"
VERSION="0.1.51"
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: 27 additions & 0 deletions lib/core/rancher/step.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ 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_m2_or_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
# TODO: figure out how to check virtual-machine.mount.type (there's no rdctl get)
fi
fi

return 0
}

Expand Down Expand Up @@ -144,6 +158,19 @@ 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_m2_or_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 # 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"
rdctl set --experimental.virtual-machine.mount.type virtiofs
fi
fi

echo "Rancher Desktop has been installed successfully"
else
ih::log::warn "Could not install Rancher Desktop"
Expand Down
5 changes: 5 additions & 0 deletions lib/utils/arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ ih::arch::mbrew() {
ih::arch::get_macos_version() {
sw_vers -productVersion | awk -F '.' '{ printf("%d.%d\n", $1, $2) }'
}

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

0 comments on commit b3df8cd

Please sign in to comment.