Beispiel #1
0
    def get(self):
        """End point for health checks"""
        resp = {'redis': {}, 'auth_api': {}, 'ldap': {}}
        status = 200
        redis_stime = time()
        try:
            r = StrictRedis(host=const.AUTH_REDIS_HOSTNAME,
                            port=const.AUTH_REDIS_PORT)
            r.config_get('*')
        except RedisError as doh:
            resp['redis']['msg'] = '%s' % doh
            status = 500
        else:
            resp['redis']['msg'] = 'OK'
        resp['redis']['latency'] = time() - redis_stime

        ldap_stime = time()
        try:
            server = ldap3.Server(const.AUTH_LDAP_URL, get_info=None)
            conn = ldap3.Connection(server, auto_bind=True)
        except LDAPException as derp:
            resp['ldap']['msg'] = '%s' % derp
            status = 500
        else:
            resp['ldap']['msg'] = 'OK'
            conn.unbind()
        resp['ldap']['latency'] = time() - ldap_stime

        resp['auth_api']['version'] = pkg_resources.get_distribution(
            'vlab-auth-service').version
        response = Response(ujson.dumps(resp))
        response.status_code = status
        response.headers['Content-Type'] = 'application/json'
        return response
Beispiel #2
0
def _rewrite_redis_aof(veil_server=None):
    current_veil_env = get_current_veil_env()
    if not hasattr(current_veil_env.config, 'redis_servers'):
        return False
    requested = False
    for host, port in current_veil_env.config.redis_servers:
        if veil_server and veil_server.internal_ip != host:
            continue
        try:
            client = StrictRedis(host=host, port=port)
            if client.config_get('appendonly')['appendonly'] != 'yes':
                continue
            LOGGER.info('request for redis aof rewrite <%(host)s:%(port)s>', {
                'host': host,
                'port': port
            })
            client.bgrewriteaof()
            requested = True
        except Exception as e:
            if 'append only file rewriting already in progress' not in e.message:
                requested = True
                LOGGER.exception(
                    'Exception thrown while requesting for redis aof rewrite <%(host)s:%(port)s>',
                    {
                        'host': host,
                        'port': port
                    })
    return requested
def dynamic_encoding_switch(instance: redis.StrictRedis):
    emptyDB(instance)
    hash_max_ziplist_entiries = instance.config_get("hash-max-ziplist-entries")
    print(hash_max_ziplist_entiries)

    for i in range(515):
        instance.hset("test-hash", i, 1)

        if i > 510:
            debug = instance.debug_object("test-hash")
            print("Count: {} Length: {} Enconding: {}".format(
                i, debug.get('serializedlength'), debug.get('encoding')))