podman-desktop icon indicating copy to clipboard operation
podman-desktop copied to clipboard

chore: set libkrun as default provider on mac

Open gastoner opened this issue 6 months ago • 12 comments

What does this PR do?

Sets libkrun as default provider on mac

Screenshot / video of UI

https://github.com/user-attachments/assets/590624ba-65a1-4ea9-9769-70fa7718363b

What issues does this PR fix or reference?

Closes #11453

How to test this PR?

Try to create machine

  • [ ] Tests are covering the bug fix or the new feature

gastoner avatar Jun 10 '25 06:06 gastoner

Codecov Report

Attention: Patch coverage is 88.69565% with 13 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ckages/extension/src/utils/podman-configuration.ts 79.03% 13 Missing :warning:

:loudspeaker: Thoughts on this report? Let us know!

codecov[bot] avatar Jun 10 '25 06:06 codecov[bot]

@benoitf when discussing this issue with @jiridostal, he raised a point that there might be an issue if the user does not have libkrun & vrunkit. Both of which need to be installed before creating VrunKit-based machine

I suggest either:

  1. Switch the description to markdown and provide links to vrunkit and libkrun dependencies
  2. Add a note, or error with some detection check that the user does not have vrunkit and libkrun installed (would be visible by default after opening the form if the user does not have them installed, both of those tools)

gastoner avatar Jun 10 '25 08:06 gastoner

@benoitf when discussing this issue with @jiridostal, he raised a point that there might be an issue if the user does not have libkrun & vrunkit. Both of which need to be installed before creating VrunKit-based machine

I suggest either:

1. Switch the description to markdown and provide links to vrunkit and libkrun dependencies

2. Add a note, or error with some detection check that the user does not have vrunkit and libkrun installed (would be visible by default after opening the form if the user does not have them installed, both of those tools)

We can perhaps add a pre check that issue a warning if vfkit and libkrun are not available and ask them to install Podman from installer and then remove the libkrun option

jeffmaury avatar Jun 10 '25 13:06 jeffmaury

This change will also impact a creating a machine from Dashboard, although there is no option to choose a provider. So if the user will not have libkrun/krunkit installed, it will fail for him.

odockal avatar Jun 11 '25 04:06 odockal

@SoniaSandler should be updated 🤞

gastoner avatar Jun 17 '25 08:06 gastoner

How about creating a machine from Dashboard on intel-based mac machines? This way it is gonna fail with error for the user since libkrun does not work there, no?

odockal avatar Jun 24 '25 13:06 odockal

📝 Walkthrough

"""

Walkthrough

The changes introduce the use of "default GPU enabled (LibKrun)" as the default machine provider for Podman on macOS, replacing "default (Apple HyperVisor)". This is reflected in configuration defaults, labels, and enum options. A new check is added to verify the installation of the krunkit package via Homebrew. The logic for machine creation is updated to select the provider based on CPU architecture and to update the containers configuration file accordingly. Additional tests are added to verify provider update logic and the new krunkit check.

Assessment against linked issues

Objective Addressed Explanation
Make libkrun the default when creating a Podman machine (#11453)
Set the containers.conf default provider as well if it's the first time or if no machine exists (#11453)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Addition of MacKrunkitPodmanMachineCreationCheck class and related tests (src/checks/macos-checks.ts, src/checks/macos-check.spec.ts) The linked issue does not mention adding a check for krunkit installation; this is an additional system validation feature not specified in #11453.
Modifications to connection auditing logic to include krunkit installation check (src/extension.ts) This change relates to runtime validation and is not part of the stated objectives in #11453.
Changes to machine provider selection logic based on CPU architecture in createMachine (src/extension.ts) While related to provider selection, the architecture-specific override is not explicitly mentioned in #11453 objectives.
Updates to telemetry recording for machine provider selection (src/extension.ts) Telemetry changes are not specified in the linked issue objectives.

Suggested reviewers

  • jeffmaury """

[!WARNING] There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

extensions/podman/packages/extension/src/checks/macos-check.spec.ts

Oops! Something went wrong! :(

ESLint: 9.31.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'svelte-eslint-parser' imported from /eslint.config.mjs at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9) at packageResolve (node:internal/modules/esm/resolve:767:81) at moduleResolve (node:internal/modules/esm/resolve:853:18) at defaultResolve (node:internal/modules/esm/resolve:983:11) at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12) at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25) at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38) at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38) at #link (node:internal/modules/esm/module_job:202:49)

extensions/podman/packages/extension/src/extension.ts

Oops! Something went wrong! :(

ESLint: 9.31.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'svelte-eslint-parser' imported from /eslint.config.mjs at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9) at packageResolve (node:internal/modules/esm/resolve:767:81) at moduleResolve (node:internal/modules/esm/resolve:853:18) at defaultResolve (node:internal/modules/esm/resolve:983:11) at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12) at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25) at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38) at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38) at #link (node:internal/modules/esm/module_job:202:49)

extensions/podman/packages/extension/src/utils/util.ts

Oops! Something went wrong! :(

ESLint: 9.31.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'svelte-eslint-parser' imported from /eslint.config.mjs at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9) at packageResolve (node:internal/modules/esm/resolve:767:81) at moduleResolve (node:internal/modules/esm/resolve:853:18) at defaultResolve (node:internal/modules/esm/resolve:983:11) at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12) at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25) at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38) at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38) at #link (node:internal/modules/esm/module_job:202:49)

  • 4 others

📜 Recent review details

Configuration used: CodeRabbit UI Review profile: CHILL Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8baf8c1bdb611c1abbb90d93883243309ce96cb6 and 116092b31dcaf5ed608b0eb6cdb8cb635f7b3ffa.

📒 Files selected for processing (8)
  • extensions/podman/packages/extension/package.json (1 hunks)
  • extensions/podman/packages/extension/src/checks/macos-check.spec.ts (3 hunks)
  • extensions/podman/packages/extension/src/checks/macos-checks.ts (1 hunks)
  • extensions/podman/packages/extension/src/extension.spec.ts (3 hunks)
  • extensions/podman/packages/extension/src/extension.ts (4 hunks)
  • extensions/podman/packages/extension/src/utils/podman-configuration.spec.ts (2 hunks)
  • extensions/podman/packages/extension/src/utils/podman-configuration.ts (2 hunks)
  • extensions/podman/packages/extension/src/utils/util.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
  • extensions/podman/packages/extension/package.json
  • extensions/podman/packages/extension/src/utils/util.ts
  • extensions/podman/packages/extension/src/utils/podman-configuration.spec.ts
  • extensions/podman/packages/extension/src/extension.ts
  • extensions/podman/packages/extension/src/checks/macos-checks.ts
  • extensions/podman/packages/extension/src/utils/podman-configuration.ts
  • extensions/podman/packages/extension/src/checks/macos-check.spec.ts
  • extensions/podman/packages/extension/src/extension.spec.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: unit tests / macos-15
  • GitHub Check: build website
  • GitHub Check: linter, formatters
  • GitHub Check: typecheck
  • GitHub Check: macOS
  • GitHub Check: unit tests / windows-2022
  • GitHub Check: smoke e2e tests (production)
  • GitHub Check: unit tests / ubuntu-24.04
  • GitHub Check: smoke e2e tests (development)
  • GitHub Check: Windows
  • GitHub Check: Linux
✨ Finishing Touches
  • [ ] 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Jun 24 '25 13:06 coderabbitai[bot]

how does it work on mac/Intel ? as libkrun is not supported there

benoitf avatar Jun 24 '25 13:06 benoitf

I have some concerns about this PR, specifically it's not obvious to me that the changes in the default value from applehv to libkrun are being propagated to podman CLI in order to maintain alignment between PD and Podman. I looked at the code in the PR and it's not clear to me where this propagation takes place and I would like to be sure that it does take place becayse otherwise changing the default value will cause podman machines to become invisible in Podman CLI since by default applehv will still be the default value in CLI.

cbr7 avatar Jun 24 '25 13:06 cbr7

@dgolovin Tests added

gastoner avatar Jun 25 '25 09:06 gastoner

@benoitf @cbr7 I've added if statement that if the platform is amd64 we will use applev no matter what. I'm just not sure what we should do with the CLI visibility, export some variable to show those machines instead? This does not seem right to me (what if is the user creating libkrun machine after he has created 4 applev machines)

gastoner avatar Jun 25 '25 09:06 gastoner

@gastoner I agree that that is a concern also, however that is also the current behavior, only in reverse, with applehv as the default. In https://github.com/podman-desktop/podman-desktop/issues/11453 @benoitf describes that containers.conf file should be modified or created if it doesn't already exist with provider setting to libkrun, this would at least keep alignment with what PD is doing, even though yes in that case any existing applehv machines would become somewhat invisible in turn.

cbr7 avatar Jun 25 '25 10:06 cbr7

@benoitf @cbr7 should be updated, just I cant verify on intel mac :(

gastoner avatar Jun 27 '25 06:06 gastoner

@cbr7 @odockal will you be able to verify this fix on intel mac so we can merge this?

rujutashinde avatar Jul 02 '25 01:07 rujutashinde

@cbr7 @odockal will you be able to verify this fix on intel mac so we can merge this?

I am looking at intel mac.

odockal avatar Jul 02 '25 07:07 odockal

@gastoner @odockal @rujutashinde I've checked out this PR and the changes are mostly ok, however I think there is one usecase that has been overlooked. As far as I can see if the user creates a podman machine using the Initialize and start button from the dashboard, the podman machine created will always be applehv, regardless of what setting is written to the containers.conf file and additionally no changes are propagated to the file either.

cbr7 avatar Jul 02 '25 07:07 cbr7

Now we should create libkrun machine on arm64 and applehv on x86 machines

gastoner avatar Jul 02 '25 17:07 gastoner

@cbr7 @odockal Updated

gastoner avatar Jul 03 '25 05:07 gastoner

@gastoner LGTM

cbr7 avatar Jul 03 '25 09:07 cbr7

@odockal @dgolovin can you PTAL?

gastoner avatar Jul 03 '25 11:07 gastoner

@odockal I've applied some suggestions, but I wasn't able to connect those 2 tests from because there wold be required some ifs in order to check that from dashboard we can create only applehv on x64 and libkrun on arm64 since there is no option to chose

gastoner avatar Jul 04 '25 14:07 gastoner

@dgolovin Can you PTAL? Need aproval from you in order to merge this

gastoner avatar Jul 04 '25 14:07 gastoner

wondering if it should not be merged post 1.20.0 or delaying 1.20.0

I don't think we have enough usage data to merge it the same day of a release

benoitf avatar Jul 04 '25 14:07 benoitf

Wait until 1.20 is relased

DO NOT merge now

gastoner avatar Jul 07 '25 08:07 gastoner

Merging since 1.20 is out

gastoner avatar Jul 16 '25 06:07 gastoner