# Parallel steps in kubernetes runner

**URL:** <https://drone.discourse.group/t/parallel-steps-in-kubernetes-runner/7656>\
**Category:** Drone Bugs\
**Created:** [April 21, 2020, 1:50pm UTC](https://drone.discourse.group/t/parallel-steps-in-kubernetes-runner/7656 "2020-04-21T13:50:30Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrewrynhard](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/andrewrynhard/32/5756_2.png) [@andrewrynhard](https://drone.discourse.group/u/andrewrynhard)\
**Post date:** [April 21, 2020, 1:50pm UTC](https://drone.discourse.group/t/parallel-steps-in-kubernetes-runner/7656/1 "2020-04-21T13:50:31Z")

</div>

When using a pipeline that has parallel steps, and when any two steps complete at roughly the same time, multiples steps fail with the following: `default: Operation cannot be fulfilled on pods "drone-0upypmgcjeq7yt2inqe5": the object has been modified; please apply your changes to the latest version and try again`.

---

<div class="post-metadata">

**Author:** ![ashwilliams1](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/ashwilliams1/32/5549_2.png) [@ashwilliams1](https://drone.discourse.group/u/ashwilliams1)\
**Post date:** [April 21, 2020, 6:24pm UTC](https://drone.discourse.group/t/parallel-steps-in-kubernetes-runner/7656/2 "2020-04-21T18:24:57Z")

</div>

See [Kubernetes runner: operation cannot be fulfilled; the object has been modified](http://discuss.harness.io/t/kube-runner-limitations/6853)

---

<div class="post-metadata">

**Author:** ![andrewrynhard](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/andrewrynhard/32/5756_2.png) [@andrewrynhard](https://drone.discourse.group/u/andrewrynhard)\
**Post date:** [April 23, 2020, 12:12am UTC](https://drone.discourse.group/t/parallel-steps-in-kubernetes-runner/7656/3 "2020-04-23T00:12:02Z")

</div>

This seems to prevent that error, but concurrent steps still fail for me. They either hang forever, or fail with zero logs. Now I see this in the kubelet logs:

```
147.75.64.155: E0423 00:09:56.347725 5495 status_manager.go:402] Status update on pod ci/drone-h4ozy45e6uldqyfbe4hb aborted: terminated container drone-5hxb5687jy44py8lbj3e attempted illegal transition to non-terminated state

```

EDIT:

The above error may not be one of concern as I dig into it, but I’m still not able to get parallel steps to work.

---

<div class="post-metadata">

**Author:** ![andrewrynhard](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/andrewrynhard/32/5756_2.png) [@andrewrynhard](https://drone.discourse.group/u/andrewrynhard)\
**Post date:** [April 23, 2020, 1:56am UTC](https://drone.discourse.group/t/parallel-steps-in-kubernetes-runner/7656/4 "2020-04-23T01:56:27Z")

</div>

it looks like steps finish successfully by looking at the logs, but the step is red: [https://ci.dev.talos-systems.io/talos-systems/talos/8551/1/16](https://ci.dev.talos-systems.io/talos-systems/talos/8551/1/16)

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [April 23, 2020, 4:02pm UTC](https://drone.discourse.group/t/parallel-steps-in-kubernetes-runner/7656/5 "2020-04-23T16:02:34Z")

</div>

I took a look at the raw request and I see the code returns an exit code of 2  
[https://ci.dev.talos-systems.io/api/repos/talos-systems/talos/builds/8551](https://ci.dev.talos-systems.io/api/repos/talos-systems/talos/builds/8551)

This means the step is definitely failing and the step should be red. Is it possible your make command (or whatever is running inside the container) is failing silently with an exit code of 2? I can say with certainty that Drone would not assign an exit code of 2 unless it came directly from the kubernetes API.

---

<div class="post-metadata">

**Author:** ![andrewrynhard](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/andrewrynhard/32/5756_2.png) [@andrewrynhard](https://drone.discourse.group/u/andrewrynhard)\
**Post date:** [April 23, 2020, 9:14pm UTC](https://drone.discourse.group/t/parallel-steps-in-kubernetes-runner/7656/6 "2020-04-23T21:14:21Z")

</div>

All I can add to this is that this exact same pipeline/step works when we use the deprecated built in kubernetes runner. Also, the failures seem to be random. For example, the `talos-local` step fails here: [https://ci.dev.talos-systems.io/talos-systems/talos/8550/1/14](https://ci.dev.talos-systems.io/talos-systems/talos/8550/1/14). Strange thing is that [https://ci.dev.talos-systems.io/api/repos/talos-systems/talos/builds/8551](https://ci.dev.talos-systems.io/api/repos/talos-systems/talos/builds/8551) says it was skipped. Again, this all works when using the baked in k8s runner. Here is our last successful run, with the same exact pipeline, except without `type: kubernetes`: [https://ci.dev.talos-systems.io/talos-systems/talos/8530](https://ci.dev.talos-systems.io/talos-systems/talos/8530)

EDIT:

I ran the markdown lint step locally, and it is indeed failing. Will fix that and try again. Regardless, in some cases it is green and some it is not. Something feels off with the reporting of the success of a step.

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [April 24, 2020, 12:47am UTC](https://drone.discourse.group/t/parallel-steps-in-kubernetes-runner/7656/7 "2020-04-24T00:47:55Z")

</div>

Are you sure the step can be parallelized? Perhaps there is a race condition where the step is reading or writing files that are also being accessed by another step. This could explain why the failures would be random …

But let’s step back for a moment and consider the following …

IF we assume:

1. Drone creates a standard Kubernetes Pod and
2. Each step is a standard Kubernetes container and
3. Your commands are a simple bash script (as shown [here](https://docs.drone.io/pipeline/kubernetes/syntax/steps/#commands)) and
4. the bash script is the container entrypoint and
5. Drone gets the exit code directly from Kubernetes

Then: How could Drone cause a container to fail or return the wrong exit code?

As a next step, I would recommend that you triage the code and try to find the root cause (bonus points for sending a patch). Since you are able to reproduce the issue (albeit infrequently) you would be in the best position to debug the problem. You can find the relevant code at [https://github.com/drone-runners/drone-runner-kube/blob/master/engine/engine\_impl.go](https://github.com/drone-runners/drone-runner-kube/blob/master/engine/engine_impl.go)

---

<div class="post-metadata">

**Author:** ![andrewrynhard](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/andrewrynhard/32/5756_2.png) [@andrewrynhard](https://drone.discourse.group/u/andrewrynhard)\
**Post date:** [April 27, 2020, 5:20am UTC](https://drone.discourse.group/t/parallel-steps-in-kubernetes-runner/7656/8 "2020-04-27T05:20:36Z")

</div>

I’m absolutely certain the step can be parallelized. Again, this pipeline has been working for months. The only thing that has changed is the Kubernetes runner. Take [https://ci.dev.talos-systems.io/api/repos/talos-systems/talos/builds/8613](https://ci.dev.talos-systems.io/api/repos/talos-systems/talos/builds/8613) as an example. This PR fails randomly. I can reproduce this more than infrequently. In fact it has happened 5 times out of the last 6 runs. Each time, a different step has failed (see 8610, 8611, and 8614), each time a different stable fails, and nothing as to indicate _why_ (no logs for most).

[https://ci.dev.talos-systems.io/api/repos/talos-systems/talos/builds/8614](https://ci.dev.talos-systems.io/api/repos/talos-systems/talos/builds/8614) is interesting because the `setup-ci` logs look perfectly fine, yet the exit code is 2, and also at this point there is no parallelization. Everything after `setup-ci` depends on it. Similarly [https://ci.dev.talos-systems.io/talos-systems/talos/8615/1/8](https://ci.dev.talos-systems.io/talos-systems/talos/8615/1/8) shows logs that look normal, yet the exit code 2.

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [April 27, 2020, 12:53pm UTC](https://drone.discourse.group/t/parallel-steps-in-kubernetes-runner/7656/9 "2020-04-27T12:53:58Z")

</div>

If you believe this is an issue with the kubernetes runner, the next step is for you to debug the code and submit a patch to [drone-runners/drone-runner-kube](https://github.com/drone-runners/drone-runner-kube). We provide [this guide](http://discuss.harness.io/t/contributing-to-drone-for-kubernetes/3159) to contributing to the kubernetes runner.

---

<div class="post-metadata">

**Author:** ![andrewrynhard](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/andrewrynhard/32/5756_2.png) [@andrewrynhard](https://drone.discourse.group/u/andrewrynhard)\
**Post date:** [July 27, 2020, 2:44pm UTC](https://drone.discourse.group/t/parallel-steps-in-kubernetes-runner/7656/10 "2020-07-27T14:44:48Z")

</div>

@bradrydzewski Looks like [Kubernetes runner intermittently fails steps](http://discuss.harness.io/t/kubernetes-runner-intermittently-fails-steps/7372/5) is exactly what I am seeing. We can close this.
