-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use dataDir/config.yaml as the default config path (#4466)
A recent change in behaviour has caused some confusion where the default config path changed from `repo/config.yaml` to `~/.config/bacalhau/config.yaml`. This PR reverts this change and continue using a `config.yaml` under the repo/dataDir if present and if no explicit config file was provided by the user through `--config` flag. The assumption that many users have is deleting the data directory (e.g. `~/.bacalhau`), or pointing to a fresh directory using `$BACALHAU_DIR` env variable or `--data-dir` flag, is reseting the state and configuration of the node or client. However, this wasn't the case as the default config path was outside the data directory. ### Before this PR This is an example where issues could happen: ``` # user changes the api port # here the user didn't provide a --config file, so configurations # were written to a user global `~/.config/bacalhau/config.yaml` # and not local to the data dir bacalhau config set api.port 2233 # user starts a node and expects 2233 # this works as the user didn't specify --config and the default path was picked bacalhau serve --compute --orchestrator # user decides to start another node, or just stop the previous one and start fresh again export BACALHAU_DIR=$(mktemp -d -t bacalhau_dir) bacalhau serve --compute --orchestrator # here the user expects the node to start with default api.port of 1234 # but the default configuration was read again ``` ### After this PR ``` # user changes the api port # the configs are now written to the data dir `$BACALHAU_DIR/config.yaml` bacalhau config set api.port 2233 # user starts a node and expects 2233 # this works as the user didn't specify --config and the data dir path was picked bacalhau serve --compute --orchestrator # user decides to start another node, or just stop the previous one and start fresh again export BACALHAU_DIR=$(mktemp -d -t bacalhau_dir) bacalhau serve --compute --orchestrator # here the node starts with fresh config as the data dir has empty configuratoin ``` ### Different Combinations with the upcoming v1.5.0 release, users are able to define explicit configuration files using `--config` flag, as well as the existing `--data-dir` flag to define where bacalhau stores its state. These are also configurable using env variables. The default `data-dir` if none is specified is `~/.bacalhau`, and the default config path is `$(dataDir)/config.yaml`. Lets explore what that means in action #### Setting config ``` # will use ~/.bacalhau/config.yaml bacalhau config set api.port 2233 # will use hello.yaml bacalhau config set --config hello.yaml api.port 2233 # will use customDir/config.yaml bacalhau config set --data-dir customDir api.port 2233 # will use hello.yaml bacalhau config set --config hello.yaml --data-dir customDir api.port 2233 ``` #### Applying config `bacalhau serve` has the same flags as `bacalhau config set`, and the same logic and precedence applies ``` # will use ~/.bacalhau/config.yaml bacalhau serve --orchestrator --compute # will use hello.yaml bacalhau serve --orchestrator --compute --config hello.yaml # will use customDir/config.yaml bacalhau serve --orchestrator --compute --data-dir customDir # will use hello.yaml instead of customDir/config.yaml bacalhau serve --orchestrator --compute --config hello.yaml --data-dir customDir ```
- Loading branch information
Showing
11 changed files
with
389 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.