Skip to content

Commit 252bf7f

Browse files
zimegmwbrooks
andauthored
fix: output debug log if manifest file changes but manifest source is remote (#318)
Co-authored-by: Michael Brooks <mbrooks@slack-corp.com>
1 parent 4ff1172 commit 252bf7f

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

cmd/platform/run.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ func newRunLogger(clients *shared.ClientFactory, cmd *cobra.Command) *logger.Log
183183
cmd.Println(style.Secondary(fmt.Sprintf("Manifest change detected: %s, reinstalling app...", path)))
184184
case "on_cloud_run_watch_manifest_change_reinstalled":
185185
cmd.Println(style.Secondary("App successfully reinstalled"))
186+
case "on_cloud_run_watch_manifest_change_skipped_remote":
187+
path := event.DataToString("cloud_run_watch_manifest_change_skipped")
188+
cmd.Println(style.Secondary(fmt.Sprintf("Manifest change detected: %s, skipped reinstalling app because manifest.source=remote", path)))
186189
case "on_cloud_run_watch_app_change":
187190
path := event.DataToString("cloud_run_watch_app_change")
188191
cmd.Println(style.Secondary(fmt.Sprintf("App change detected: %s, restarting server...", path)))

internal/pkg/platform/localserver.go

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,10 @@ func (r *LocalServer) WatchManifest(ctx context.Context, auth types.SlackAuth, a
365365
return err
366366
}
367367

368-
// Skip manifest watching if manifest source is remote
369-
if manifestSource.Equals(config.ManifestSourceRemote) {
370-
r.clients.IO.PrintDebug(ctx, "Manifest watching disabled: manifest.source is set to remote")
371-
// Block until context is cancelled to keep the goroutine alive
372-
<-ctx.Done()
373-
return nil
368+
// Check if manifest source is remote - we'll still watch but only log changes
369+
isRemoteManifest := manifestSource.Equals(config.ManifestSourceRemote)
370+
if isRemoteManifest {
371+
r.clients.IO.PrintDebug(ctx, "Manifest source is remote - file changes will be logged only")
374372
}
375373

376374
// Get manifest watch configuration
@@ -396,8 +394,7 @@ func (r *LocalServer) WatchManifest(ctx context.Context, auth types.SlackAuth, a
396394
// Add provided paths to watcher
397395
for _, path := range paths {
398396
if err := w.AddRecursive(path); err != nil {
399-
r.log.Data["cloud_run_watch_error"] = fmt.Sprintf("manifest_watcher.paths: %s", err)
400-
r.log.Warn("on_cloud_run_watch_error")
397+
r.clients.IO.PrintDebug(ctx, "Skipping watch path %s: %s", path, err)
401398
}
402399
}
403400

@@ -409,15 +406,20 @@ func (r *LocalServer) WatchManifest(ctx context.Context, auth types.SlackAuth, a
409406
r.clients.IO.PrintDebug(ctx, "Manifest file watcher context canceled, returning.")
410407
return
411408
case event := <-w.Event:
412-
r.log.Data["cloud_run_watch_manifest_change"] = event.Path
413-
r.log.Info("on_cloud_run_watch_manifest_change")
414-
415-
// Reinstall the app when manifest changes
416-
if _, _, _, err := apps.InstallLocalApp(ctx, r.clients, "", r.log, auth, app); err != nil {
417-
r.log.Data["cloud_run_watch_error"] = err.Error()
418-
r.log.Warn("on_cloud_run_watch_error")
409+
if isRemoteManifest {
410+
r.log.Data["cloud_run_watch_manifest_change_skipped"] = event.Path
411+
r.log.Info("on_cloud_run_watch_manifest_change_skipped_remote")
419412
} else {
420-
r.log.Info("on_cloud_run_watch_manifest_change_reinstalled")
413+
r.log.Data["cloud_run_watch_manifest_change"] = event.Path
414+
r.log.Info("on_cloud_run_watch_manifest_change")
415+
416+
// Reinstall the app when manifest changes
417+
if _, _, _, err := apps.InstallLocalApp(ctx, r.clients, "", r.log, auth, app); err != nil {
418+
r.log.Data["cloud_run_watch_error"] = err.Error()
419+
r.log.Warn("on_cloud_run_watch_error")
420+
} else {
421+
r.log.Info("on_cloud_run_watch_manifest_change_reinstalled")
422+
}
421423
}
422424
case err := <-w.Error:
423425
r.log.Data["cloud_run_watch_error"] = err.Error()
@@ -474,8 +476,7 @@ func (r *LocalServer) WatchApp(ctx context.Context) error {
474476
// Add provided paths to watcher
475477
for _, path := range paths {
476478
if err := w.AddRecursive(path); err != nil {
477-
r.log.Data["cloud_run_watch_error"] = fmt.Sprintf("app_watcher.paths: %s", err)
478-
r.log.Warn("on_cloud_run_watch_error")
479+
r.clients.IO.PrintDebug(ctx, "Skipping watch path %s: %s", path, err)
479480
}
480481
}
481482

0 commit comments

Comments
 (0)