Skip to content

Commit

Permalink
Merge pull request #6 from gyuho/get-worker-node-logs
Browse files Browse the repository at this point in the history
*: expose "GetWorkerNodeLogs"
  • Loading branch information
gyuho authored Oct 22, 2018
2 parents e6daa01 + e486828 commit 28d996a
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 5 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG-0.0.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@


## [0.0.3](https://github.com/aws/awstester/releases/tag/0.0.3) (2018-10-22)

See [code changes](https://github.com/aws/awstester/compare/0.0.2...0.0.3).

### `awstester` CLI

- Add [`awstester eks test get-worker-node-logs`](https://github.com/aws/awstester/pull/6) command.

### `eksdeployer`

- Add [`GetWorkerNodeLogs`](https://github.com/aws/awstester/pull/6) to download worker node logs.

### Go

- Compile with [*Go 1.11.1*](https://golang.org/doc/devel/release.html#go1.11).


## [0.0.2](https://github.com/aws/awstester/releases/tag/0.0.2) (2018-10-22)

See [code changes](https://github.com/aws/awstester/compare/0.0.1...0.0.2).
Expand Down
35 changes: 34 additions & 1 deletion cmd/awstester/eks/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,45 @@ func newTest() *cobra.Command {
Short: "Test commands",
}
cmd.AddCommand(
newTestGetWorkerNodeLogs(),
newTestDumpClusterLogs(),
newTestALB(),
)
return cmd
}

func newTestGetWorkerNodeLogs() *cobra.Command {
return &cobra.Command{
Use: "get-worker-node-logs",
Short: "Downloads all cluster logs",
Run: testGetWorkerNodeLogs,
}
}

func testGetWorkerNodeLogs(cmd *cobra.Command, args []string) {
if path == "" {
fmt.Fprintln(os.Stderr, "'--path' flag is not specified")
os.Exit(1)
}

cfg, err := eksconfig.Load(path)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to load configuration %q (%v)\n", path, err)
os.Exit(1)
}
var dp eksdeployer.Interface
dp, err = eks.NewEKSDeployer(cfg)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to create EKS deployer %v\n", err)
os.Exit(1)
}

if err = dp.GetWorkerNodeLogs(); err != nil {
fmt.Fprintf(os.Stderr, "failed to get worker node logs %v\n", err)
os.Exit(1)
}
}

func newTestDumpClusterLogs() *cobra.Command {
return &cobra.Command{
Use: "dump-cluster-logs [artifact-directory]",
Expand Down Expand Up @@ -55,7 +88,7 @@ func testDumpClusterLogs(cmd *cobra.Command, args []string) {
}

if err = dp.DumpClusterLogs(dir, ""); err != nil {
fmt.Fprintf(os.Stderr, "failed correctness test %v\n", err)
fmt.Fprintf(os.Stderr, "failed to dump cluster logs %v\n", err)
os.Exit(1)
}
}
Expand Down
3 changes: 3 additions & 0 deletions eksdeployer/eksdeployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ type Interface interface {
// Extra methods for EKS specific operations //
///////////////////////////////////////////////

// GetWorkerNodeLogs downloads logs from worker node machines.
GetWorkerNodeLogs() error

// UploadToBucketForTests uploads a local file to awstester S3 bucket.
UploadToBucketForTests(localPath, remotePath string) error

Expand Down
4 changes: 2 additions & 2 deletions internal/eks/deployer_embedded.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ func (md *embedded) GetClusterCreated(v string) (time.Time, error) {
// Let default kubetest log dumper handle all artifact uploads.
// See https://github.com/kubernetes/test-infra/pull/9811/files#r225776067.
func (md *embedded) DumpClusterLogs(artifactDir, _ string) (err error) {
err = md.fetchWorkerNodeLogs()
err = md.GetWorkerNodeLogs()
if err != nil {
return err
}
Expand Down Expand Up @@ -699,7 +699,7 @@ func (md *embedded) uploadWorkerNode() (err error) {
if !md.cfg.EnableNodeSSH {
return nil
}
err = md.fetchWorkerNodeLogs()
err = md.GetWorkerNodeLogs()
if err != nil {
return err
}
Expand Down
5 changes: 5 additions & 0 deletions internal/eks/worker_node_log_aws_cli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package eks

func (ac *awsCli) GetWorkerNodeLogs() error {
panic("TODO")
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

// https://github.com/kubernetes/test-infra/blob/master/kubetest/dump.go
// TODO: parallelize for >100 nodes?
func (md *embedded) fetchWorkerNodeLogs() (err error) {
func (md *embedded) GetWorkerNodeLogs() (err error) {
if !md.cfg.EnableNodeSSH {
return errors.New("node SSH is not enabled")
}
Expand Down
10 changes: 9 additions & 1 deletion kubetest/eks/eks.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,15 @@ func (tr *tester) GetClusterCreated(v string) (time.Time, error) {
// See https://github.com/kubernetes/test-infra/pull/9811/files#r225776067.
func (tr *tester) DumpClusterLogs(artifactDir, _ string) (err error) {
tr.LoadConfig()

_, err = tr.ctrl.Output(exec.Command(
tr.awsTesterPath,
"eks",
"--path="+tr.cfg.ConfigPath,
"test", "get-worker-node-logs",
))
if err != nil {
return err
}
_, err = tr.ctrl.Output(exec.Command(
tr.awsTesterPath,
"eks",
Expand Down

0 comments on commit 28d996a

Please sign in to comment.