← Back to Pull requests

Update zbus to v6 #1546

Merged
fpob merged 10 files (1062 lines) on Nov 24, 2026 12:09 UTC
View on GitHub
fpob fpob commented on Nov 10, 2026 11:32 UTC
Author

zbus 6 dropped the blocking API and provides only an async API. It was necessary to refactor the code and add a new async driver trait with a sync wrapper. Apart from that, only minor renames were needed.

Supersedes: https://github.com/containers/netavark/pull/1527

Diff: 1062 lines (+424 / -638) across 10 files Reviewer: Luap99 Review duration: 20197m
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.56) × (1 − Review Confidence (0.72)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.56 · 1062 lines diff across 10 files
0.56
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.47 · 5 substantive comment(s)
0.47
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
72%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.400
Real PR Conversation Timeline
9 items
mheon mheon commented on code on Nov 10, 2026 13:00 UTC
Code Review
src/firewall/mod.rs:1
@@ -18,30 +18,64 @@ const NONE: &str = "none";
 /// and port mappings.
 pub trait FirewallDriver {
     /// Set up firewall rules for the given network,
-    fn setup_network(
-        &self,
-        network_setup: SetupNetwork,
-        dbus_con: &Option<zbus::blocking::Connection>,
-    ) -> NetavarkResult<()>;
+    fn setup_network(&self, network_setup: SetupNetwork) -> NetavarkResult<()>;
     /// Tear down firewall rules for the given network.
     fn teardown_network(&self, tear: TearDownNetwork) -> NetavarkResult<()>;
 
     /// Set up port-forwarding firewall rules for a given container.
-    fn setup_port_forward(
-        &self,
-        setup_pw: PortForwardConfig,
-        dbus_con: &Option<zbus::blocking::Connection>,
-    ) -> NetavarkResult<()>;
+    fn setup_port_forward(&self, setup_pw: PortForwardConfig) -> NetavarkResult<()>;
     /// Tear down port-forwarding firewall rules for a single container.
     fn teardown_port_forward(&self, teardown_pf: TeardownPortForward) -> NetavarkResult<()>;
 
     /// Return the name of the driver.
     fn driver_name(&self) -> &str;
 }
 
+/// Same as FirewallDriver, just with async setup and teardown methods.

Ew. I don't think there's a better way of doing this, but I still hate it.

mheon mheon commented on Nov 10, 2026 13:01 UTC
Contributor

When we started using zbus, it was on v2.x. They're on v6.x now. That's 4 major versions in not that long a time. Might be smart to investigate alternatives that produce less churn.

That's a separate problem, though. Code LGTM

Luap99 Luap99 commented on Nov 10, 2026 16:59 UTC
Contributor

commits should be squashed in one as I will get compile failures during a bisect otherwise

Luap99 Luap99 commented on code on Nov 10, 2026 17:04 UTC
Code Review
src/firewall/mod.rs:1
@@ -126,3 +149,16 @@ pub fn get_supported_firewall_driver(
         Err(e) => Err(e),
     }
 }
+
+pub(crate) fn create_zbus_system_connection() -> NetavarkResult<Connection> {
+    block_on(Connection::system())
+        .map_err(|e| NetavarkError::wrap("failed to create DBus connection", e.into()))
+}
+
+pub(crate) fn block_on<F: std::future::Future>(fut: F) -> F::Output {

this is creating a new runtime for each call, this seems wasteful assuming there is a non significant setup cost each time? I think it would make the most sense to kee the runtime. Cant we store the runtime with the the connection together as one thing to resuse the same runtime for all calls?

Luap99 Luap99 commented on code on Nov 10, 2026 17:04 UTC
Code Review
src/firewall/mod.rs:1
@@ -126,3 +149,16 @@ pub fn get_supported_firewall_driver(
         Err(e) => Err(e),
     }
 }
+
+pub(crate) fn create_zbus_system_connection() -> NetavarkResult<Connection> {
+    block_on(Connection::system())
+        .map_err(|e| NetavarkError::wrap("failed to create DBus connection", e.into()))
+}
+
+pub(crate) fn block_on<F: std::future::Future>(fut: F) -> F::Output {
+    tokio::runtime::Builder::new_current_thread()
+        .enable_all()
+        .build()
+        .expect("runtime")

That produces an ugly panic if the runtime setup ever fails, errors should be returned as result.
Also a reason to only setup the runtime once.

Luap99 Luap99 requested changes on Nov 10, 2026 17:05 UTC
Changes Requested Reviewer

Requested changes.

fpob fpob commented on Nov 11, 2026 13:56 UTC
Author

ready for re-review

Luap99 Luap99 approved these changes on Nov 24, 2026 12:09 UTC
Approved Reviewer

LGTM

Reviewers
Assignees
fpob fpob
Labels
risk: low confidence: 72.3% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 56.2% (MEDIUM) · Higher = larger blast radius
56.2%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 72.3% · Lower = rushed or shallow review
72.3%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 15.6% · Safe to merge
15.6%