Skip to content

Commit 770daff

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 770daff

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

dstack-util/src/system_setup.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,10 +708,18 @@ 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 synced = false;
712+
for i in 1..=30 {
713+
if cmd! { chronyc waitsync 1 0.2; }.is_ok() {
714+
synced = true;
715+
break;
716+
}
717+
info!("Time sync attempt {i}/30 failed, retrying...");
718+
tokio::time::sleep(Duration::from_secs(1)).await;
719+
}
720+
if !synced {
721+
bail!("Failed to sync system time after 30 attempts");
713722
}
714-
.context("Failed to sync system time")?;
715723
} else {
716724
info!("System time will be synchronized by chronyd in background");
717725
}

0 commit comments

Comments
 (0)