Fix scale-out in the multi-site replication scenario

If the multi-site relation is established, the `ceph-radosgw` application
cannot be scaled out.

This is happening because the multi-site functions are part of
`check_optional_config_and_relations`, which is called by `assess_status`
after every successful hook in the main hook entrypoint:
```
if __name__ == '__main__':
    try:
        hooks.execute(sys.argv)
    except UnregisteredHookError as e:
        log('Unknown hook {} - skipping.'.format(e))
    except ValueError as e:
        # Handle any invalid configuration values
        status_set(WORKLOAD_STATES.BLOCKED, str(e))
    else:
        assess_status(CONFIGS)
```

The multi-site functions (for example: `is_multisite_configured` or
`check_cluster_has_buckets`) will fail since the unit is not be ready
for service.

This change ensures that the unit is ready for service before calling
any multi-site functions.

Closes-Bug: #2062405
Change-Id: I63c21a0b545bb456df9b09d8c16cc43cd7eec2f3
Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
This commit is contained in:
Ionut Balutoiu 2023-10-19 13:40:26 +03:00
parent 6f2a7540e8
commit 1cac43fadc
1 changed files with 6 additions and 4 deletions

View File

@ -246,8 +246,9 @@ def check_optional_config_and_relations(configs):
# Primary site status check
if primary_rids:
# Migration: The system is not multisite already.
if not multisite.is_multisite_configured(config('zone'),
config('zonegroup')):
if (ready_for_service(legacy=False) and
not multisite.is_multisite_configured(config('zone'),
config('zonegroup'))):
if multisite.check_cluster_has_buckets():
zones, zonegroups = get_zones_zonegroups()
status_msg = "Multiple zone or zonegroup configured, " \
@ -271,8 +272,9 @@ def check_optional_config_and_relations(configs):
# Secondary site status check
if secondary_rids:
# Migration: The system is not multisite already.
if not multisite.is_multisite_configured(config('zone'),
config('zonegroup')):
if (ready_for_service(legacy=False) and
not multisite.is_multisite_configured(config('zone'),
config('zonegroup'))):
if multisite.check_cluster_has_buckets():
return ('blocked',
"Non-Pristine RGW site can't be used as secondary")