Skip to content

Commit 128c2e1

Browse files
committed
fix(agentos): route CompareVmConfig through the sidecar request loop
1 parent 140f2f0 commit 128c2e1

3 files changed

Lines changed: 55 additions & 3 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ jobs:
154154
AGENTOS_SIDECAR_BIN: ${{ github.workspace }}/target/debug/agentos-native-sidecar
155155
run: |
156156
cargo test -p agentos-client \
157+
--features service-internals \
157158
--lib \
158159
--test scaffold \
159160
--test e2e_smoke \
@@ -163,6 +164,7 @@ jobs:
163164
--test sidecar_pool_e2e \
164165
--test cron_e2e \
165166
--test cron_grammar_e2e \
167+
--test vm_config_compare_e2e \
166168
-- --test-threads=1
167169
- name: Stage stripped sidecar artifacts
168170
run: |
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//! Config comparison against a running VM through a real `agentos-native-sidecar`.
2+
#![cfg(feature = "service-internals")]
3+
4+
mod common;
5+
6+
use std::collections::BTreeMap;
7+
8+
use agentos_client::config::AgentOsConfig;
9+
use agentos_client::service_internals::vm_config_equivalent;
10+
use agentos_client::AgentOs;
11+
12+
fn config(environment: Option<BTreeMap<String, String>>) -> AgentOsConfig {
13+
AgentOsConfig {
14+
environment,
15+
..Default::default()
16+
}
17+
}
18+
19+
#[tokio::test]
20+
async fn running_vm_compares_configs_through_the_sidecar() {
21+
if !common::require_sidecar("running_vm_compares_configs_through_the_sidecar") {
22+
return;
23+
}
24+
let vm = AgentOs::create(config(None))
25+
.await
26+
.expect("create VM against real sidecar");
27+
28+
let same = vm_config_equivalent(&vm, &config(None), &config(None), Vec::new(), Vec::new())
29+
.await
30+
.expect("compare an unchanged config");
31+
let changed_environment = Some(BTreeMap::from([(String::from("DEBUG"), String::from("1"))]));
32+
let changed = vm_config_equivalent(
33+
&vm,
34+
&config(None),
35+
&config(changed_environment),
36+
Vec::new(),
37+
Vec::new(),
38+
)
39+
.await
40+
.expect("compare a config with a changed environment");
41+
vm.shutdown().await.expect("shutdown VM");
42+
43+
assert!(same);
44+
assert!(!changed);
45+
}

‎crates/native-sidecar/src/service.rs‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2607,6 +2607,7 @@ where
26072607
| RequestRoute::GetZombieTimerCount(_)
26082608
| RequestRoute::ProvidedCommands(_)
26092609
| RequestRoute::ListMounts(_)
2610+
| RequestRoute::CompareVmConfig(_)
26102611
| RequestRoute::GuestFilesystemCall(_)
26112612
| RequestRoute::GuestKernelCall(_)
26122613
| RequestRoute::BootstrapRootFilesystem(_)
@@ -2801,6 +2802,12 @@ where
28012802
let future = self.list_mounts(&request, payload);
28022803
Ok(Some(PreparedRequest::from_vm_command(request, future)))
28032804
}
2805+
RequestRoute::CompareVmConfig(payload) => {
2806+
let result = self.compare_vm_config(&request, payload);
2807+
Ok(Some(PreparedRequest::from_future(request, async move {
2808+
result
2809+
})))
2810+
}
28042811
RequestRoute::BootstrapRootFilesystem(payload) => {
28052812
let future = self.bootstrap_root_filesystem(&request, payload.entries);
28062813
Ok(Some(PreparedRequest::from_vm_command(request, future)))
@@ -3032,9 +3039,7 @@ where
30323039
})
30333040
})))
30343041
}
3035-
RequestRoute::CreateVm(_)
3036-
| RequestRoute::CompareVmConfig(_)
3037-
| RequestRoute::DisposeVm(_) => {
3042+
RequestRoute::CreateVm(_) | RequestRoute::DisposeVm(_) => {
30383043
unreachable!("VM creation and disposal use dedicated prepared routes")
30393044
}
30403045
}

0 commit comments

Comments
 (0)