@@ -123,7 +123,7 @@ func ExecuteTaskInEnvironment(task Task, prePost string) error {
123
123
fmt .Printf ("##############################################\n BEGIN %s %s\n ##############################################\n " , prePost , task .Name )
124
124
st := time .Now ()
125
125
126
- err := ExecTaskInPod (task , command , false ) //(task.Service, task.Namespace, command, false, task.Container, task.ScaleWaitTime, task.ScaleMaxIterations)
126
+ err := ExecTaskInPod (task , command , false )
127
127
128
128
if err != nil {
129
129
fmt .Printf ("Failed to execute task `%v` due to reason `%v`\n " , task .Name , err .Error ())
@@ -270,15 +270,28 @@ func ExecTaskInPod(
270
270
return fmt .Errorf ("error while creating Executor: %v" , err )
271
271
}
272
272
273
- err = exec .Stream (remotecommand.StreamOptions {
273
+ // After replacing exec.Stream with exec.StreamWithContext, we can now pass a context to the stream
274
+ // this will allow us, eventually, to set limits on how long the exec can run, among other things.
275
+ err = exec .StreamWithContext (context .TODO (), remotecommand.StreamOptions {
274
276
Stdout : os .Stdout ,
275
277
Stderr : os .Stderr ,
276
278
Tty : tty ,
277
279
})
280
+
278
281
if err != nil {
279
282
return fmt .Errorf ("Error returned: %v" , err )
280
283
}
281
284
285
+ if debug {
286
+ fmt .Printf ("Task '%v' executed in pod %v \n " , task .Name , pod .Name )
287
+ if numIterations > 1 {
288
+ fmt .Printf ("Scaled up pods to %d replicas before executing task\n " , numIterations )
289
+ }
290
+ if task .ScaleWaitTime > 0 {
291
+ fmt .Printf ("Waited %d seconds before executing task\n " , task .ScaleWaitTime )
292
+ }
293
+ }
294
+
282
295
return nil
283
296
284
297
}
0 commit comments