Address feedback and test failures

This commit is contained in:
Peter Rifel 2020-07-17 10:55:59 -05:00
parent d8b69ab2e3
commit 1faeb36d37
No known key found for this signature in database
GPG Key ID: BC6469E5B16DB2B6
4 changed files with 9 additions and 6 deletions

View File

@ -150,7 +150,7 @@ func RunToolboxDump(ctx context.Context, f *util.Factory, out io.Writer, options
}
// TODO: We need to find the correct SSH user, ideally per IP
sshUser := "admin"
sshUser := "ubuntu"
sshConfig := &ssh.ClientConfig{
User: sshUser,
Auth: []ssh.AuthMethod{

View File

@ -23,6 +23,7 @@ kops toolbox dump [flags]
### Options
```
--dir string target directory; if specified will collect logs and other information.
-h, --help help for dump
-o, --output string output format. One of: yaml, json (default "yaml")
```

View File

@ -79,6 +79,7 @@ k8s.io/kops/pkg/commands
k8s.io/kops/pkg/configbuilder
k8s.io/kops/pkg/diff
k8s.io/kops/pkg/dns
k8s.io/kops/pkg/dump
k8s.io/kops/pkg/edit
k8s.io/kops/pkg/featureflag
k8s.io/kops/pkg/flagbuilder

View File

@ -20,15 +20,16 @@ import (
"bytes"
"context"
"fmt"
"golang.org/x/crypto/ssh"
"io"
corev1 "k8s.io/api/core/v1"
"k8s.io/klog"
"log"
"net"
"os"
"path/filepath"
"strings"
"golang.org/x/crypto/ssh"
corev1 "k8s.io/api/core/v1"
"k8s.io/klog"
)
// logDumper gets all the nodes from a kubernetes cluster and dumps a well-known set of logs
@ -235,7 +236,7 @@ func (n *logDumperNode) dump(ctx context.Context) []error {
errors = append(errors, err)
}
// Capture logs from any systemd services in our list, that are registered
// Capture logs from any systemd services in our list that are registered
services, err := n.listSystemdUnits(ctx)
if err != nil {
errors = append(errors, fmt.Errorf("error listing systemd services: %v", err))
@ -262,7 +263,7 @@ func (n *logDumperNode) dump(ctx context.Context) []error {
if !strings.HasPrefix(f, prefix) {
continue
}
if err := n.shellToFile(ctx, "sudo cat "+f, filepath.Join(n.dir, filepath.Base(f))); err != nil {
if err := n.shellToFile(ctx, "sudo cat '"+strings.ReplaceAll(f, "'", "'\\''")+"'", filepath.Join(n.dir, filepath.Base(f))); err != nil {
errors = append(errors, err)
}
}