Move CreateDeployments out of the pipeline creation critical path
Problem
When looking at the p99 for the pipeline creation duration across all projects at GitLab (https://log.gprd.gitlab.net/goto/23c87560-6b57-11ed-9f43-e3784d7fe3ca) we can see that up to 10% of the time is spent in CreateDeployments
step.
Looking at the CreateDeployments
step, it creates deployments for each build in the pipeline, when an environment is specified.
Is this something we can defer to when builds actually need to run?
Proposal
As per motivations in #383600 (comment 1185384822) we could move the logic to InitialPipelineProcessWorker
so we can ensure we create deployments before a pipeline is processed.
NOTE: This improvement won't affect much the performance of gitlab-org/gitlab
pipelines.
Edited by Fabio Pitino