From 5e08061cd6b4a5bc28aae0c1754ca1f4d1f15aea Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Sun, 16 Oct 2022 20:33:31 +0200 Subject: [PATCH] Factor out garage-entrypoint The daemon entrypoint now starts the garage child processes directly, without the extra step of indirection --- docs/dev/daemon-process-tree.plantuml | 22 +- docs/dev/daemon-process-tree.svg | 46 ++-- go-workspace/src/cmd/cryptic-net-main/main.go | 2 - go-workspace/src/cmd/entrypoint/daemon.go | 213 +++--------------- .../src/cmd/entrypoint/daemon_util.go | 205 +++++++++++++++++ go-workspace/src/cmd/entrypoint/daemon_yml.go | 72 ++++++ .../src/cmd/garage-entrypoint/main.go | 129 ----------- 7 files changed, 341 insertions(+), 348 deletions(-) create mode 100644 go-workspace/src/cmd/entrypoint/daemon_util.go create mode 100644 go-workspace/src/cmd/entrypoint/daemon_yml.go delete mode 100644 go-workspace/src/cmd/garage-entrypoint/main.go diff --git a/docs/dev/daemon-process-tree.plantuml b/docs/dev/daemon-process-tree.plantuml index c2c9462..4e1c38d 100644 --- a/docs/dev/daemon-process-tree.plantuml +++ b/docs/dev/daemon-process-tree.plantuml @@ -17,6 +17,7 @@ state AppDir { entrypoint : * Merge given and default daemon.yml files entrypoint : * Copy bootstrap.tgz into $_DATA_DIR_PATH, if it's not there entrypoint : * Merge daemon.yml config into bootstrap.tgz + entrypoint : * Create $_RUNTIME_DIR_PATH/garage-N.toml\n (one per storage allocation) entrypoint : * Run child processes } @@ -41,20 +42,17 @@ state AppDir { entrypoint --> nebulaEntrypoint : child nebulaEntrypoint --> nebula : exec - state "./bin/cryptic-net-main garage-entrypoint" as garageEntrypoint { - garageEntrypoint : * Create $_RUNTIME_DIR_PATH/garage-N.toml\n (one per storage allocation) - garageEntrypoint : * Run child processes + state "Garage processes (only if any storage allocs are defined)" as garageChildren { + + state "./bin/garage -c $_RUNTIME_DIR_PATH/garage-N.toml server" as garage + state "./bin/garage-apply-layout-diff" as garageApplyLayoutDiff { + garageApplyLayoutDiff : * Runs once then exits + garageApplyLayoutDiff : * Updates cluster topo + } } - state "./bin/garage -c $_RUNTIME_DIR_PATH/garage-N.toml server" as garage - state "./bin/garage-apply-layout-diff" as garageApplyLayoutDiff { - garageApplyLayoutDiff : * Runs once then exits - garageApplyLayoutDiff : * Updates cluster topo - } - - entrypoint --> garageEntrypoint : child (only if >1 storage allocation defined in daemon.yml) - garageEntrypoint --> garage : child (one per storage allocation) - garageEntrypoint --> garageApplyLayoutDiff : child + entrypoint --> garage : child (one per storage allocation) + entrypoint --> garageApplyLayoutDiff : child state "./bin/cryptic-net-main update-global-bucket" as updateGlobalBucket { updateGlobalBucket : * Runs once then exits diff --git a/docs/dev/daemon-process-tree.svg b/docs/dev/daemon-process-tree.svg index d5974a3..f673f0d 100644 --- a/docs/dev/daemon-process-tree.svg +++ b/docs/dev/daemon-process-tree.svg @@ -1,15 +1,15 @@ -AppDirAll relative paths are relative to the root of the AppDir./bin/dnsmasq -d -C $_RUNTIME_DIR_PATH/dnsmasq.conf./bin/nebula -config $_RUNTIME_DIR_PATH/nebula.yml./bin/garage -c $_RUNTIME_DIR_PATH/garage-N.toml server./AppRunSet PATH to APPDIR/bin./bin/cryptic-net-main entrypoint daemon -c ./daemon.ymlCreate runtime dir at $_RUNTIME_DIR_PATHLock runtime dirMerge given and default daemon.yml filesCopy bootstrap.tgz into $_DATA_DIR_PATH, if it's not thereMerge daemon.yml config into bootstrap.tgzRun child processes./bin/dnsmasq-entrypointCreate $_RUNTIME_DIR_PATH/dnsmasq.conf./bin/cryptic-net-main nebula-entrypointCreate $_RUNTIME_DIR_PATH/nebula.yml./bin/cryptic-net-main garage-entrypointCreate $_RUNTIME_DIR_PATH/garage-N.toml(one per storage allocation)Run child processes./bin/garage-apply-layout-diffRuns once then exitsUpdates cluster topo./bin/cryptic-net-main update-global-bucketRuns once then exitsUpdates the bootstrap data for the host in garage for other hosts to query./cryptic-net daemon -c ./daemon.ymlexecexecchildexecchildexecchild (only if >1 storage allocation defined in daemon.yml)child (one per storage allocation)childchildAppDirGarage processes (only if any storage allocs are defined)All relative paths are relative to the root of the AppDir./bin/dnsmasq -d -C $_RUNTIME_DIR_PATH/dnsmasq.conf./bin/nebula -config $_RUNTIME_DIR_PATH/nebula.yml./AppRunSet PATH to APPDIR/bin./bin/cryptic-net-main entrypoint daemon -c ./daemon.ymlCreate runtime dir at $_RUNTIME_DIR_PATHLock runtime dirMerge given and default daemon.yml filesCopy bootstrap.tgz into $_DATA_DIR_PATH, if it's not thereMerge daemon.yml config into bootstrap.tgzCreate $_RUNTIME_DIR_PATH/garage-N.toml(one per storage allocation)Run child processes./bin/dnsmasq-entrypointCreate $_RUNTIME_DIR_PATH/dnsmasq.conf./bin/cryptic-net-main nebula-entrypointCreate $_RUNTIME_DIR_PATH/nebula.yml./bin/cryptic-net-main update-global-bucketRuns once then exitsUpdates the bootstrap data for the host in garage for other hosts to query./bin/garage -c $_RUNTIME_DIR_PATH/garage-N.toml server./bin/garage-apply-layout-diffRuns once then exitsUpdates cluster topo./cryptic-net daemon -c ./daemon.ymlexecexecchildexecchildexecchild (one per storage allocation)childchild