@@ -71,7 +71,7 @@ func (c *CollectLogs) Collect(progressChan chan<- interface{}) (CollectorResult,
7171 }
7272
7373 for _ , containerName := range containerNames {
74- podLogs , err := savePodLogs (ctx , c .BundlePath , client , & pod , c .Collector .Name , containerName , c .Collector .Limits , false )
74+ podLogs , err := savePodLogs (ctx , c .BundlePath , client , & pod , c .Collector .Name , containerName , c .Collector .Limits , false , true )
7575 if err != nil {
7676 key := fmt .Sprintf ("%s/%s-errors.json" , c .Collector .Name , pod .Name )
7777 if containerName != "" {
@@ -89,7 +89,7 @@ func (c *CollectLogs) Collect(progressChan chan<- interface{}) (CollectorResult,
8989 }
9090 } else {
9191 for _ , container := range c .Collector .ContainerNames {
92- containerLogs , err := savePodLogs (ctx , c .BundlePath , client , & pod , c .Collector .Name , container , c .Collector .Limits , false )
92+ containerLogs , err := savePodLogs (ctx , c .BundlePath , client , & pod , c .Collector .Name , container , c .Collector .Limits , false , true )
9393 if err != nil {
9494 key := fmt .Sprintf ("%s/%s/%s-errors.json" , c .Collector .Name , pod .Name , container )
9595 err := output .SaveResult (c .BundlePath , key , marshalErrors ([]string {err .Error ()}))
@@ -132,8 +132,9 @@ func savePodLogs(
132132 collectorName , container string ,
133133 limits * troubleshootv1beta2.LogLimits ,
134134 follow bool ,
135+ createSymLinks bool ,
135136) (CollectorResult , error ) {
136- return savePodLogsWithInterface (ctx , bundlePath , client , pod , collectorName , container , limits , follow )
137+ return savePodLogsWithInterface (ctx , bundlePath , client , pod , collectorName , container , limits , follow , createSymLinks )
137138}
138139
139140func savePodLogsWithInterface (
@@ -144,6 +145,7 @@ func savePodLogsWithInterface(
144145 collectorName , container string ,
145146 limits * troubleshootv1beta2.LogLimits ,
146147 follow bool ,
148+ createSymLinks bool ,
147149) (CollectorResult , error ) {
148150 podLogOpts := corev1.PodLogOptions {
149151 Follow : follow ,
@@ -185,7 +187,9 @@ func savePodLogsWithInterface(
185187 return nil , errors .Wrap (err , "failed to get log writer" )
186188 }
187189 // NOTE: deferred calls are executed in LIFO order i.e called in reverse order
188- defer result .SymLinkResult (bundlePath , linkRelPathPrefix + ".log" , filePathPrefix + ".log" )
190+ if createSymLinks {
191+ defer result .SymLinkResult (bundlePath , linkRelPathPrefix + ".log" , filePathPrefix + ".log" )
192+ }
189193 defer result .CloseWriter (bundlePath , filePathPrefix + ".log" , logWriter )
190194
191195 _ , err = io .Copy (logWriter , podLogs )
@@ -207,7 +211,9 @@ func savePodLogsWithInterface(
207211 return nil , errors .Wrap (err , "failed to get previous log writer" )
208212 }
209213 // NOTE: deferred calls are executed in LIFO order i.e called in reverse order
210- defer result .SymLinkResult (bundlePath , linkRelPathPrefix + "-previous.log" , filePathPrefix + "-previous.log" )
214+ if createSymLinks {
215+ defer result .SymLinkResult (bundlePath , linkRelPathPrefix + "-previous.log" , filePathPrefix + "-previous.log" )
216+ }
211217 defer result .CloseWriter (bundlePath , filePathPrefix + "-previous.log" , logWriter )
212218
213219 _ , err = io .Copy (prevLogWriter , podLogs )
0 commit comments