Rename Organization read_only states to maintenance
What does this MR do and why?
Renames the Organization read_only* states to maintenance* so the code
matches ADR https://handbook.gitlab.com/handbook/engineering/architecture/design-documents/organization/decisions/010_organization_maintenance_mode/, which was renamed from "Organization Read-Only Mode" to
"Organization Maintenance Mode". The initial iteration blocks all requests
(reads included), so "read-only" no longer described the behavior.
Scope, in app/models/concerns/organizations/stateful.rb and its call sites:
- Enum states
read_only_initialization/read_only->maintenance_initialization/maintenance READ_ONLY_STATES/READ_ONLY_REASONS/TIME_BOUNDED_READ_ONLY_REASONS/READ_ONLY_BLOCKED_STATES->MAINTENANCE_*read_only?/read_only_message/read_only_time_bounded?/read_only_enforced?predicatesin_read_only_statesscope, transition events, andread_only_reasonmetadata keyorganization_read_only_enforcementfeature flag ->organization_maintenance_enforcement- Specs, shared examples, and the generated GraphQL reference and introspection schema
in_read_only_statesscope is removed as it's unused
The enum is integer-backed and no organization has entered these states in
production, so the maintenance_reason metadata key is renamed without a
data migration.
References
- Closes #614066 (closed)
- Stacked on https://gitlab.com/gitlab-org/gitlab/-/tree/607966-block-all-requests-read-only-org
How to set up and validate locally
This is a rename refactor behind a default-off feature flag; no behavior changes. Validate with:
bundle exec rspec spec/models/concerns/organizations/stateful_spec.rbbundle exec rspec spec/lib/gitlab/git_access_organization_maintenance_spec.rb
Migrating read-only records to maintenance
Run the following in the Rails console:
Organizations::OrganizationDetail
.where("state_metadata ? 'read_only_reason'")
.find_each do |detail|
detail.state_metadata['maintenance_reason'] = detail.state_metadata.delete('read_only_reason')
detail.save!(validate: false)
endMR acceptance checklist
Evaluate this MR against the MR acceptance checklist.