src/rgw/setup/rgw.py
def _get_lock(consul_idx: str):
        """Get lock from consul kv."""
        # if in case try-catch block code executed at the same time on all the nodes,
        # then all nodes will try to update rgw lock-key in consul, after updating key
        # it will wait for sometime(time.sleep(3)) and in next iteration all nodes will
        # get lock value as node-id of node who has updated the lock key at last.
        # and then only that node will perform the user creation operation.
        rgw_lock = False
        while True:
            try:
                rgw_lock_val = Conf.get(consul_idx, const.CONSUL_LOCK_KEY)
                Log.info(f'{const.CONSUL_LOCK_KEY} value - {rgw_lock_val}')
                if rgw_lock_val is None:
                    Log.info(f'Setting consul kv store value for key :{const.CONSUL_LOCK_KEY}'
                            f' and value as :{Rgw._machine_id}')
                    Rgw._set_consul_kv(consul_idx, const.CONSUL_LOCK_KEY, Rgw._machine_id)
                    continue
                elif rgw_lock_val == Rgw._machine_id:
                    Log.info('Required lock already possessed, proceeding with RGW '
                        f'admin user creation on node {rgw_lock_val}')
                    rgw_lock = True
                    break
                elif rgw_lock_val != Rgw._machine_id:
                    if rgw_lock_val == const.ADMIN_USER_CREATED:
                        Log.info('User is already created.')
                        break
                    Log.info(f'RGW lock is acquired by "{rgw_lock_val}" node.')
                    Log.info(f'Waiting for user creation to complete on "{rgw_lock_val}" node')
                    time.sleep(3)
                    continue

            except Exception as e:
                Log.error('Exception occured while connecting to consul service'
                          f' endpoint {e}')
                break
        return rgw_lock
Get lock from consul kv.
Get lock from consul kv.
Get lock from consul kv .
def _get_lock(consul_idx: str):
        rgw_lock = False
        while True:
            try:
                rgw_lock_val = Conf.get(consul_idx, const.CONSUL_LOCK_KEY)
                Log.info(f'{const.CONSUL_LOCK_KEY} value - {rgw_lock_val}')
                if rgw_lock_val is None:
                    Log.info(f'Setting consul kv store value for key :{const.CONSUL_LOCK_KEY}'
                            f' and value as :{Rgw._machine_id}')
                    Rgw._set_consul_kv(consul_idx, const.CONSUL_LOCK_KEY, Rgw._machine_id)
                    continue
                elif rgw_lock_val == Rgw._machine_id:
                    Log.info('Required lock already possessed, proceeding with RGW '
                        f'admin user creation on node {rgw_lock_val}')
                    rgw_lock = True
                    break
                elif rgw_lock_val != Rgw._machine_id:
                    if rgw_lock_val == const.ADMIN_USER_CREATED:
                        Log.info('User is already created.')
                        break
                    Log.info(f'RGW lock is acquired by "{rgw_lock_val}" node.')
                    Log.info(f'Waiting for user creation to complete on "{rgw_lock_val}" node')
                    time.sleep(3)
                    continue
            except Exception as e:
                Log.error('Exception occured while connecting to consul service'
                          f' endpoint {e}')
                break
        return rgw_lock
def _get_lock ( consul_idx : str ) : rgw_lock = False while True : try : rgw_lock_val = Conf . get ( consul_idx , const . CONSUL_LOCK_KEY ) Log . info ( f'{const.CONSUL_LOCK_KEY} value - {rgw_lock_val}' ) if rgw_lock_val is None : Log . info ( f'Setting consul kv store value for key :{const.CONSUL_LOCK_KEY}' f' and value as :{Rgw._machine_id}' ) Rgw . _set_consul_kv ( consul_idx , const . CONSUL_LOCK_KEY , Rgw . _machine_id ) continue elif rgw_lock_val == Rgw . _machine_id : Log . info ( 'Required lock already possessed, proceeding with RGW ' f'admin user creation on node {rgw_lock_val}' ) rgw_lock = True break elif rgw_lock_val != Rgw . _machine_id : if rgw_lock_val == const . ADMIN_USER_CREATED : Log . info ( 'User is already created.' ) break Log . info ( f'RGW lock is acquired by "{rgw_lock_val}" node.' ) Log . info ( f'Waiting for user creation to complete on "{rgw_lock_val}" node' ) time . sleep ( 3 ) continue except Exception as e : Log . error ( 'Exception occured while connecting to consul service' f' endpoint {e}' ) break return rgw_lock
Get lock from consul kv.
Get lock from consul kv .
"""Get lock from consul kv.""" # if in case try-catch block code executed at the same time on all the nodes, # then all nodes will try to update rgw lock-key in consul, after updating key # it will wait for sometime(time.sleep(3)) and in next iteration all nodes will # get lock value as node-id of node who has updated the lock key at last. # and then only that node will perform the user creation operation.
consul_idx
str