Commit 8316a06

Eric Bower  ·  2026-05-08 11:35:58 -0400 EDT
parent 4eaacc1
fix: published.json
1 files changed,  +11, -6
+11, -6
......@@ -1047,6 +1047,7 @@ func monitorTick(cfg *Cfg, log *slog.Logger, output io.Writer, jobStates map[str
10471047 if allCompleted(group) {
10481048 // Check sentinel — publish terminal status exactly once
10491049 sentinel := filepath.Join(cfg.ArtifactDir, name, jobID, "published.json")
1050+ log.Debug("checking completion", "all_completed", true, "sentinel", sentinel)
10501051 if _, err := os.Stat(sentinel); err == nil {
10511052 log.Debug("terminal status already published, skipping", "sentinel", sentinel)
10521053 continue
......@@ -1075,11 +1076,10 @@ func monitorTick(cfg *Cfg, log *slog.Logger, output io.Writer, jobStates map[str
10751076 log.Error("publish final status", "err", err)
10761077 }
10771078 }
1078- // Sync artifacts before writing sentinel — syncArtifacts skips jobs with published.json
1079- if err := syncJobArtifacts(cfg, name, jobID, log); err != nil {
1080- log.Error("sync artifacts", "err", err)
1081- }
1082- // Write sentinel so we don't re-publish on subsequent ticks
1079+ // Write published.json, then sync to include it in the rsync.
1080+ // syncArtifacts at end-of-tick will skip this job (has published.json),
1081+ // so this is the only sync for completed jobs. In-progress jobs are
1082+ // synced every tick by syncArtifacts (no published.json yet).
10831083 published := map[string]interface{}{
10841084 "status": status,
10851085 "exit_code": exitCode,
......@@ -1087,9 +1087,13 @@ func monitorTick(cfg *Cfg, log *slog.Logger, output io.Writer, jobStates map[str
10871087 "finished_at": time.Now().UTC().Format(time.RFC3339),
10881088 }
10891089 publishedJSON, _ := json.Marshal(published)
1090+ log.Info("writing sentinel", "path", sentinel)
10901091 if err := os.WriteFile(sentinel, publishedJSON, 0644); err != nil {
10911092 log.Error("write published sentinel", "err", err)
10921093 }
1094+ if err := syncJobArtifacts(cfg, name, jobID, log); err != nil {
1095+ log.Error("sync artifacts", "err", err)
1096+ }
10931097 } else {
10941098 log.Debug("job still running", "sessions", len(group))
10951099 // Publish running status only when --include-running is set
......@@ -1530,7 +1534,8 @@ func syncArtifacts(cfg *Cfg, log *slog.Logger) error {
15301534 jobDir := filepath.Join(cfg.ArtifactDir, entry.Name(), repoEntry.Name())
15311535 publishedPath := filepath.Join(jobDir, "published.json")
15321536
1533- // Skip if already published (job is complete)
1537+ // Skip if job is complete (published.json exists)
1538+ // In-progress jobs are synced every tick; completed jobs are skipped.
15341539 if _, err := os.Stat(publishedPath); err == nil {
15351540 continue
15361541 }