diff --git a/kafka_server/coordinator/api/broker/api.py b/kafka_server/coordinator/api/broker/api.py index a0d1556..2e5ffb9 100644 --- a/kafka_server/coordinator/api/broker/api.py +++ b/kafka_server/coordinator/api/broker/api.py @@ -2,7 +2,7 @@ import json import os import sys -import random +from random import SystemRandom COORDINATOR_PROJECT_PATH = os.getenv("COORDINATOR_PROJECT_PATH", "/app/") sys.path.append(os.path.abspath(COORDINATOR_PROJECT_PATH)) @@ -13,7 +13,7 @@ api_blueprint = Blueprint('api', __name__) - +cryptogen = SystemRandom() @api_blueprint.route('/init', methods=['GET']) def init_broker(): @@ -35,7 +35,7 @@ def init_broker(): replica_url = None if broker_id not in all_brokers_replicas: keys = all_brokers.keys() - key = random.choice(list(keys)) + key = cryptogen.choice(list(keys)) replica_url = all_brokers[key] response_code = broker_database.add_replica_for_broker(broker_id, replica_url) if response_code != 200: diff --git a/kafka_server/coordinator_database/main.py b/kafka_server/coordinator_database/main.py index 738a636..0e00121 100644 --- a/kafka_server/coordinator_database/main.py +++ b/kafka_server/coordinator_database/main.py @@ -50,7 +50,7 @@ def delete_broker(): broker_id = data['broker_id'] with concurrent.futures.ThreadPoolExecutor() as executor: future = executor.submit(broker.delete_broker, broker_id) - result = future.result() + _ = future.result() return jsonify("Successfully deleted")