refactor: make management controller able to create project namespaces again #1482
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since #1431 we rely on a webhook to create Project namespaces synchronously. Although this was a valid decision made for well-documented reasons, one undesired side-effect has been difficulty bootstraping Kargo with a default Project already in place:
If the Project is applied before the webhook registration, Project creation succeeds, but creation of the underlying namespace does not take place. If the manifests contain additional resources that belong in that namespace, their creation will fail.
If the webhook registration is applied before the Project, Project creation will fail since the webhook server isn't running yet. Creation of the underlying namespace does not take place and, as above, if the manifests contain additional resources that belong in that namespace, their creation will fail.
Some unsatisfactory solutions we explored included:
Ensuring the webhook server is ready before attempting to create the Project.
This was deemed to be difficult, or at least annoying.
"Create projects the hard way" by directly creating an appropriately labeled namespace.
This loses out on the benefits of having a Project resource. Those aren't significant now, but will be of increasing consequence over time.
We settled on partially rolling back #1431, allowing for a Project's underlying namespace to be created synchronously by a webhook or asynchronously by the management controller. This ability enables a better option:
cc @gdsoumya