Skip to content

Commit 4799c63

Browse files
authored
Merge pull request #274 from aojea/dumplogs2
Dump cluster logs when necessary
2 parents 696b358 + 15c1c04 commit 4799c63

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

kubetest2-gke/deployer/down.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ func (d *Deployer) Down() error {
3636
return nil
3737
}
3838

39+
if err := d.DumpClusterLogs(); err != nil {
40+
klog.Warningf("Dumping cluster logs at the end of Up() failed: %v", err)
41+
}
42+
3943
// If the GCP projects are acquired from Boskos, release the projects and
4044
// rely on boskos-janitor to do clean-ups for them.
4145
if d.totalBoskosProjectsRequested > 0 {

kubetest2-gke/deployer/up.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,26 @@ func (d *Deployer) Up() error {
3838
return err
3939
}
4040

41-
defer func() {
41+
if err := d.CreateNetwork(); err != nil {
42+
return err
43+
}
44+
if err := d.CreateClusters(); err != nil {
4245
if d.RepoRoot == "" {
4346
klog.Warningf("repo-root not supplied, skip dumping cluster logs")
44-
return
4547
}
4648
if err := d.DumpClusterLogs(); err != nil {
4749
klog.Warningf("Dumping cluster logs at the end of Up() failed: %v", err)
4850
}
49-
}()
50-
51-
if err := d.CreateNetwork(); err != nil {
52-
return err
53-
}
54-
if err := d.CreateClusters(); err != nil {
5551
return fmt.Errorf("error creating the clusters: %w", err)
5652
}
5753

5854
if err := d.TestSetup(); err != nil {
55+
if d.RepoRoot == "" {
56+
klog.Warningf("repo-root not supplied, skip dumping cluster logs")
57+
}
58+
if err := d.DumpClusterLogs(); err != nil {
59+
klog.Warningf("Dumping cluster logs at the end of Up() failed: %v", err)
60+
}
5961
return fmt.Errorf("error running setup for the tests: %w", err)
6062
}
6163

kubetest2-kind/deployer/down.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ import (
2525
)
2626

2727
func (d *deployer) Down() error {
28+
if err := d.DumpClusterLogs(); err != nil {
29+
klog.Warningf("Dumping cluster logs at the start of Down() failed: %v", err)
30+
}
2831
args := []string{
2932
"delete", "cluster",
3033
"--name", d.ClusterName,

0 commit comments

Comments
 (0)