···
io.Copy(os.Stdout, reader)
105
+
workflowTimeoutStr := e.cfg.Pipelines.WorkflowTimeout
106
+
workflowTimeout, err := time.ParseDuration(workflowTimeoutStr)
108
+
e.l.Error("failed to parse workflow timeout", "error", err, "timeout", workflowTimeoutStr)
109
+
workflowTimeout = 5 * time.Minute
111
+
e.l.Info("using workflow timeout", "timeout", workflowTimeout)
112
+
ctx, cancel := context.WithTimeout(ctx, workflowTimeout)
err = e.StartSteps(ctx, w.Steps, wid, w.Image)
if errors.Is(err, ErrTimedOut) {
···
// All other errors are bubbled up.
// Fixed version of the step execution logic
func (e *Engine) StartSteps(ctx context.Context, steps []models.Step, wid models.WorkflowId, image string) error {
180
-
stepTimeoutStr := e.cfg.Pipelines.StepTimeout
181
-
stepTimeout, err := time.ParseDuration(stepTimeoutStr)
183
-
e.l.Error("failed to parse step timeout", "error", err, "timeout", stepTimeoutStr)
184
-
stepTimeout = 5 * time.Minute
186
-
e.l.Info("using step timeout", "timeout", stepTimeout)
for stepIdx, step := range steps {
envs := ConstructEnvs(step.Environment)
envs.AddEnv("HOME", workspaceDir)
e.l.Debug("envs for step", "step", step.Name, "envs", envs.Slice())
···
}, hostConfig, nil, nil, "")
211
+
defer e.DestroyStep(ctx, resp.ID)
return fmt.Errorf("creating container: %w", err)
···
return fmt.Errorf("connecting network: %w", err)
211
-
stepCtx, stepCancel := context.WithTimeout(ctx, stepTimeout)
213
-
err = e.docker.ContainerStart(stepCtx, resp.ID, container.StartOptions{})
221
+
err = e.docker.ContainerStart(ctx, resp.ID, container.StartOptions{})
e.l.Info("started container", "name", resp.ID, "step", step.Name)
···
// start tailing logs in background
tailDone := make(chan error, 1)
223
-
tailDone <- e.TailStep(stepCtx, resp.ID, wid, stepIdx)
230
+
tailDone <- e.TailStep(ctx, resp.ID, wid, stepIdx)
// wait for container completion or timeout
···
233
-
state, waitErr = e.WaitStep(stepCtx, resp.ID)
240
+
state, waitErr = e.WaitStep(ctx, resp.ID)
···
// wait for tailing to complete
243
-
case <-stepCtx.Done():
244
-
e.l.Warn("step timed out; killing container", "container", resp.ID, "timeout", stepTimeout)
246
-
_ = e.DestroyStep(ctx, resp.ID)
250
+
e.l.Warn("step timed out; killing container", "container", resp.ID, "step", step.Name)
251
+
err = e.DestroyStep(context.Background(), resp.ID)
253
+
e.l.Error("failed to destroy step", "container", resp.ID, "error", err)
// wait for both goroutines to finish