From a50c14f83bacf1d9ff3ce64ff33d3824457174bd Mon Sep 17 00:00:00 2001 From: Matt Curtis Date: Wed, 18 Dec 2024 10:30:04 +0000 Subject: [PATCH 1/2] edb-connect: fix edb default host and allow caller to set it --- tools/edbconnect/main/main.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/edbconnect/main/main.go b/tools/edbconnect/main/main.go index 42b2c265b8..eaa5caa3ec 100644 --- a/tools/edbconnect/main/main.go +++ b/tools/edbconnect/main/main.go @@ -12,6 +12,12 @@ import ( ) func main() { + // optionally set edbHost from cli flag, default to obscuronode-edgelessdb-0 + edbHost := "obscuronode-edgelessdb-0" + if len(os.Args) > 1 { + edbHost = os.Args[1] + } + fmt.Println("Retrieving Edgeless DB credentials...") creds, found, err := edgelessdb.LoadCredentialsFromFile() if err != nil { @@ -29,9 +35,9 @@ func main() { } fmt.Println("TLS config created. Connecting to Edgeless DB...") testlog.SetupSysOut() - db, err := edgelessdb.ConnectToEdgelessDB("obscuronode-edgelessdb", cfg, testlog.Logger()) + db, err := edgelessdb.ConnectToEdgelessDB(edbHost, cfg, testlog.Logger()) if err != nil { - fmt.Println("Error connecting to Edgeless DB:", err) + fmt.Printf("Error connecting to Edgeless DB at %s: %v\n", edbHost, err) panic(err) } fmt.Println("Connected to Edgeless DB.") From fc9799572d9c749af2ab880e6d1712c880b1b3c3 Mon Sep 17 00:00:00 2001 From: Matt Curtis Date: Wed, 18 Dec 2024 10:44:42 +0000 Subject: [PATCH 2/2] require edb-host and volume to be set, update shell script to set the values --- tools/edbconnect/edb-connect.sh | 5 +++-- tools/edbconnect/main/main.go | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/edbconnect/edb-connect.sh b/tools/edbconnect/edb-connect.sh index 37d14c740a..36b0ea2575 100644 --- a/tools/edbconnect/edb-connect.sh +++ b/tools/edbconnect/edb-connect.sh @@ -5,11 +5,12 @@ IMAGE_NAME="testnetobscuronet.azurecr.io/obscuronet/edbconnect:latest" CONTAINER_BASE_NAME="edb-connect" UNIQUE_ID=$(date +%s%3N) # Using milliseconds for uniqueness CONTAINER_NAME="${CONTAINER_BASE_NAME}-${UNIQUE_ID}" -VOLUME_NAME="obscuronode-enclave-volume" +VOLUME_NAME="obscuronode-enclave-volume-0" +DB_HOST="obscuronode-edgelessdb-0" NETWORK_NAME="node_network" SGX_ENCLAVE_DEVICE="/dev/sgx_enclave" SGX_PROVISION_DEVICE="/dev/sgx_provision" -COMMAND="ego run /home/ten/go-ten/tools/edbconnect/main/main" +COMMAND="ego run /home/ten/go-ten/tools/edbconnect/main/main $DB_HOST" # Function to destroy exited containers matching the base name destroy_exited_containers() { diff --git a/tools/edbconnect/main/main.go b/tools/edbconnect/main/main.go index eaa5caa3ec..28f1513a1b 100644 --- a/tools/edbconnect/main/main.go +++ b/tools/edbconnect/main/main.go @@ -12,10 +12,14 @@ import ( ) func main() { - // optionally set edbHost from cli flag, default to obscuronode-edgelessdb-0 - edbHost := "obscuronode-edgelessdb-0" + // get edbHost from first command line arg + var edbHost string if len(os.Args) > 1 { edbHost = os.Args[1] + } else { + fmt.Println("Usage: edbconnect ") + fmt.Println("Ensure you have the latest copy of the ./edb-connect.sh launch script if you see this error.") + os.Exit(1) } fmt.Println("Retrieving Edgeless DB credentials...")