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

[WIP] log untar errors #992

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion hack/ci/e2e-k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ set -o errexit -o nounset -o xtrace
cleanup() {
# KIND_CREATE_ATTEMPTED is true once we: kind create
if [ "${KIND_CREATE_ATTEMPTED:-}" = true ]; then
kind "export" logs "${ARTIFACTS}/logs" || true
kind 'export' logs -v 99999 "${ARTIFACTS}/logs" || true
kind delete cluster || true
fi
rm -f _output/bin/e2e.test || true
Expand Down
7 changes: 6 additions & 1 deletion pkg/exec/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/alessio/shellescape"

"sigs.k8s.io/kind/pkg/errors"
"sigs.k8s.io/kind/pkg/globals"
)

// PrettyCommand takes arguments identical to Cmder.Command,
Expand Down Expand Up @@ -105,7 +106,11 @@ func RunWithStdoutReader(cmd Cmd, readerFunc func(io.Reader) error) error {

errChan := make(chan error, 1)
go func() {
errChan <- readerFunc(pr)
rerr := readerFunc(pr)
if rerr != nil {
globals.GetLogger().V(1).Infof("readerFunc encountered: %v", rerr)
}
errChan <- rerr
pr.Close()
}()

Expand Down
6 changes: 5 additions & 1 deletion pkg/internal/cluster/logs/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func Collect(nodes []nodes.Node, dir string) error {
// http://man7.org/linux/man-pages/man1/tar.1.html#RETURN_VALUE
`tar --hard-dereference -C /var/log -chf - . || (r=$?; [ $r -eq 1 ] || exit $r)`,
)

if err := exec.RunWithStdoutReader(cmd, func(outReader io.Reader) error {
if err := untar(outReader, filepath.Join(dir, name)); err != nil {
return errors.Wrapf(err, "Untarring %q: %v", name, err)
Expand Down Expand Up @@ -130,6 +129,11 @@ func Collect(nodes []nodes.Node, dir string) error {
// untar reads the tar file from r and writes it into dir.
func untar(r io.Reader, dir string) (err error) {
tr := tar.NewReader(r)
defer func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really needed? is is possible this func returns without error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The WIP is to prevent merge. This PR is just being used to obtain debugging information versus trying to trigger this failure mode locally because CI will run many jobs at once for me :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(also that's why it checks if err != nil)

if err != nil {
globals.GetLogger().Errorf("untarring encountered: %v", err)
}
}()
for {
f, err := tr.Next()

Expand Down