From 12eb4f9aac7fd29f90c158bfa2715a5e2ef58497 Mon Sep 17 00:00:00 2001 From: Eduardo Date: Tue, 21 Jan 2025 10:21:42 -0300 Subject: [PATCH] fix: the return value in retrieve allocation key error case. --- neurons/Miner/container.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/neurons/Miner/container.py b/neurons/Miner/container.py index ead01397..4ce1d3f2 100644 --- a/neurons/Miner/container.py +++ b/neurons/Miner/container.py @@ -385,11 +385,14 @@ def retrieve_allocation_key(): return allocation_key except Exception as e: bt.logging.info(f"Error retrieving allocation key.") - return "" + return None def restart_container(public_key:str): try: allocation_key = retrieve_allocation_key() + if allocation_key is None: + bt.logging.info("Failed to retrieve allocation key.") + return {"status": False} # compare public_key to the local saved allocation key for security if allocation_key.strip() == public_key.strip(): client, containers = get_docker() @@ -418,6 +421,9 @@ def restart_container(public_key:str): def pause_container(public_key:str): try: allocation_key = retrieve_allocation_key() + if allocation_key is None: + bt.logging.info("Failed to retrieve allocation key.") + return {"status": False} # compare public_key to the local saved allocation key for security if allocation_key.strip() == public_key.strip(): client, containers = get_docker() @@ -442,6 +448,9 @@ def pause_container(public_key:str): def unpause_container(public_key:str): try: allocation_key = retrieve_allocation_key() + if allocation_key is None: + bt.logging.info("Failed to retrieve allocation key.") + return {"status": False} # compare public_key to the local saved allocation key for security if allocation_key.strip() == public_key.strip(): client, containers = get_docker() @@ -466,6 +475,9 @@ def unpause_container(public_key:str): def exchange_key_container(new_ssh_key: str, public_key: str, key_type: str = "user" ): try: allocation_key = retrieve_allocation_key() + if allocation_key is None: + bt.logging.info("Failed to retrieve allocation key.") + return {"status": False} # compare public_key to the local saved allocation key for security if allocation_key.strip() == public_key.strip(): client, containers = get_docker()