Skip to content

Commit db89b49

Browse files
committed
Improve time sync logging visibility
Add retry loop with per-attempt logging for NTS time sync, making it easy to diagnose slow NTS-KE handshakes in boot logs.
1 parent 627f19a commit db89b49

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

dstack-util/src/system_setup.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,10 +708,23 @@ pub async fn cmd_sys_setup(args: SetupArgs) -> Result<()> {
708708
async fn do_sys_setup(stage0: Stage0<'_>) -> Result<()> {
709709
if stage0.shared.app_compose.secure_time {
710710
info!("Waiting for the system time to be synchronized");
711-
cmd! {
712-
chronyc waitsync 20 0.1;
711+
let mut last_err = None;
712+
for i in 1..=30 {
713+
match cmd! { chronyc waitsync 1 0.2; } {
714+
Ok(_) => {
715+
last_err = None;
716+
break;
717+
}
718+
Err(e) => {
719+
info!("Time sync attempt {i}/30 failed, retrying...");
720+
last_err = Some(e);
721+
tokio::time::sleep(Duration::from_secs(1)).await;
722+
}
723+
}
724+
}
725+
if let Some(e) = last_err {
726+
return Err(e).context("Failed to sync system time after 30 attempts");
713727
}
714-
.context("Failed to sync system time")?;
715728
} else {
716729
info!("System time will be synchronized by chronyd in background");
717730
}

0 commit comments

Comments
 (0)