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

Make sure we mute/unmute logs at the correct times #2592

Merged
merged 1 commit into from
Aug 2, 2019
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
2 changes: 1 addition & 1 deletion pkg/skaffold/kubernetes/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func sinceSeconds(d time.Duration) int64 {
}

func (a *LogAggregator) streamContainerLogs(ctx context.Context, pod *v1.Pod, container v1.ContainerStatus) {
logrus.Infof("Stream logs from pod: %s container: %s", pod.Name, container.Name)
logrus.Infof("Streaming logs from pod: %s container: %s", pod.Name, container.Name)

// In theory, it's more precise to use --since-time='' but there can be a time
// difference between the user's machine and the server.
Expand Down
12 changes: 10 additions & 2 deletions pkg/skaffold/runner/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ import (
var ErrorConfigurationChanged = errors.New("configuration changed")

func (r *SkaffoldRunner) doDev(ctx context.Context, out io.Writer) error {
r.logger.Mute()
actionPerformed := false

// acquire the intents
buildIntent, syncIntent, deployIntent := r.intents.GetIntents()

if (r.changeSet.needsRedeploy && deployIntent) ||
(len(r.changeSet.needsRebuild) > 0 && buildIntent) ||
(len(r.changeSet.needsResync) > 0 && syncIntent) {
r.logger.Mute()
balopat marked this conversation as resolved.
Show resolved Hide resolved
// if any action is going to be performed, reset the monitor's changed component tracker for debouncing
defer r.monitor.Reset()
defer r.listener.LogWatchToUser(out)
Expand All @@ -55,6 +56,7 @@ func (r *SkaffoldRunner) doDev(ctx context.Context, out io.Writer) error {
r.changeSet.resetSync()
r.intents.resetSync()
}()
actionPerformed = true
for _, s := range r.changeSet.needsResync {
color.Default.Fprintf(out, "Syncing %d files for %s\n", len(s.Copy)+len(s.Delete), s.Image)

Expand All @@ -69,6 +71,9 @@ func (r *SkaffoldRunner) doDev(ctx context.Context, out io.Writer) error {
r.changeSet.resetBuild()
r.intents.resetBuild()
}()
// this linter apparently doesn't understand fallthroughs
//nolint:ineffassign
actionPerformed = true
if _, err := r.BuildAndTest(ctx, out, r.changeSet.needsRebuild); err != nil {
r.changeSet.reset()
logrus.Warnln("Skipping deploy due to error:", err)
Expand All @@ -82,6 +87,7 @@ func (r *SkaffoldRunner) doDev(ctx context.Context, out io.Writer) error {
r.logger.Unmute()
return nil
}
actionPerformed = true
r.forwarderManager.Stop()
defer func() {
r.changeSet.reset()
Expand All @@ -96,7 +102,9 @@ func (r *SkaffoldRunner) doDev(ctx context.Context, out io.Writer) error {
}
}

r.logger.Unmute()
if actionPerformed {
r.logger.Unmute()
}
return nil
}

Expand Down