@@ -140,6 +140,7 @@ func runGatherBootstrapCmd(ctx context.Context, directory string) (string, error
140140
141141func gatherBootstrap (bootstrap string , port int , masters []string , directory string ) (string , error ) {
142142 gatherID := time .Now ().Format ("20060102150405" )
143+ archives := map [string ]string {}
143144
144145 serialLogBundle := filepath .Join (directory , fmt .Sprintf ("serial-log-bundle-%s.tar.gz" , gatherID ))
145146 serialLogBundlePath , err := filepath .Abs (serialLogBundle )
@@ -154,9 +155,32 @@ func gatherBootstrap(bootstrap string, port int, masters []string, directory str
154155 logrus .Info ("Pulling VM console logs" )
155156 if err := consoleGather .Run (); err != nil {
156157 logrus .Infof ("Failed to gather VM console logs: %s" , err .Error ())
158+ } else {
159+ archives [serialLogBundlePath ] = "serial"
157160 }
158161 }
159162
163+ clusterLogBundlePath , err := pullLogsFromBootstrap (gatherID , bootstrap , port , masters , directory )
164+ if err != nil {
165+ logrus .Infof ("Failed to gather bootstrap logs: %s" , err .Error ())
166+ } else {
167+ archives [clusterLogBundlePath ] = ""
168+ }
169+
170+ if len (archives ) == 0 {
171+ return "" , fmt .Errorf ("failed to gather VM console and bootstrap logs" )
172+ }
173+
174+ logBundlePath := filepath .Join (directory , fmt .Sprintf ("log-bundle-%s.tar.gz" , gatherID ))
175+ err = serialgather .CombineArchives (logBundlePath , archives )
176+ if err != nil {
177+ return "" , errors .Wrap (err , "failed to combine archives" )
178+ }
179+
180+ return logBundlePath , nil
181+ }
182+
183+ func pullLogsFromBootstrap (gatherID string , bootstrap string , port int , masters []string , directory string ) (string , error ) {
160184 logrus .Info ("Pulling debug logs from the bootstrap machine" )
161185 client , err := ssh .NewClient ("core" , net .JoinHostPort (bootstrap , strconv .Itoa (port )), gatherBootstrapOpts .sshKeys )
162186 if err != nil {
@@ -180,14 +204,7 @@ func gatherBootstrap(bootstrap string, port int, masters []string, directory str
180204 return "" , errors .Wrap (err , "failed to stat log file" )
181205 }
182206
183- logBundlePath := filepath .Join (filepath .Dir (clusterLogBundlePath ), fmt .Sprintf ("log-bundle-%s.tar.gz" , gatherID ))
184- archives := map [string ]string {serialLogBundlePath : "serial" , clusterLogBundlePath : "" }
185- err = serialgather .CombineArchives (logBundlePath , archives )
186- if err != nil {
187- return "" , errors .Wrap (err , "failed to combine archives" )
188- }
189-
190- return logBundlePath , nil
207+ return clusterLogBundlePath , nil
191208}
192209
193210func logClusterOperatorConditions (ctx context.Context , config * rest.Config ) error {
0 commit comments