Skip to content

Commit a6650e0

Browse files
Force debug, better error handle
1 parent 9ee0d14 commit a6650e0

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

scripts/aws/ec2.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import yaml
1717

1818
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
19-
from confidential_compute import ConfidentialCompute, ConfidentialComputeConfig, SecretNotFoundException
19+
from confidential_compute import ConfidentialCompute, ConfidentialComputeConfig, SecretNotFoundException, ConfidentialComputeStartupException
2020

2121
class AWSConfidentialComputeConfig(ConfidentialComputeConfig):
2222
enclave_memory_mb: int
@@ -100,8 +100,7 @@ def add_defaults(configs: Dict[str, any]) -> AWSConfidentialComputeConfig:
100100
try:
101101
client = boto3.client("secretsmanager", region_name=region)
102102
except Exception as e:
103-
# MissingInstanceProfile
104-
raise RuntimeError("Please use IAM instance profile for your instance and make sure that has permission to access Secret Manager")
103+
raise RuntimeError("Please use IAM instance profile for your instance and make sure that has permission to access Secret Manager", e)
105104
try:
106105
secret = add_defaults(json.loads(client.get_secret_value(SecretId=secret_identifier)["SecretString"]))
107106
self.__validate_aws_specific_config(secret)
@@ -204,7 +203,7 @@ def __run_nitro_enclave(self):
204203
"--enclave-cid", "42",
205204
"--enclave-name", "uid2operator"
206205
]
207-
if self.configs["debug_mode"]:
206+
if self.configs('debug_mode', True): #E2E override
208207
print("Running in debug_mode")
209208
command += ["--debug-mode", "--attach-console"]
210209
self.run_command(command)
@@ -247,12 +246,14 @@ def __kill_auxiliaries(self) -> None:
247246
parser = argparse.ArgumentParser(description="Manage EC2-based confidential compute workflows.")
248247
parser.add_argument("-o", "--operation", choices=["stop", "start"], default="start", help="Operation to perform.")
249248
args = parser.parse_args()
250-
ec2 = EC2()
251249
try:
250+
ec2 = EC2()
252251
if args.operation == "stop":
253252
ec2.cleanup()
254253
else:
255254
ec2.run_compute()
255+
except ConfidentialComputeStartupException as e:
256+
print("Failed starting up Confidential Compute. Please find the error code and documentation", e)
256257
except Exception as e:
257-
print("Failed starting up Confidential Compute. Please contact uid2", e)
258+
print("Unknown failure while starting up Confidential Compute. Please contact UID support team with this log", e)
258259

scripts/confidential_compute.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,20 @@ def run_command(command, seperate_process=False):
122122
except Exception as e:
123123
print(f"Failed to run command: {str(e)}")
124124
raise RuntimeError (f"Failed to start {' '.join(command)} ")
125+
126+
class ConfidentialComputeStartupException(Exception):
127+
def __init__(self, message):
128+
super().__init__(message)
125129

126-
class MissingConfigError(Exception):
130+
class MissingConfigError(ConfidentialComputeStartupException):
127131
"""Custom exception to handle missing config keys."""
128132
def __init__(self, missing_keys):
129133
self.missing_keys = missing_keys
130134
self.message = f"\n Missing configuration keys: {', '.join(missing_keys)} \n"
131135
super().__init__(self.message)
132136

133-
class SecretNotFoundException(Exception):
137+
class SecretNotFoundException(ConfidentialComputeStartupException):
134138
"""Custom exception if secret manager is not found"""
135139
def __init__(self, name):
136-
self.message = f"Secret manager not found - {name}"
140+
self.message = f"Secret manager not found - {name}. Please check if secret exist and the Instance Profile has permission to read it"
137141
super().__init__(self.message)

0 commit comments

Comments
 (0)