Esempio n. 1
0
def _update_db_proxy(db_name, datastore_name, datastore_ro_name, db_password,
                     datastore_password, datastore_ro_password):
    logs.info('Updating db proxy')
    db_proxy_manager.update(wait_updated=False)
    ok = False
    for i in range(5):
        try:
            for user, password, db in [
                (db_name, db_password, db_name),
                (datastore_name, datastore_password, datastore_name),
                (datastore_ro_name, datastore_ro_password, datastore_name)
            ]:
                if user:
                    db_manager.check_connection_string(
                        db_manager.get_external_connection_string(
                            user, password, db))
            ok = True
            break
        except Exception as e:
            logs.warning(str(e))
        logs.info(f'Waiting for connection to db proxy...')
        # 40 seconds on first iteration - to ensure secret is updated in pgbouncer volume
        time.sleep(40 if i == 0 else 1)
        db_proxy_manager.reload()
        time.sleep(10 if i == 2 else 5)
    assert ok, 'failed to get connection to db proxy'
    yield {
        'step':
        'update-db-proxy',
        'msg':
        f'Updated DB Proxy with the new dbs and roles: {db_name}, {datastore_name}, {datastore_ro_name}'
    }
Esempio n. 2
0
def update():
    db_proxy_manager.update()