Skip to content

Commit 7f09640

Browse files
authored
Merge pull request #453 from Dstack-TEE/notify-error
dstack-util: notify host on boot error
2 parents 76ace38 + cdea272 commit 7f09640

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

dstack-util/src/system_setup.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,15 @@ fn emit_key_provider_info(provider_info: &KeyProviderInfo) -> Result<()> {
511511

512512
pub async fn cmd_sys_setup(args: SetupArgs) -> Result<()> {
513513
let stage0 = Stage0::load(&args)?;
514+
let vmm = stage0.host_api();
515+
let result = do_sys_setup(stage0).await;
516+
if let Err(err) = &result {
517+
vmm.notify_q("boot.error", &format!("{err:#}")).await;
518+
}
519+
result
520+
}
521+
522+
async fn do_sys_setup(stage0: Stage0<'_>) -> Result<()> {
514523
if stage0.shared.app_compose.secure_time {
515524
info!("Waiting for the system time to be synchronized");
516525
cmd! {
@@ -585,6 +594,12 @@ struct Stage1<'a> {
585594
}
586595

587596
impl<'a> Stage0<'a> {
597+
fn host_api(&self) -> HostApi {
598+
HostApi::new(
599+
self.shared.sys_config.host_api_url.clone(),
600+
self.shared.sys_config.pccs_url.clone(),
601+
)
602+
}
588603
fn load(args: &'a SetupArgs) -> Result<Self> {
589604
let host_shared_copy_dir = args.work_dir.join(HOST_SHARED_DIR_NAME);
590605
let host_shared = HostShared::copy("/tmp/.host-shared".as_ref(), &host_shared_copy_dir)?;
@@ -1155,7 +1170,10 @@ impl<'a> Stage0<'a> {
11551170
self.vmm
11561171
.notify_q("boot.progress", "requesting app keys")
11571172
.await;
1158-
let app_keys = self.request_app_keys().await?;
1173+
let app_keys = self
1174+
.request_app_keys()
1175+
.await
1176+
.context("Failed to request app keys")?;
11591177
if app_keys.disk_crypt_key.is_empty() {
11601178
bail!("Failed to get valid key phrase from KMS");
11611179
}

0 commit comments

Comments
 (0)