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? predicates
  • in_read_only_states scope, transition events, and read_only_reason metadata key
  • organization_read_only_enforcement feature flag -> organization_maintenance_enforcement
  • Specs, shared examples, and the generated GraphQL reference and introspection schema
  • in_read_only_states scope 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

How to set up and validate locally

This is a rename refactor behind a default-off feature flag; no behavior changes. Validate with:

  1. bundle exec rspec spec/models/concerns/organizations/stateful_spec.rb
  2. bundle 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)
  end

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist.

Edited by Abdul Wadood

Merge request reports

Loading
Loading