Skip to content

Commit

Permalink
edb-connect: fix edb default host and allow caller to set it (#2214)
Browse files Browse the repository at this point in the history
  • Loading branch information
BedrockSquirrel authored Dec 18, 2024
1 parent ea3bf07 commit 6328e9a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 3 additions & 2 deletions tools/edbconnect/edb-connect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
14 changes: 12 additions & 2 deletions tools/edbconnect/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ import (
)

func main() {
// get edbHost from first command line arg
var edbHost string
if len(os.Args) > 1 {
edbHost = os.Args[1]
} else {
fmt.Println("Usage: edbconnect <edb-host>")
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...")
creds, found, err := edgelessdb.LoadCredentialsFromFile()
if err != nil {
Expand All @@ -29,9 +39,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.")
Expand Down

0 comments on commit 6328e9a

Please sign in to comment.