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

[Spike] Evaluate using krunkit instead of vfkit without codebase changes #4341

Open
vyasgun opened this issue Aug 29, 2024 · 7 comments
Open
Assignees

Comments

@vyasgun
Copy link
Contributor

vyasgun commented Aug 29, 2024

This is a follow-up issue to the spike #4233. This issue will be used to track the following:

  1. The key differences between krunkit and vfkit
  2. Detect if krunkit is being used instead of vfkit so that we skip the 'timesync' configuration(which does not work with krunkit)
  3. Test if krunkit can be integrated alongside vfkit without altering the existing codebase
@cfergeau
Copy link
Contributor

There are also versioning differences (vfkit --version vs krunkit --version).

For ease of testing, the ideal situation would be if we could just do ln -s krunkit ~/.crc/bin/vfkit, and then crc setup/crc start would just work, and use krunkit instead of vfkit.

@cfergeau
Copy link
Contributor

so that we skip the 'timesync' configuration

We could also consider changing how we deal with this, podman uses the makestep configuration option from chrony to do this: https://github.com/containers/podman-machine-os/blob/main/podman-image-daily/50-podman-makestep.conf

@vyasgun
Copy link
Contributor Author

vyasgun commented Sep 5, 2024

Major differences between vfkit and krunkit

krunkit is a tool to launch VMs using macOS's hypervisor framework and the libkrun virtual machine monitor library.
It allows containers to access and use the host's GPU and is mainly designed to run GPU accelerated workloads.

libkrun uses MacOS's Hypervisor.Framwork, which is a low-level interface to interact with the kernel’s virtualization facilities. On the other hand, vfkit uses Virtualization.Framework, which is is roughly a Virtual Machine Monitor implementation. libkrun provides a modern, Rust-based Virtual Machine Monitor, that links directly against Hypervisor.framework to create Virtual Machines on macOS.

krunkit does not support Intel processors which makes it unfeasible to completely switch out vfkit.

Naming and Version Differences

In the current codebase, vfkit version and binary name have been hardcoded in https://github.com/crc-org/crc/blob/main/pkg/crc/machine/vfkit/constants.go#L12-L15 as follows:

const (
	VfkitVersion = "0.5.0"
	vfkitCommand = "vfkit"
)

This causes the vfkit version check in the beginning of crc start to fail.
By creating a symbolic link from the name vfkit to krunkit is not enough as the version of krunkit is different.


gvyas@Gunjans-MacBook-Pro crc % ln -s /opt/homebrew/bin/krunkit ~/.crc/bin/vfkit
gvyas@Gunjans-MacBook-Pro crc % ~/.crc/bin/vfkit --version                     
krunkit 0.1.2

Another issue is the PID check in the file https://github.com/crc-org/crc/blob/main/pkg/drivers/vfkit/driver_darwin.go#L428-L432

if !strings.HasPrefix(name, "vfkit") {
	// return InvalidExecutable error?
	log.Debugf("pid %d is stale, and is being used by %s", pid, name)
	return nil, nil
}

TimeSync Configuration

krunkit is missing the timesync flag present in vfkit. On inspection, the crc VM already has chronyd.service running and no further changes might be required for the same.

gvyas@Gunjans-MacBook-Pro specs % crcssh
Warning: Permanently added '[127.0.0.1]:2222' (ED25519) to the list of known hosts.
Script '01_update_platforms_check.sh' FAILURE (exit code '1'). Continuing...
Boot Status is GREEN - Health Check SUCCESS
Last login: Thu Sep  5 05:16:52 2024 from 192.168.127.1

[core@api ~]$ systemctl status chronyd.service
● chronyd.service - NTP client/server
     Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; preset: enabled)
     Active: active (running) since Thu 2024-09-05 05:13:20 EDT; 15min ago
       Docs: man:chronyd(8)
             man:chrony.conf(5)
    Process: 716 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
   Main PID: 778 (chronyd)
      Tasks: 1 (limit: 97216)
     Memory: 4.2M
        CPU: 26ms
     CGroup: /system.slice/chronyd.service
             └─778 /usr/sbin/chronyd -F 2

[core@api ~]$ chronyc tracking
Reference ID    : 0FCFF8C2 (15.207.248.194)
Stratum         : 5
Ref time (UTC)  : Thu Sep 05 09:26:25 2024
System time     : 0.000169504 seconds slow of NTP time
Last offset     : -0.000171302 seconds
RMS offset      : 1.699727654 seconds
Frequency       : 0.561 ppm slow
Residual freq   : +1.666 ppm
Skew            : 7.643 ppm
Root delay      : 0.030079169 seconds
Root dispersion : 0.001693360 seconds
Update interval : 65.1 seconds
Leap status     : Normal

@cfergeau
Copy link
Contributor

cfergeau commented Sep 5, 2024

On inspection, the crc VM already has chronyd.service running and no further changes might be required for the same.

makestep 1 -1 is required in chronyd configuration if we want VM time to be correctly re-synchronized when the laptop wakes up from suspend.

@praveenkumar
Copy link
Member

On inspection, the crc VM already has chronyd.service running and no further changes might be required for the same.

makestep 1 -1 is required in chronyd configuration if we want VM time to be correctly re-synchronized when the laptop wakes up from suspend.

@cfergeau this we can do as part of snc bundle right?

@cfergeau
Copy link
Contributor

On inspection, the crc VM already has chronyd.service running and no further changes might be required for the same.

makestep 1 -1 is required in chronyd configuration if we want VM time to be correctly re-synchronized when the laptop wakes up from suspend.

@cfergeau this we can do as part of snc bundle right?

If this works as expected, yes we could add it to snc and stop using vfkit -timesync

@gbraad
Copy link
Contributor

gbraad commented Nov 25, 2024

Thta would be a different issue. This spike is concluded. Can we close it?

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

No branches or pull requests

4 participants