def _stop_service(self, container_id): ship = get_ship_name() service_dict = None service_list = kv_list('ships/{}/service/'.format(ship)) if service_list: key = fnmatch.filter(service_list, '*/{}'.format(container_id)) service_dict = kv_get(key[0]) if key else None if service_dict and service_dict['Status'] in ['crashed', 'not-recovered']: kv_remove(key[0]) else: run_command_in_container('supervisorctl stop armada_agent', container_id) # TODO: Compatibility with old microservice images. Should be removed in future armada version. run_command_in_container('supervisorctl stop register_in_service_discovery', container_id) docker_api = docker_client.api() last_exception = None try: deregister_services(container_id) except: traceback.print_exc() for i in range(3): try: docker_api.stop(container_id) kv_remove(key[0]) except Exception as e: last_exception = e traceback.print_exc() if not is_container_running(container_id): break if is_container_running(container_id): get_logger().error('Could not stop container: {}'.format(container_id)) raise last_exception
def _stop_service(self, container_id): docker_api = docker_client.api() last_exception = None try: exec_id = docker_api.exec_create( container_id, 'supervisorctl stop register_in_service_discovery') docker_api.exec_start(exec_id['Id']) except: traceback.print_exc() try: deregister_services(container_id) except: traceback.print_exc() for i in range(3): try: docker_api.stop(container_id) except Exception as e: last_exception = e traceback.print_exc() if not is_container_running(container_id): break if is_container_running(container_id): get_logger().error( 'Could not stop container: {}'.format(container_id)) raise last_exception
def _stop_service(self, container_id): ship = get_ship_name() service_dict = None service_list = kv_list('ships/{}/service/'.format(ship)) if service_list: key = fnmatch.filter(service_list, '*/{}'.format(container_id)) service_dict = kv_get(key[0]) if key else None if service_dict and service_dict['Status'] in [ 'crashed', 'not-recovered' ]: kv_remove(key[0]) else: run_command_in_container('supervisorctl stop armada_agent', container_id) # TODO: Compatibility with old microservice images. Should be removed in future armada version. run_command_in_container( 'supervisorctl stop register_in_service_discovery', container_id) docker_api = docker_client.api() last_exception = None try: deregister_services(container_id) except: traceback.print_exc() for i in range(3): try: docker_api.stop(container_id) kv_remove(key[0]) except Exception as e: last_exception = e traceback.print_exc() if not is_container_running(container_id): break if is_container_running(container_id): get_logger().error( 'Could not stop container: {}'.format(container_id)) raise last_exception
def _stop_service(self, container_id): docker_api = docker_client.api() last_exception = None try: exec_id = docker_api.exec_create(container_id, 'supervisorctl stop register_in_service_discovery') docker_api.exec_start(exec_id['Id']) except: traceback.print_exc() try: deregister_services(container_id) except: traceback.print_exc() for i in range(3): try: docker_api.stop(container_id) except Exception as e: last_exception = e traceback.print_exc() if not is_container_running(container_id): break if is_container_running(container_id): get_logger().error('Could not stop container: {}'.format(container_id)) raise last_exception