Skip to content

Teach rkforge to find bundled aardvark-dns#589

Open
erasernoob wants to merge 1 commit intork8s-dev:mainfrom
erasernoob:test-rkfroge-attach
Open

Teach rkforge to find bundled aardvark-dns#589
erasernoob wants to merge 1 commit intork8s-dev:mainfrom
erasernoob:test-rkfroge-attach

Conversation

@erasernoob
Copy link
Copy Markdown
Collaborator

Refactor the aardvark-dns discover logic in rkforge.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c41b1e5a8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

}

for candidate in aardvark_candidates() {
if candidate.is_file() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Require executable aardvark-dns candidates

default_aardvark_bin now accepts the first candidate that is only is_file(), including entries discovered from PATH. In environments where an earlier PATH directory contains a non-executable regular file named aardvark-dns, rkforge will select that path and netavark setup/teardown will fail, even if a valid executable exists later in PATH or in system locations. Filtering candidates by executability (or resolving via command lookup semantics) avoids this regression.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors rkforge’s aardvark-dns discovery to support “bundled”/install-prefix layouts and centralizes the logic so container + compose networking share the same path resolution.

Changes:

  • Introduces commands::network_paths to resolve netavark config dir and locate aardvark-dns via env vars, exe-relative locations, PATH, and system fallbacks.
  • Wires the new shared helpers into both container networking and compose networking code paths.
  • Adds a build script and README guidance to improve local build + runtime discovery expectations.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
project/rkforge/src/commands/network_paths.rs New centralized discovery logic for netavark config dir and aardvark-dns binary, plus a basic unit test.
project/rkforge/src/commands/mod.rs Exposes the new network_paths module within the crate.
project/rkforge/src/commands/container/network.rs Switches container networking to use shared aardvark/netavark path helpers.
project/rkforge/src/commands/compose/network.rs Switches compose networking to use shared aardvark/netavark path helpers.
project/rkforge/build.rs Attempts to embed a build-time default aardvark-dns path for discovery.
project/rkforge/README.md Documents how to build aardvark-dns with rkforge and the intended runtime lookup order.

Comment on lines +46 to +52
if let Some(path) = std::env::var_os("PATH") {
candidates.extend(
path_entries(&path)
.into_iter()
.map(|dir| dir.join(AARDVARK_BINARY_NAME)),
);
}
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

Searching PATH for aardvark-dns can result in executing an unexpected binary when rkforge is run with elevated privileges (e.g., via sudo), especially if PATH contains relative entries like .. Consider filtering PATH entries to absolute/trusted directories (and/or moving PATH behind the hard-coded system locations) so discovery can’t be influenced by an untrusted working directory or user-controlled PATH ordering.

Copilot uses AI. Check for mistakes.
Comment on lines +93 to +106
#[test]
fn path_entries_are_searchable_for_aardvark() {
let tmp = tempdir().unwrap();
let bin = tmp.path().join(AARDVARK_BINARY_NAME);
fs::write(&bin, b"#!/bin/sh\n").unwrap();

let path = env::join_paths([tmp.path()]).unwrap();
let found = path_entries(&path)
.into_iter()
.map(|dir| dir.join(AARDVARK_BINARY_NAME))
.find(|candidate| candidate.is_file());

assert_eq!(found, Some(bin));
}
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

The new discovery behavior (exe-relative ../libexec/... paths and overall precedence) is largely untested: the current unit test only exercises PATH splitting, not that append_exe_relative_candidates produces the intended install-prefix candidates or that default_aardvark_bin prefers env vars vs. exe-relative vs. PATH/system paths. Adding targeted tests around candidate ordering/selection would help prevent regressions in this refactor.

Copilot uses AI. Check for mistakes.
Comment thread project/rkforge/README.md
Comment on lines +94 to +95
4. `PATH`
5. System paths such as `/usr/libexec/podman/aardvark-dns` and `/usr/bin/aardvark-dns`
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

The documented search order for aardvark-dns doesn’t fully match the code: network_paths also checks ../libexec/podman/aardvark-dns relative to the rkforge install prefix (and may include a build-time default via RKFORGE_AARDVARK_DNS_BUILD_DEFAULT). Please update this list to reflect the actual candidates (or adjust the code to match the documented order).

Suggested change
4. `PATH`
5. System paths such as `/usr/libexec/podman/aardvark-dns` and `/usr/bin/aardvark-dns`
4. `../libexec/podman/aardvark-dns` relative to the `rkforge` install prefix
5. A build-time default path, if `RKFORGE_AARDVARK_DNS_BUILD_DEFAULT` is set
6. `PATH`
7. System paths such as `/usr/libexec/podman/aardvark-dns` and `/usr/bin/aardvark-dns`

Copilot uses AI. Check for mistakes.
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.

2 participants