Skip to content

Conversation

@redbeam
Copy link
Contributor

@redbeam redbeam commented Dec 17, 2025

Fixes #5066

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced Windows preflight validation to check both gvisor and 9P registry configurations separately, with improved error messaging to indicate which specific configuration failed validation.

✏️ Tip: You can customize this high-level summary in your review settings.

@redbeam redbeam self-assigned this Dec 17, 2025
@openshift-ci openshift-ci bot requested review from cfergeau and lilyLuLiu December 17, 2025 15:43
@openshift-ci
Copy link

openshift-ci bot commented Dec 17, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign evidolob for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai
Copy link

coderabbitai bot commented Dec 17, 2025

Walkthrough

The change extends Windows preflight validation by adding a check for 9P hvsock registry entries alongside the existing gvisor vsock check. The checkVsock function now queries both gvisor and fs9p registry keys separately with dedicated constants and error messages.

Changes

Cohort / File(s) Summary
Windows Preflight Registry Validation
pkg/crc/preflight/preflight_windows.go
Introduces separate constants for gvisor and fs9p vsock registry entries. Extended checkVsock function to validate both registry entries sequentially with distinct error messages for each validation step.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify that gvisor and fs9p registry key and value constants are correct
  • Confirm the sequential validation logic and error handling flow for both registry checks

Poem

🐰 Windows whispers of vsock and hvsock dreams,
Registry keys gleam in preflight beams,
Gvisor and 9P now dance as one,
Validation complete—no stone left unrun! ✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is minimal, containing only 'Fixes #5066' without details on proposed changes, type of change, or testing approach required by the template. Expand the description to include type of change (Feature), proposed changes list, testing approach, and platform testing checklist as specified in the template.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding a preflight check for 9p hvsock, which matches the code modifications.
Linked Issues check ✅ Passed The code changes align with the linked issue requirements: added separate registry checks for both gvisor and 9P hvsock entries as requested.
Out of Scope Changes check ✅ Passed All changes in preflight_windows.go are scoped to the issue: extending checkVsock to validate both gvisor and 9P hvsock registry entries.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-9p-preflight

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@redbeam
Copy link
Contributor Author

redbeam commented Dec 17, 2025

/hold

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
pkg/crc/preflight/preflight_windows.go (1)

188-206: Implementation correctly validates both gvisor and 9P vsock registry entries.

The dual-check approach properly validates both vsock configurations required for Windows networking. The error messages clearly distinguish between gvisor and 9P failures, which will help with troubleshooting.

Optional: Consider extracting a helper function to reduce duplication:

func checkVsockRegistryKey(key, value, component string) error {
	stdout, _, err := powershell.Execute(fmt.Sprintf(`Get-Item -Path "%s\%s"`, vsockRegistryDirectory, key))
	if err != nil {
		return err
	}
	if !strings.Contains(stdout, value) {
		return fmt.Errorf("VSock registry key for %s not correctly configured", component)
	}
	return nil
}

func checkVsock() error {
	if err := checkVsockRegistryKey(gvisorVsockRegistryKey, gvisorVsockRegistryValue, "gvisor"); err != nil {
		return err
	}
	if err := checkVsockRegistryKey(fs9pVsockRegistryKey, fs9pVsockRegistryValue, "9P"); err != nil {
		return err
	}
	return nil
}

However, the current inline approach is perfectly acceptable given the simplicity of the checks.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 54c1407 and 0b0f2ea.

📒 Files selected for processing (1)
  • pkg/crc/preflight/preflight_windows.go (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: redbeam
Repo: crc-org/crc PR: 4866
File: pkg/fileserver/fs9p/shares.go:0-0
Timestamp: 2025-08-06T09:48:10.441Z
Learning: The vsock implementation in pkg/fileserver/fs9p/shares.go was temporarily removed because 9pfs doesn't fully support it yet. It will be added back when 9pfs provides proper vsock support.
Learnt from: redbeam
Repo: crc-org/crc PR: 4879
File: pkg/crc/machine/start.go:254-254
Timestamp: 2025-12-17T10:14:34.618Z
Learning: In the 9P file sharing implementation for Windows (pkg/crc/machine/start.go), the hardcoded "2" parameter in the 9pfs command represents the vsock CID (Context ID) for the host. In vsock addressing: CID 0 = hypervisor, CID 1 = local communication, CID 2 = host, CID 3+ = guest VMs.
📚 Learning: 2025-08-06T09:48:10.441Z
Learnt from: redbeam
Repo: crc-org/crc PR: 4866
File: pkg/fileserver/fs9p/shares.go:0-0
Timestamp: 2025-08-06T09:48:10.441Z
Learning: The vsock implementation in pkg/fileserver/fs9p/shares.go was temporarily removed because 9pfs doesn't fully support it yet. It will be added back when 9pfs provides proper vsock support.

Applied to files:

  • pkg/crc/preflight/preflight_windows.go
📚 Learning: 2025-12-17T10:14:34.618Z
Learnt from: redbeam
Repo: crc-org/crc PR: 4879
File: pkg/crc/machine/start.go:254-254
Timestamp: 2025-12-17T10:14:34.618Z
Learning: In the 9P file sharing implementation for Windows (pkg/crc/machine/start.go), the hardcoded "2" parameter in the 9pfs command represents the vsock CID (Context ID) for the host. In vsock addressing: CID 0 = hypervisor, CID 1 = local communication, CID 2 = host, CID 3+ = guest VMs.

Applied to files:

  • pkg/crc/preflight/preflight_windows.go
🪛 Gitleaks (8.30.0)
pkg/crc/preflight/preflight_windows.go

[high] 182-182: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


[high] 184-184: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

⏰ 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). (17)
  • GitHub Check: build-installer (windows-2022, 1.24)
  • GitHub Check: build-qe (linux, arm64)
  • GitHub Check: build-qe (windows, amd64)
  • GitHub Check: build-qe (linux, amd64)
  • GitHub Check: build-qe (darwin, arm64)
  • GitHub Check: build-qe (darwin, amd64)
  • GitHub Check: build (ubuntu-latest, 1.24)
  • GitHub Check: build (windows-2022, 1.24)
  • GitHub Check: verify-devcontainer
  • GitHub Check: build (ubuntu-22.04, 1.24)
  • GitHub Check: Run OKD bundle with crc (1.24)
  • GitHub Check: build (macOS-26, 1.24)
  • GitHub Check: build (macOS-15-intel, 1.24)
  • GitHub Check: build (macOS-15, 1.24)
  • GitHub Check: build (ubuntu-latest, 1.24)
  • GitHub Check: build (macOS-15, 1.24)
  • GitHub Check: Konflux kflux-prd-rh02 / crc-binary-on-pull-request
🔇 Additional comments (1)
pkg/crc/preflight/preflight_windows.go (1)

178-186: LGTM! Constants are well-defined.

The refactoring to separate gvisor and 9P vsock registry constants is clear and makes the code more maintainable. The GUID-format registry keys correctly encode the vsock ports in hexadecimal (0x0400 for gvisor, 0x9000 for 9P).

Note: The static analysis warning about "Generic API Key" is a false positive—these are Windows registry key GUIDs, not secrets.

@openshift-ci
Copy link

openshift-ci bot commented Dec 18, 2025

@redbeam: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/security 0b0f2ea link false /test security

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@redbeam
Copy link
Contributor Author

redbeam commented Dec 18, 2025

/unhold

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

Successfully merging this pull request may close these issues.

Add preflight test for 9P hvsock on Windows

2 participants