Enable Organization presence validation for update templates rake task
What does this MR do and why?
In !155732 (merged), we added validation for presence of an Organization on Namespaces. Since this MR was already quite big and impactful, most 'Create Namespace' code paths are wrapped in a Namespace.with_disabled_organization_validation
method, which caused the validation to be skipped.
This MR will enable the validation for the gitlab:update_project_templates
rake task.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
- In rails console enable these feature flags:
Feature.enable(:require_organization) && Feature.enable(:allow_organization_creation)
- Run the rake rask:
bundle exec rake gitlab:update_project_templates
I paused the execution of the script on line 68 because the script did not work locally: the git commands did not work. But using byebug
, I was able to verify that the namespace and the project records had the correct Organization ID:
[65, 74] in /Users/rutger/gitlab-development-kit/gitlab/lib/tasks/gitlab/update_templates.rake
65: unless project.persisted?
66: raise "Failed to create project: #{project.errors.messages}"
67: end
68:
69: byebug
=> 70: uri_encoded_project_path = template.uri_encoded_project_path
71:
72: # extract a concrete commit for signing off what we actually downloaded
73: # this way we do the right thing even if the repository gets updated in the meantime
74: get_commits_response = Gitlab::HTTP.get("#{template.project_host}/api/v4/projects/#{uri_encoded_project_path}/repository/commits",
(byebug) tmp_organization.id
1002654
(byebug) project.organization.id
1002654
(byebug) tmp_namespace.organization.id
1002654
(byebug)
No errors should be raised.
Related to #411832 (closed)