diff --git a/launcher/container_runner.go b/launcher/container_runner.go index 9d6e4ce3..078032a5 100644 --- a/launcher/container_runner.go +++ b/launcher/container_runner.go @@ -579,17 +579,17 @@ func (r *ContainerRunner) Run(ctx context.Context) error { return fmt.Errorf("unknown logging redirect location: %v", r.launchSpec.LogRedirect) } - setupDuration := time.Since(start) - r.logger.Info("Workload setup completed", - "setup_sec", setupDuration.Seconds(), - ) - task, err := r.container.NewTask(ctx, cio.NewCreator(streamOpt)) if err != nil { return &RetryableError{err} } defer task.Delete(ctx) + setupDuration := time.Since(start) + r.logger.Info("Workload setup completed", + "setup_sec", setupDuration.Seconds(), + ) + exitStatusC, err := task.Wait(ctx) if err != nil { r.logger.Error(err.Error()) diff --git a/launcher/internal/logging/logging.go b/launcher/internal/logging/logging.go index b0acdc8b..f78f754b 100644 --- a/launcher/internal/logging/logging.go +++ b/launcher/internal/logging/logging.go @@ -174,11 +174,13 @@ func (l *logger) writeLog(severity clogging.Severity, msg string, args ...any) { logEntry.Payload = pl l.cloudLogger.Log(logEntry) - l.cloudLogger.Flush() + if err := l.cloudLogger.Flush(); err != nil { + l.serialLogger.Error(fmt.Sprintf("cloud.Logger.Flush returned error: %v", err)) + } // Write to serial console. switch severity { - case clogging.Info, clogging.Notice: + case clogging.Info, clogging.Notice, clogging.Debug: l.serialLogger.Info(msg, args...) case clogging.Warning: l.serialLogger.Warn(msg, args...)