diff --git a/docs/dev/daemon-process-tree.plantuml b/docs/dev/daemon-process-tree.plantuml index bac3f61..70dc0b1 100644 --- a/docs/dev/daemon-process-tree.plantuml +++ b/docs/dev/daemon-process-tree.plantuml @@ -7,34 +7,30 @@ state AppDir { note "All relative paths are relative to the root of the AppDir" as N1 - state "./AppRun" as AppRun { - AppRun : * Set PATH to APPDIR/bin - } - state "./bin/entrypoint daemon -c ./daemon.yml" as entrypoint { - entrypoint : * Create runtime dir at $_RUNTIME_DIR_PATH + entrypoint : * Create runtime dir entrypoint : * Lock runtime dir entrypoint : * Merge given and default daemon.yml files - entrypoint : * Copy bootstrap.json into $_DATA_DIR_PATH, if it's not there + entrypoint : * Copy bootstrap.json into state directory, if it's not there entrypoint : * Merge daemon.yml config into bootstrap.json - entrypoint : * Create $_RUNTIME_DIR_PATH/dnsmasq.conf - entrypoint : * Create $_RUNTIME_DIR_PATH/nebula.yml - entrypoint : * Create $_RUNTIME_DIR_PATH/garage-N.toml\n (one per storage allocation) - entrypoint : * Run child processes - entrypoint : * (in the background) Updates garage cluster layout - entrypoint : * (in the background) Stores host info in global bucket + entrypoint : * Create $RUNTIME_DIRECTORY/dnsmasq.conf + entrypoint : * Create $RUNTIME_DIRECTORY/nebula.yml + entrypoint : * Create $RUNTIME_DIRECTORY/garage-N.toml\n (one per storage allocation) + entrypoint : * Spawn child processes + entrypoint : * Wait for nebula & garage to initialize + entrypoint : * Updates garage cluster layout + entrypoint : * Stores host info in global bucket, based on latest bootstrap.json } - init --> AppRun : exec - AppRun --> entrypoint : exec + init --> entrypoint : exec - state "./bin/dnsmasq -d -C $_RUNTIME_DIR_PATH/dnsmasq.conf" as dnsmasq + state "./bin/dnsmasq -d -C $RUNTIME_DIRECTORY/dnsmasq.conf" as dnsmasq entrypoint --> dnsmasq : child - state "./bin/nebula -config $_RUNTIME_DIR_PATH/nebula.yml" as nebula + state "./bin/nebula -config $RUNTIME_DIRECTORY/nebula.yml" as nebula entrypoint --> nebula : child - state "./bin/garage -c $_RUNTIME_DIR_PATH/garage-N.toml server" as garage + state "./bin/garage -c $RUNTIME_DIRECTORY/garage-N.toml server" as garage entrypoint --> garage : child (one per storage allocation) } diff --git a/docs/dev/daemon-process-tree.svg b/docs/dev/daemon-process-tree.svg index 4304b0c..2b60363 100644 --- a/docs/dev/daemon-process-tree.svg +++ b/docs/dev/daemon-process-tree.svg @@ -1 +1 @@ -AppDirAll relative paths are relative to the root of the AppDir./AppRunSet PATH to APPDIR/bin./bin/entrypoint daemon -c ./daemon.ymlCreate runtime dir at $_RUNTIME_DIR_PATHLock runtime dirMerge given and default daemon.yml filesCopy bootstrap.json into $_DATA_DIR_PATH, if it's not thereMerge daemon.yml config into bootstrap.jsonCreate $_RUNTIME_DIR_PATH/dnsmasq.confCreate $_RUNTIME_DIR_PATH/nebula.ymlCreate $_RUNTIME_DIR_PATH/garage-N.toml(one per storage allocation)Run child processes(in the background) Updates garage cluster layout(in the background) Stores host info in global bucket./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./isle daemon -c ./daemon.ymlexecexecchildchildchild (one per storage allocation) \ No newline at end of file +AppDirAll relative paths are relative to the root of the AppDir./bin/entrypoint daemon -c ./daemon.ymlCreate runtime dirLock runtime dirMerge given and default daemon.yml filesCopy bootstrap.json into state directory, if it's not thereMerge daemon.yml config into bootstrap.jsonCreate $RUNTIME_DIRECTORY/dnsmasq.confCreate $RUNTIME_DIRECTORY/nebula.ymlCreate $RUNTIME_DIRECTORY/garage-N.toml(one per storage allocation)Spawn child processesWait for nebula & garage to initializeUpdates garage cluster layoutStores host info in global bucket, based on latest bootstrap.json./bin/dnsmasq -d -C $RUNTIME_DIRECTORY/dnsmasq.conf./bin/nebula -config $RUNTIME_DIRECTORY/nebula.yml./bin/garage -c $RUNTIME_DIRECTORY/garage-N.toml server./isle daemon -c ./daemon.ymlexecchildchildchild (one per storage allocation) \ No newline at end of file diff --git a/go/bootstrap/bootstrap.go b/go/bootstrap/bootstrap.go index 6470c6c..fe48fa6 100644 --- a/go/bootstrap/bootstrap.go +++ b/go/bootstrap/bootstrap.go @@ -16,9 +16,9 @@ import ( "sort" ) -// DataDirPath returns the path within the user's data directory where the +// StateDirPath returns the path within the user's state directory where the // bootstrap file is stored. -func DataDirPath(dataDirPath string) string { +func StateDirPath(dataDirPath string) string { return filepath.Join(dataDirPath, "bootstrap.json") } diff --git a/go/cmd/entrypoint/bootstrap_util.go b/go/cmd/entrypoint/bootstrap_util.go index 34f5633..38ac306 100644 --- a/go/cmd/entrypoint/bootstrap_util.go +++ b/go/cmd/entrypoint/bootstrap_util.go @@ -11,17 +11,17 @@ import ( func loadHostBootstrap() (bootstrap.Bootstrap, error) { - dataDirPath := bootstrap.DataDirPath(envDataDirPath) + stateDirPath := bootstrap.StateDirPath(envStateDirPath) - hostBootstrap, err := bootstrap.FromFile(dataDirPath) + hostBootstrap, err := bootstrap.FromFile(stateDirPath) if errors.Is(err, fs.ErrNotExist) { return bootstrap.Bootstrap{}, fmt.Errorf( "%q not found, has the daemon ever been run?", - dataDirPath, + stateDirPath, ) } else if err != nil { - return bootstrap.Bootstrap{}, fmt.Errorf("loading %q: %w", dataDirPath, err) + return bootstrap.Bootstrap{}, fmt.Errorf("loading %q: %w", stateDirPath, err) } return hostBootstrap, nil @@ -29,7 +29,7 @@ func loadHostBootstrap() (bootstrap.Bootstrap, error) { func writeBootstrapToDataDir(hostBootstrap bootstrap.Bootstrap) error { - path := bootstrap.DataDirPath(envDataDirPath) + path := bootstrap.StateDirPath(envStateDirPath) dirPath := filepath.Dir(path) if err := os.MkdirAll(dirPath, 0700); err != nil { diff --git a/go/cmd/entrypoint/daemon.go b/go/cmd/entrypoint/daemon.go index 3ef1b7b..b3cc912 100644 --- a/go/cmd/entrypoint/daemon.go +++ b/go/cmd/entrypoint/daemon.go @@ -245,8 +245,8 @@ var subCmdDaemon = subCmd{ defer runtimeDirCleanup() var ( - bootstrapDataDirPath = bootstrap.DataDirPath(envDataDirPath) - bootstrapAppDirPath = bootstrap.AppDirPath(envAppDirPath) + bootstrapStateDirPath = bootstrap.StateDirPath(envStateDirPath) + bootstrapAppDirPath = bootstrap.AppDirPath(envAppDirPath) hostBootstrapPath string hostBootstrap bootstrap.Bootstrap @@ -277,7 +277,7 @@ var subCmdDaemon = subCmd{ } switch { - case tryLoadBootstrap(bootstrapDataDirPath): + case tryLoadBootstrap(bootstrapStateDirPath): case *bootstrapPath != "" && tryLoadBootstrap(*bootstrapPath): case tryLoadBootstrap(bootstrapAppDirPath): case err != nil: @@ -286,7 +286,7 @@ var subCmdDaemon = subCmd{ return errors.New("No bootstrap.json file could be found, and one is not provided with --bootstrap-path") } - if hostBootstrapPath != bootstrapDataDirPath { + if hostBootstrapPath != bootstrapStateDirPath { // If the bootstrap file is not being stored in the data dir, copy // it there, so it can be loaded from there next time. diff --git a/go/cmd/entrypoint/garage.go b/go/cmd/entrypoint/garage.go index d90184c..b17bd32 100644 --- a/go/cmd/entrypoint/garage.go +++ b/go/cmd/entrypoint/garage.go @@ -13,7 +13,7 @@ import ( // order to prevent it from doing so. func initMCConfigDir() (string, error) { var ( - path = filepath.Join(envDataDirPath, "mc") + path = filepath.Join(envStateDirPath, "mc") sharePath = filepath.Join(path, "share") configJSONPath = filepath.Join(path, "config.json") ) diff --git a/go/cmd/entrypoint/main.go b/go/cmd/entrypoint/main.go index 3a1fdc0..3023fe5 100644 --- a/go/cmd/entrypoint/main.go +++ b/go/cmd/entrypoint/main.go @@ -28,7 +28,7 @@ func getAppDirPath() string { var ( envAppDirPath = getAppDirPath() envRuntimeDirPath = filepath.Join(xdg.RuntimeDir, "isle") - envDataDirPath = filepath.Join(xdg.DataHome, "isle") + envStateDirPath = filepath.Join(xdg.StateHome, "isle") ) func binPath(name string) string { diff --git a/tests/cases/admin/01-create-network.sh b/tests/cases/admin/01-create-network.sh index 0f6c059..a73cb72 100644 --- a/tests/cases/admin/01-create-network.sh +++ b/tests/cases/admin/01-create-network.sh @@ -9,7 +9,7 @@ source "$UTILS"/with-1-data-1-empty-node-cluster.sh [ "$(jq -r