Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't use progress to render restart, which hides logs #12226

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions pkg/compose/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@
pathMappings[i] = batch[i].PathMapping
}

writeWatchSyncMessage(options.LogTo, serviceName, pathMappings)
writeWatchSyncMessage(options.LogTo, serviceName, pathMappings, restartService)

service, err := project.GetService(serviceName)
if err != nil {
Expand All @@ -537,17 +537,28 @@
return err
}
if restartService {
return s.Restart(ctx, project.Name, api.RestartOptions{
err = s.restart(ctx, project.Name, api.RestartOptions{
Services: []string{serviceName},
Project: project,
NoDeps: false,
})
if err != nil {
return err
}

Check warning on line 547 in pkg/compose/watch.go

View check run for this annotation

Codecov / codecov/patch

pkg/compose/watch.go#L546-L547

Added lines #L546 - L547 were not covered by tests
options.LogTo.Log(
api.WatchLogger,
fmt.Sprintf("service %q restarted", serviceName))

}
return nil
}

// writeWatchSyncMessage prints out a message about the sync for the changed paths.
func writeWatchSyncMessage(log api.LogConsumer, serviceName string, pathMappings []sync.PathMapping) {
func writeWatchSyncMessage(log api.LogConsumer, serviceName string, pathMappings []sync.PathMapping, restart bool) {
action := "Syncing"
if restart {
action = "Syncing and restarting"
}
if logrus.IsLevelEnabled(logrus.DebugLevel) {
hostPathsToSync := make([]string, len(pathMappings))
for i := range pathMappings {
Expand All @@ -556,15 +567,16 @@
log.Log(
api.WatchLogger,
fmt.Sprintf(
"Syncing %q after changes were detected: %s",
"%s service %q after changes were detected: %s",
action,
serviceName,
strings.Join(hostPathsToSync, ", "),
),
)
} else {
log.Log(
api.WatchLogger,
fmt.Sprintf("Syncing service %q after %d changes were detected", serviceName, len(pathMappings)),
fmt.Sprintf("%s service %q after %d changes were detected", action, serviceName, len(pathMappings)),
)
}
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/e2e/watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,7 @@ func doTest(t *testing.T, svcName string) {
return poll.Continue("%v", r.Combined())
}
}
poll.WaitOn(t, checkRestart(fmt.Sprintf("%s-1 Restarting", svcName)))
poll.WaitOn(t, checkRestart(fmt.Sprintf("%s-1 Started", svcName)))
poll.WaitOn(t, checkRestart(fmt.Sprintf("service %q restarted", svcName)))
poll.WaitOn(t, checkFileContents("/app/config/file.config", "This is an updated config file"))

testComplete.Store(true)
Expand Down
Loading