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

Reroute logs printed directly to stdout #4115

Merged
merged 1 commit into from
Apr 23, 2019
Merged
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
18 changes: 18 additions & 0 deletions pkg/minikube/machine/cache_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ limitations under the License.
package machine

import (
"bytes"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
"path"
Expand Down Expand Up @@ -288,6 +291,21 @@ func getDstPath(image, dst string) (string, error) {

// CacheImage caches an image
func CacheImage(image, dst string) error {
// There are go-containerregistry calls here that result in
// ugly log messages getting printed to stdout. Capture
// stdout instead and writing it to info.
r, w, err := os.Pipe()
if err != nil {
return errors.Wrap(err, "opening writing buffer")
}
log.SetOutput(w)
defer func() {
log.SetOutput(os.Stdout)
var buf bytes.Buffer
io.Copy(&buf, r)
glog.Infof(buf.String())
}()

glog.Infof("Attempting to cache image: %s at %s\n", image, dst)
if _, err := os.Stat(dst); err == nil {
return nil
Expand Down