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.
System Info
next-5d98a717ac
Additional context
Validations
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Checked that the bug isn’t fixed in the
nextversion already [https://woodpecker-ci.org/faq#which-version-of-woodpecker-should-i-use]
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 21 (21 by maintainers)
Commits related to this issue
- Temp rename CI services to avoid duplicate name issues (#3497) Workaround for: https://github.com/woodpecker-ci/woodpecker/issues/3494 — committed to woodpecker-ci/woodpecker by xoxys 3 years ago
- rename stepID to workflowID to reflect value address https://github.com/woodpecker-ci/woodpecker/issues/3494#issuecomment-2001986597 — committed to 6543-forks/woodpecker by 6543 3 years ago
- rename stepID to workflowID to reflect value (#3502) address https://github.com/woodpecker-ci/woodpecker/issues/3494#issuecomment-2001986597 — committed to woodpecker-ci/woodpecker by 6543 3 years ago
- Update pipeline state on server as a whole on approval (#3504) We can not just update some records for steps, as we want the pipeline engine as single source of truth but not manage the state. And ... — committed to woodpecker-ci/woodpecker by 6543 3 years ago
@xoxys Makes total sense now. Thanks for investigating it.
It should probably be called
workflowIdinstead ofstepIdin 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.Stepwith new UUID’s and a list ofmodel.Stepfrom 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.Stepas 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…