Skip to content

Commit

Permalink
Merge pull request #2592 from nkubala/unmute-logs
Browse files Browse the repository at this point in the history
Make sure we mute/unmute logs at the correct times
  • Loading branch information
balopat authored Aug 2, 2019
2 parents 4b959ca + e871bb2 commit 1903df3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/skaffold/kubernetes/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,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 @@ -34,14 +34,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()
// 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 @@ -56,6 +57,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 @@ -70,6 +72,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 @@ -83,6 +88,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 @@ -97,7 +103,9 @@ func (r *SkaffoldRunner) doDev(ctx context.Context, out io.Writer) error {
}
}

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

Expand Down

0 comments on commit 1903df3

Please sign in to comment.