woodpecker: Duplicate step/service names results in conflicting container names

Component

server

Describe the bug

If a workflow contains multiple steps or services with the same name (one service and one step with the same name is affected as well) it will result in a race condition during the container creation.

image

image image

System Info

next-5d98a717ac

Additional context

caused by https://github.com/woodpecker-ci/woodpecker/pull/2757/files#diff-6f809c0a6ea3b1924d8664a9f0dba9e308c15a5915d6444a18f0cb913809e26aR90

Validations

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 21 (21 by maintainers)

Commits related to this issue

Most upvoted comments

@xoxys Makes total sense now. Thanks for investigating it.

What’s also strange is that it’s called StepID https://github.com/woodpecker-ci/woodpecker/blob/main/server/pipeline/stepbuilder/stepBuilder.go#L289 while the WorkflowID is passed to the method https://github.com/woodpecker-ci/woodpecker/blob/main/server/pipeline/stepbuilder/stepBuilder.go#L166

It should probably be called workflowId instead of stepId in the function as well.

uh now I’m up-to-date with the issue … let me thing I’ll try to come up with a nice solution … and also explain how/why things are done etc …

During the pipeline creation, the Pipeline is stored in the DB. All steps of this pipeline are created and stored with a UUID in the DB as well, and linked to the pipeline. As we don’t store any step information that is required to execute them, the entire pipeline config needs to be parsed again on approval.

At this point, we have a list of backendTypes.Step with new UUID’s and a list of model.Step from the DB with the original UUID’s, but there is no way to map them except by the step names (as done right now) but that is causing this bug.

I also don’t really like the approach, but it should be simple to implement and I have no better idea. Parsing the entire pipeline config twice also has its price, of course, so parsing them only once and temp store them for blocked Pipelines in the DB until the pipeline gets started is IMO a not that bad solution.

I agree, storing backendTypes.Step as JSON in DB looks like a simple way. But it should only be stored for blocked pipeline steps, and we should remove it from the DB on approvals/declines to not blow up the DB. What do you think?

Oh, I see… Thanks.

Sorry that I created these inconveniences, but I didn’t test with steps/services with same name…