cosmos-sdk/cosmovisor/args.go

363 lines
10 KiB
Go
Raw Normal View History

package cosmovisor
import (
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
"encoding/json"
"errors"
"fmt"
"net/url"
"os"
"path/filepath"
"strconv"
feat(cosmovisor): strict boolean argument parsing (#10018) ## Description Closes: #10017 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-08-30 08:17:12 -07:00
"strings"
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
"time"
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
feat: Add cosmovisor run command (#10316) * [10285]: Move the Run function into a new cmd/run.go and have main call the renamed/updated RunCosmovisorCommand function. * [10285]: Shorten the run warning to a single line and log it at the start and end of a run. * [10285]: Make the version.go funcs public. Allow for --version. Limit help request to just the first argument. * [10285]: Create a LogConfigOrError that logs the config or config errors in a standard way. * [10285]: Output config info/errors with the help command. * [10285]: Update the Run command to use the new config/error logging. * [10285]: Only provide the first arg to the cmd tester funcs, since that's all that really matters. * [10285]: Tweak a function comment. * [10285]: For the version command, run the binary with version too. * [10285]: Trim whitespace from the first argument before checking if it's any commands. * [10285]: Update and add some unit tests. * [10285]: In GetConfigFromEnv, make sure the cfg isn't null before trying to use it. * [10285]: Add some unit tests for LogConfigOrError. * [10285]: Allow for the poll interval to be defined as a duration. * [10285]: Add changelog line. * [10285]: Update the README to reflect the addition of the run action. * [10285]: slight tweak to changlog. * [10285]: Add a couple lines to the help text about getting help from the configured binary. * [10285]: Remove a println from a unit test. * [10285]: Put the help command first in the README. Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2021-10-18 08:32:24 -07:00
"github.com/rs/zerolog"
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
cverrors "github.com/cosmos/cosmos-sdk/cosmovisor/errors"
refactor: import dependancy from upgrade module to cosmovisor module (#10442) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description Closes: #10378 Cosmovisor module copies the data type `UpgradeInfo` and constant `upgradeFilename` from upgrade module to cosmovisor module. This pr will directly import the datatype and const from cosmos-sdk/upgrade module: `UpgradeInfo` -> `upgradetypes.Plan` `upgradeFilename` -> `upgradekeeper.UpgradeInfoFilename` <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-11-09 06:15:43 -08:00
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)
feat(cosmovisor): strict boolean argument parsing (#10018) ## Description Closes: #10017 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-08-30 08:17:12 -07:00
// environment variable names
const (
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
EnvHome = "DAEMON_HOME"
EnvName = "DAEMON_NAME"
EnvDownloadBin = "DAEMON_ALLOW_DOWNLOAD_BINARIES"
EnvRestartUpgrade = "DAEMON_RESTART_AFTER_UPGRADE"
EnvSkipBackup = "UNSAFE_SKIP_BACKUP"
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
EnvDataBackupPath = "DAEMON_DATA_BACKUP_DIR"
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
EnvInterval = "DAEMON_POLL_INTERVAL"
EnvPreupgradeMaxRetries = "DAEMON_PREUPGRADE_MAX_RETRIES"
feat(cosmovisor): strict boolean argument parsing (#10018) ## Description Closes: #10017 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-08-30 08:17:12 -07:00
)
const (
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
rootName = "cosmovisor"
genesisDir = "genesis"
upgradesDir = "upgrades"
currentLink = "current"
)
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
// must be the same as x/upgrade/types.UpgradeInfoFilename
const defaultFilename = "upgrade-info.json"
// Config is the information passed in to control the daemon
type Config struct {
Home string
Name string
AllowDownloadBinaries bool
RestartAfterUpgrade bool
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
PollInterval time.Duration
feat: Add backup option for cosmovisor (#9652) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description Ref: https://github.com/cosmos/cosmos-sdk/issues/9616#issuecomment-873051972 depends: #8590 <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> This PR adds a full backup option for cosmovisor. `UNSAFE_SKIP_BACKUP` is an `env` setting introduced newly. - if `false` (default, **recommended**), cosmovisor will try to take backup and then upgrade. In case of failure while taking backup, it will just halt the process there and won't try the upgrade. - If `true`, the cosmovisor will try to upgrade without any backup. This setting makes it hard to recover from a failed upgrade. Node operators either need to sync from a healthy node or use a snapshot from others. --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-08-05 13:00:08 -07:00
UnsafeSkipBackup bool
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
DataBackupPath string
feat: adding `max-retries` limit to preupgrade retry limit (#10137) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description Ref: #9973, #10056 <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> * Skipping backup when skipping upgrade at specified height * adding env var `PREUPGRADE_MAX_RETRIES` which specifies the limit on how many times to retry preupgrade on error code `31` --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-09-23 08:31:10 -07:00
PreupgradeMaxRetries int
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
// currently running upgrade
refactor: import dependancy from upgrade module to cosmovisor module (#10442) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description Closes: #10378 Cosmovisor module copies the data type `UpgradeInfo` and constant `upgradeFilename` from upgrade module to cosmovisor module. This pr will directly import the datatype and const from cosmos-sdk/upgrade module: `UpgradeInfo` -> `upgradetypes.Plan` `upgradeFilename` -> `upgradekeeper.UpgradeInfoFilename` <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-11-09 06:15:43 -08:00
currentUpgrade upgradetypes.Plan
}
// Root returns the root directory where all info lives
func (cfg *Config) Root() string {
return filepath.Join(cfg.Home, rootName)
}
// GenesisBin is the path to the genesis binary - must be in place to start manager
func (cfg *Config) GenesisBin() string {
return filepath.Join(cfg.Root(), genesisDir, "bin", cfg.Name)
}
// UpgradeBin is the path to the binary for the named upgrade
func (cfg *Config) UpgradeBin(upgradeName string) string {
return filepath.Join(cfg.UpgradeDir(upgradeName), "bin", cfg.Name)
}
// UpgradeDir is the directory named upgrade
func (cfg *Config) UpgradeDir(upgradeName string) string {
safeName := url.PathEscape(upgradeName)
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
return filepath.Join(cfg.BaseUpgradeDir(), safeName)
}
// BaseUpgradeDir is the directory containing the named upgrade directories.
func (cfg *Config) BaseUpgradeDir() string {
return filepath.Join(cfg.Root(), upgradesDir)
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
}
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
// UpgradeInfoFilePath is the expected upgrade-info filename created by `x/upgrade/keeper`.
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
func (cfg *Config) UpgradeInfoFilePath() string {
return filepath.Join(cfg.Home, "data", defaultFilename)
}
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
// SymLinkToGenesis creates a symbolic link from "./current" to the genesis directory.
func (cfg *Config) SymLinkToGenesis() (string, error) {
genesis := filepath.Join(cfg.Root(), genesisDir)
link := filepath.Join(cfg.Root(), currentLink)
if err := os.Symlink(genesis, link); err != nil {
return "", err
}
// and return the genesis binary
return cfg.GenesisBin(), nil
}
// CurrentBin is the path to the currently selected binary (genesis if no link is set)
// This will resolve the symlink to the underlying directory to make it easier to debug
func (cfg *Config) CurrentBin() (string, error) {
cur := filepath.Join(cfg.Root(), currentLink)
// if nothing here, fallback to genesis
info, err := os.Lstat(cur)
if err != nil {
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
// Create symlink to the genesis
return cfg.SymLinkToGenesis()
}
// if it is there, ensure it is a symlink
if info.Mode()&os.ModeSymlink == 0 {
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
// Create symlink to the genesis
return cfg.SymLinkToGenesis()
}
// resolve it
dest, err := os.Readlink(cur)
if err != nil {
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
// Create symlink to the genesis
return cfg.SymLinkToGenesis()
}
// and return the binary
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
binpath := filepath.Join(dest, "bin", cfg.Name)
return binpath, nil
}
// GetConfigFromEnv will read the environmental variables into a config
// and then validate it is reasonable
func GetConfigFromEnv() (*Config, error) {
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
var errs []error
cfg := &Config{
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
Home: os.Getenv(EnvHome),
Name: os.Getenv(EnvName),
DataBackupPath: os.Getenv(EnvDataBackupPath),
}
if cfg.DataBackupPath == "" {
cfg.DataBackupPath = cfg.Home
}
feat(cosmovisor): strict boolean argument parsing (#10018) ## Description Closes: #10017 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-08-30 08:17:12 -07:00
var err error
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
if cfg.AllowDownloadBinaries, err = booleanOption(EnvDownloadBin, false); err != nil {
errs = append(errs, err)
}
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
if cfg.RestartAfterUpgrade, err = booleanOption(EnvRestartUpgrade, true); err != nil {
errs = append(errs, err)
feat(cosmovisor): strict boolean argument parsing (#10018) ## Description Closes: #10017 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-08-30 08:17:12 -07:00
}
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
if cfg.UnsafeSkipBackup, err = booleanOption(EnvSkipBackup, false); err != nil {
errs = append(errs, err)
}
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
interval := os.Getenv(EnvInterval)
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
if interval != "" {
feat: Add cosmovisor run command (#10316) * [10285]: Move the Run function into a new cmd/run.go and have main call the renamed/updated RunCosmovisorCommand function. * [10285]: Shorten the run warning to a single line and log it at the start and end of a run. * [10285]: Make the version.go funcs public. Allow for --version. Limit help request to just the first argument. * [10285]: Create a LogConfigOrError that logs the config or config errors in a standard way. * [10285]: Output config info/errors with the help command. * [10285]: Update the Run command to use the new config/error logging. * [10285]: Only provide the first arg to the cmd tester funcs, since that's all that really matters. * [10285]: Tweak a function comment. * [10285]: For the version command, run the binary with version too. * [10285]: Trim whitespace from the first argument before checking if it's any commands. * [10285]: Update and add some unit tests. * [10285]: In GetConfigFromEnv, make sure the cfg isn't null before trying to use it. * [10285]: Add some unit tests for LogConfigOrError. * [10285]: Allow for the poll interval to be defined as a duration. * [10285]: Add changelog line. * [10285]: Update the README to reflect the addition of the run action. * [10285]: slight tweak to changlog. * [10285]: Add a couple lines to the help text about getting help from the configured binary. * [10285]: Remove a println from a unit test. * [10285]: Put the help command first in the README. Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2021-10-18 08:32:24 -07:00
var intervalUInt uint64
intervalUInt, err = strconv.ParseUint(interval, 10, 32)
if err == nil {
cfg.PollInterval = time.Millisecond * time.Duration(intervalUInt)
} else {
cfg.PollInterval, err = time.ParseDuration(interval)
}
switch {
case err != nil:
errs = append(errs, fmt.Errorf("invalid %s: could not parse \"%s\" into either a duration or uint (milliseconds)", EnvInterval, interval))
case cfg.PollInterval <= 0:
errs = append(errs, fmt.Errorf("invalid %s: must be greater than 0", EnvInterval))
}
} else {
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
cfg.PollInterval = 300 * time.Millisecond
}
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
envPreupgradeMaxRetriesVal := os.Getenv(EnvPreupgradeMaxRetries)
feat: adding `max-retries` limit to preupgrade retry limit (#10137) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description Ref: #9973, #10056 <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> * Skipping backup when skipping upgrade at specified height * adding env var `PREUPGRADE_MAX_RETRIES` which specifies the limit on how many times to retry preupgrade on error code `31` --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-09-23 08:31:10 -07:00
if cfg.PreupgradeMaxRetries, err = strconv.Atoi(envPreupgradeMaxRetriesVal); err != nil && envPreupgradeMaxRetriesVal != "" {
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
errs = append(errs, fmt.Errorf("%s could not be parsed to int: %w", EnvPreupgradeMaxRetries, err))
feat: adding `max-retries` limit to preupgrade retry limit (#10137) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description Ref: #9973, #10056 <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> * Skipping backup when skipping upgrade at specified height * adding env var `PREUPGRADE_MAX_RETRIES` which specifies the limit on how many times to retry preupgrade on error code `31` --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-09-23 08:31:10 -07:00
}
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
errs = append(errs, cfg.validate()...)
if len(errs) > 0 {
return nil, cverrors.FlattenErrors(errs...)
}
return cfg, nil
}
feat: Add cosmovisor run command (#10316) * [10285]: Move the Run function into a new cmd/run.go and have main call the renamed/updated RunCosmovisorCommand function. * [10285]: Shorten the run warning to a single line and log it at the start and end of a run. * [10285]: Make the version.go funcs public. Allow for --version. Limit help request to just the first argument. * [10285]: Create a LogConfigOrError that logs the config or config errors in a standard way. * [10285]: Output config info/errors with the help command. * [10285]: Update the Run command to use the new config/error logging. * [10285]: Only provide the first arg to the cmd tester funcs, since that's all that really matters. * [10285]: Tweak a function comment. * [10285]: For the version command, run the binary with version too. * [10285]: Trim whitespace from the first argument before checking if it's any commands. * [10285]: Update and add some unit tests. * [10285]: In GetConfigFromEnv, make sure the cfg isn't null before trying to use it. * [10285]: Add some unit tests for LogConfigOrError. * [10285]: Allow for the poll interval to be defined as a duration. * [10285]: Add changelog line. * [10285]: Update the README to reflect the addition of the run action. * [10285]: slight tweak to changlog. * [10285]: Add a couple lines to the help text about getting help from the configured binary. * [10285]: Remove a println from a unit test. * [10285]: Put the help command first in the README. Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2021-10-18 08:32:24 -07:00
// LogConfigOrError logs either the config details or the error.
fix(cosmovisor): udpate the help and version command output (#10458) ## Description Closes: #10450 * `cosmovisor help` should not print any error. * `cosmovisor version` should print more clear message if it can't run `app version`. ## Before ``` ~/tmp ❯ cosmovisor version Cosmosvisor - A process manager for Cosmos SDK application binaries. Cosmovisor is a wrapper for a Cosmos SDK based App (set using the required DAEMON_NAME env variable). It starts the App by passing all provided arguments and monitors the DAEMON_HOME/data/upgrade-info.json file to perform an update. The upgrade-info.json file is created by the App x/upgrade module when the blockchain height reaches an approved upgrade proposal. The file includes data from the proposal. Cosmovisor interprets that data to perform an update: switch a current binary and restart the App. Configuration of Cosmovisor is done through environment variables, which are documented in: https://github.com/cosmos/cosmos-sdk/tree/master/cosmovisor/README.md 8:03PM ERR multiple configuration errors found: module=cosmovisor 8:03PM ERR 1: error="DAEMON_NAME is not set" module=cosmovisor 8:03PM ERR 2: error="DAEMON_HOME is not set" module=cosmovisor 8:03PM ERR error="2 errors: 1: DAEMON_NAME is not set, 2: DAEMON_HOME is not set" module=cosmovisor ❯ cosmovisor help Cosmosvisor - A process manager for Cosmos SDK application binaries. Cosmovisor is a wrapper for a Cosmos SDK based App (set using the required DAEMON_NAME env variable). It starts the App by passing all provided arguments and monitors the DAEMON_HOME/data/upgrade-info.json file to perform an update. The upgrade-info.json file is created by the App x/upgrade module when the blockchain height reaches an approved upgrade proposal. The file includes data from the proposal. Cosmovisor interprets that data to perform an update: switch a current binary and restart the App. Configuration of Cosmovisor is done through environment variables, which are documented in: https://github.com/cosmos/cosmos-sdk/tree/master/cosmovisor/README.md 8:03PM ERR multiple configuration errors found: module=cosmovisor 8:03PM ERR 1: error="DAEMON_NAME is not set" module=cosmovisor 8:03PM ERR 2: error="DAEMON_HOME is not set" module=cosmovisor 8:03PM ERR error="2 errors: 1: DAEMON_NAME is not set, 2: DAEMON_HOME is not set" module=cosmovisor ``` ## After ``` ❯ ./cosmovisor version Cosmovisor Version: v1.0.0-76-g66bddfb04 8:05PM ERR Can't run APP version 8:05PM ERR 1: error="DAEMON_NAME is not set" 8:05PM ERR 2: error="DAEMON_HOME is not set" ❯ ./cosmovisor help Cosmosvisor - A process manager for Cosmos SDK application binaries. Cosmovisor is a wrapper for a Cosmos SDK based App (set using the required DAEMON_NAME env variable). It starts the App by passing all provided arguments and monitors the DAEMON_HOME/data/upgrade-info.json file to perform an update. The upgrade-info.json file is created by the App x/upgrade module when the blockchain height reaches an approved upgrade proposal. The file includes data from the proposal. Cosmovisor interprets that data to perform an update: switch a current binary and restart the App. Configuration of Cosmovisor is done through environment variables, which are documented in: https://github.com/cosmos/cosmos-sdk/tree/master/cosmovisor/README.md To get help for the configured binary: cosmovisor run help ``` --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-11-19 09:35:56 -08:00
func LogConfigOrError(logger zerolog.Logger, cfg *Config, err error) {
if cfg == nil && err == nil {
return
}
logger.Info().Msg("Configuration:")
feat: Add cosmovisor run command (#10316) * [10285]: Move the Run function into a new cmd/run.go and have main call the renamed/updated RunCosmovisorCommand function. * [10285]: Shorten the run warning to a single line and log it at the start and end of a run. * [10285]: Make the version.go funcs public. Allow for --version. Limit help request to just the first argument. * [10285]: Create a LogConfigOrError that logs the config or config errors in a standard way. * [10285]: Output config info/errors with the help command. * [10285]: Update the Run command to use the new config/error logging. * [10285]: Only provide the first arg to the cmd tester funcs, since that's all that really matters. * [10285]: Tweak a function comment. * [10285]: For the version command, run the binary with version too. * [10285]: Trim whitespace from the first argument before checking if it's any commands. * [10285]: Update and add some unit tests. * [10285]: In GetConfigFromEnv, make sure the cfg isn't null before trying to use it. * [10285]: Add some unit tests for LogConfigOrError. * [10285]: Allow for the poll interval to be defined as a duration. * [10285]: Add changelog line. * [10285]: Update the README to reflect the addition of the run action. * [10285]: slight tweak to changlog. * [10285]: Add a couple lines to the help text about getting help from the configured binary. * [10285]: Remove a println from a unit test. * [10285]: Put the help command first in the README. Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2021-10-18 08:32:24 -07:00
switch {
fix(cosmovisor): udpate the help and version command output (#10458) ## Description Closes: #10450 * `cosmovisor help` should not print any error. * `cosmovisor version` should print more clear message if it can't run `app version`. ## Before ``` ~/tmp ❯ cosmovisor version Cosmosvisor - A process manager for Cosmos SDK application binaries. Cosmovisor is a wrapper for a Cosmos SDK based App (set using the required DAEMON_NAME env variable). It starts the App by passing all provided arguments and monitors the DAEMON_HOME/data/upgrade-info.json file to perform an update. The upgrade-info.json file is created by the App x/upgrade module when the blockchain height reaches an approved upgrade proposal. The file includes data from the proposal. Cosmovisor interprets that data to perform an update: switch a current binary and restart the App. Configuration of Cosmovisor is done through environment variables, which are documented in: https://github.com/cosmos/cosmos-sdk/tree/master/cosmovisor/README.md 8:03PM ERR multiple configuration errors found: module=cosmovisor 8:03PM ERR 1: error="DAEMON_NAME is not set" module=cosmovisor 8:03PM ERR 2: error="DAEMON_HOME is not set" module=cosmovisor 8:03PM ERR error="2 errors: 1: DAEMON_NAME is not set, 2: DAEMON_HOME is not set" module=cosmovisor ❯ cosmovisor help Cosmosvisor - A process manager for Cosmos SDK application binaries. Cosmovisor is a wrapper for a Cosmos SDK based App (set using the required DAEMON_NAME env variable). It starts the App by passing all provided arguments and monitors the DAEMON_HOME/data/upgrade-info.json file to perform an update. The upgrade-info.json file is created by the App x/upgrade module when the blockchain height reaches an approved upgrade proposal. The file includes data from the proposal. Cosmovisor interprets that data to perform an update: switch a current binary and restart the App. Configuration of Cosmovisor is done through environment variables, which are documented in: https://github.com/cosmos/cosmos-sdk/tree/master/cosmovisor/README.md 8:03PM ERR multiple configuration errors found: module=cosmovisor 8:03PM ERR 1: error="DAEMON_NAME is not set" module=cosmovisor 8:03PM ERR 2: error="DAEMON_HOME is not set" module=cosmovisor 8:03PM ERR error="2 errors: 1: DAEMON_NAME is not set, 2: DAEMON_HOME is not set" module=cosmovisor ``` ## After ``` ❯ ./cosmovisor version Cosmovisor Version: v1.0.0-76-g66bddfb04 8:05PM ERR Can't run APP version 8:05PM ERR 1: error="DAEMON_NAME is not set" 8:05PM ERR 2: error="DAEMON_HOME is not set" ❯ ./cosmovisor help Cosmosvisor - A process manager for Cosmos SDK application binaries. Cosmovisor is a wrapper for a Cosmos SDK based App (set using the required DAEMON_NAME env variable). It starts the App by passing all provided arguments and monitors the DAEMON_HOME/data/upgrade-info.json file to perform an update. The upgrade-info.json file is created by the App x/upgrade module when the blockchain height reaches an approved upgrade proposal. The file includes data from the proposal. Cosmovisor interprets that data to perform an update: switch a current binary and restart the App. Configuration of Cosmovisor is done through environment variables, which are documented in: https://github.com/cosmos/cosmos-sdk/tree/master/cosmovisor/README.md To get help for the configured binary: cosmovisor run help ``` --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-11-19 09:35:56 -08:00
case err != nil:
cverrors.LogErrors(logger, "configuration errors found", err)
feat: Add cosmovisor run command (#10316) * [10285]: Move the Run function into a new cmd/run.go and have main call the renamed/updated RunCosmovisorCommand function. * [10285]: Shorten the run warning to a single line and log it at the start and end of a run. * [10285]: Make the version.go funcs public. Allow for --version. Limit help request to just the first argument. * [10285]: Create a LogConfigOrError that logs the config or config errors in a standard way. * [10285]: Output config info/errors with the help command. * [10285]: Update the Run command to use the new config/error logging. * [10285]: Only provide the first arg to the cmd tester funcs, since that's all that really matters. * [10285]: Tweak a function comment. * [10285]: For the version command, run the binary with version too. * [10285]: Trim whitespace from the first argument before checking if it's any commands. * [10285]: Update and add some unit tests. * [10285]: In GetConfigFromEnv, make sure the cfg isn't null before trying to use it. * [10285]: Add some unit tests for LogConfigOrError. * [10285]: Allow for the poll interval to be defined as a duration. * [10285]: Add changelog line. * [10285]: Update the README to reflect the addition of the run action. * [10285]: slight tweak to changlog. * [10285]: Add a couple lines to the help text about getting help from the configured binary. * [10285]: Remove a println from a unit test. * [10285]: Put the help command first in the README. Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2021-10-18 08:32:24 -07:00
case cfg != nil:
fix(cosmovisor): udpate the help and version command output (#10458) ## Description Closes: #10450 * `cosmovisor help` should not print any error. * `cosmovisor version` should print more clear message if it can't run `app version`. ## Before ``` ~/tmp ❯ cosmovisor version Cosmosvisor - A process manager for Cosmos SDK application binaries. Cosmovisor is a wrapper for a Cosmos SDK based App (set using the required DAEMON_NAME env variable). It starts the App by passing all provided arguments and monitors the DAEMON_HOME/data/upgrade-info.json file to perform an update. The upgrade-info.json file is created by the App x/upgrade module when the blockchain height reaches an approved upgrade proposal. The file includes data from the proposal. Cosmovisor interprets that data to perform an update: switch a current binary and restart the App. Configuration of Cosmovisor is done through environment variables, which are documented in: https://github.com/cosmos/cosmos-sdk/tree/master/cosmovisor/README.md 8:03PM ERR multiple configuration errors found: module=cosmovisor 8:03PM ERR 1: error="DAEMON_NAME is not set" module=cosmovisor 8:03PM ERR 2: error="DAEMON_HOME is not set" module=cosmovisor 8:03PM ERR error="2 errors: 1: DAEMON_NAME is not set, 2: DAEMON_HOME is not set" module=cosmovisor ❯ cosmovisor help Cosmosvisor - A process manager for Cosmos SDK application binaries. Cosmovisor is a wrapper for a Cosmos SDK based App (set using the required DAEMON_NAME env variable). It starts the App by passing all provided arguments and monitors the DAEMON_HOME/data/upgrade-info.json file to perform an update. The upgrade-info.json file is created by the App x/upgrade module when the blockchain height reaches an approved upgrade proposal. The file includes data from the proposal. Cosmovisor interprets that data to perform an update: switch a current binary and restart the App. Configuration of Cosmovisor is done through environment variables, which are documented in: https://github.com/cosmos/cosmos-sdk/tree/master/cosmovisor/README.md 8:03PM ERR multiple configuration errors found: module=cosmovisor 8:03PM ERR 1: error="DAEMON_NAME is not set" module=cosmovisor 8:03PM ERR 2: error="DAEMON_HOME is not set" module=cosmovisor 8:03PM ERR error="2 errors: 1: DAEMON_NAME is not set, 2: DAEMON_HOME is not set" module=cosmovisor ``` ## After ``` ❯ ./cosmovisor version Cosmovisor Version: v1.0.0-76-g66bddfb04 8:05PM ERR Can't run APP version 8:05PM ERR 1: error="DAEMON_NAME is not set" 8:05PM ERR 2: error="DAEMON_HOME is not set" ❯ ./cosmovisor help Cosmosvisor - A process manager for Cosmos SDK application binaries. Cosmovisor is a wrapper for a Cosmos SDK based App (set using the required DAEMON_NAME env variable). It starts the App by passing all provided arguments and monitors the DAEMON_HOME/data/upgrade-info.json file to perform an update. The upgrade-info.json file is created by the App x/upgrade module when the blockchain height reaches an approved upgrade proposal. The file includes data from the proposal. Cosmovisor interprets that data to perform an update: switch a current binary and restart the App. Configuration of Cosmovisor is done through environment variables, which are documented in: https://github.com/cosmos/cosmos-sdk/tree/master/cosmovisor/README.md To get help for the configured binary: cosmovisor run help ``` --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-11-19 09:35:56 -08:00
logger.Info().Msg(cfg.DetailString())
feat: Add cosmovisor run command (#10316) * [10285]: Move the Run function into a new cmd/run.go and have main call the renamed/updated RunCosmovisorCommand function. * [10285]: Shorten the run warning to a single line and log it at the start and end of a run. * [10285]: Make the version.go funcs public. Allow for --version. Limit help request to just the first argument. * [10285]: Create a LogConfigOrError that logs the config or config errors in a standard way. * [10285]: Output config info/errors with the help command. * [10285]: Update the Run command to use the new config/error logging. * [10285]: Only provide the first arg to the cmd tester funcs, since that's all that really matters. * [10285]: Tweak a function comment. * [10285]: For the version command, run the binary with version too. * [10285]: Trim whitespace from the first argument before checking if it's any commands. * [10285]: Update and add some unit tests. * [10285]: In GetConfigFromEnv, make sure the cfg isn't null before trying to use it. * [10285]: Add some unit tests for LogConfigOrError. * [10285]: Allow for the poll interval to be defined as a duration. * [10285]: Add changelog line. * [10285]: Update the README to reflect the addition of the run action. * [10285]: slight tweak to changlog. * [10285]: Add a couple lines to the help text about getting help from the configured binary. * [10285]: Remove a println from a unit test. * [10285]: Put the help command first in the README. Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2021-10-18 08:32:24 -07:00
}
}
// validate returns an error if this config is invalid.
// it enforces Home/cosmovisor is a valid directory and exists,
// and that Name is set
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
func (cfg *Config) validate() []error {
var errs []error
if cfg.Name == "" {
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
errs = append(errs, errors.New(EnvName+" is not set"))
}
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
switch {
case cfg.Home == "":
errs = append(errs, errors.New(EnvHome+" is not set"))
case !filepath.IsAbs(cfg.Home):
errs = append(errs, errors.New(EnvHome+" must be an absolute path"))
default:
switch info, err := os.Stat(cfg.Root()); {
case err != nil:
errs = append(errs, fmt.Errorf("cannot stat home dir: %w", err))
case !info.IsDir():
errs = append(errs, fmt.Errorf("%s is not a directory", cfg.Root()))
}
}
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
// check the DataBackupPath
if cfg.UnsafeSkipBackup == true {
return errs
}
// if UnsafeSkipBackup is false, check if the DataBackupPath valid
switch {
case cfg.DataBackupPath == "":
errs = append(errs, errors.New(EnvDataBackupPath + " must not be empty"))
case !filepath.IsAbs(cfg.DataBackupPath):
errs = append(errs, errors.New(cfg.DataBackupPath + " must be an absolute path"))
default:
switch info, err := os.Stat(cfg.DataBackupPath); {
case err != nil:
errs = append(errs, fmt.Errorf("%q must be a valid directory: %w", cfg.DataBackupPath, err))
case !info.IsDir():
errs = append(errs, fmt.Errorf("%q must be a valid directory", cfg.DataBackupPath))
}
}
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
return errs
}
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
// SetCurrentUpgrade sets the named upgrade to be the current link, returns error if this binary doesn't exist
refactor: import dependancy from upgrade module to cosmovisor module (#10442) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description Closes: #10378 Cosmovisor module copies the data type `UpgradeInfo` and constant `upgradeFilename` from upgrade module to cosmovisor module. This pr will directly import the datatype and const from cosmos-sdk/upgrade module: `UpgradeInfo` -> `upgradetypes.Plan` `upgradeFilename` -> `upgradekeeper.UpgradeInfoFilename` <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-11-09 06:15:43 -08:00
func (cfg *Config) SetCurrentUpgrade(u upgradetypes.Plan) error {
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
// ensure named upgrade exists
bin := cfg.UpgradeBin(u.Name)
if err := EnsureBinary(bin); err != nil {
return err
}
// set a symbolic link
link := filepath.Join(cfg.Root(), currentLink)
safeName := url.PathEscape(u.Name)
upgrade := filepath.Join(cfg.Root(), upgradesDir, safeName)
// remove link if it exists
if _, err := os.Stat(link); err == nil {
os.Remove(link)
}
// point to the new directory
if err := os.Symlink(upgrade, link); err != nil {
return fmt.Errorf("creating current symlink: %w", err)
}
cfg.currentUpgrade = u
refactor: import dependancy from upgrade module to cosmovisor module (#10442) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description Closes: #10378 Cosmovisor module copies the data type `UpgradeInfo` and constant `upgradeFilename` from upgrade module to cosmovisor module. This pr will directly import the datatype and const from cosmos-sdk/upgrade module: `UpgradeInfo` -> `upgradetypes.Plan` `upgradeFilename` -> `upgradekeeper.UpgradeInfoFilename` <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-11-09 06:15:43 -08:00
f, err := os.Create(filepath.Join(upgrade, upgradekeeper.UpgradeInfoFileName))
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
if err != nil {
return err
}
bz, err := json.Marshal(u)
if err != nil {
return err
}
if _, err := f.Write(bz); err != nil {
return err
}
return f.Close()
}
refactor: import dependancy from upgrade module to cosmovisor module (#10442) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description Closes: #10378 Cosmovisor module copies the data type `UpgradeInfo` and constant `upgradeFilename` from upgrade module to cosmovisor module. This pr will directly import the datatype and const from cosmos-sdk/upgrade module: `UpgradeInfo` -> `upgradetypes.Plan` `upgradeFilename` -> `upgradekeeper.UpgradeInfoFilename` <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-11-09 06:15:43 -08:00
func (cfg *Config) UpgradeInfo() upgradetypes.Plan {
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
if cfg.currentUpgrade.Name != "" {
return cfg.currentUpgrade
}
refactor: import dependancy from upgrade module to cosmovisor module (#10442) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description Closes: #10378 Cosmovisor module copies the data type `UpgradeInfo` and constant `upgradeFilename` from upgrade module to cosmovisor module. This pr will directly import the datatype and const from cosmos-sdk/upgrade module: `UpgradeInfo` -> `upgradetypes.Plan` `upgradeFilename` -> `upgradekeeper.UpgradeInfoFilename` <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-11-09 06:15:43 -08:00
filename := filepath.Join(cfg.Root(), currentLink, upgradekeeper.UpgradeInfoFileName)
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
_, err := os.Lstat(filename)
refactor: import dependancy from upgrade module to cosmovisor module (#10442) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description Closes: #10378 Cosmovisor module copies the data type `UpgradeInfo` and constant `upgradeFilename` from upgrade module to cosmovisor module. This pr will directly import the datatype and const from cosmos-sdk/upgrade module: `UpgradeInfo` -> `upgradetypes.Plan` `upgradeFilename` -> `upgradekeeper.UpgradeInfoFilename` <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-11-09 06:15:43 -08:00
var u upgradetypes.Plan
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
var bz []byte
if err != nil { // no current directory
goto returnError
}
refactor: move from io/ioutil to io and os package (#10341) ## Description The `io/ioutil` package has been deprecated in Go 1.16 (See https://golang.org/doc/go1.16#ioutil). Since cosmos-sdk has upgraded to Go 1.17 (#9987), this PR replaces the existing `io/ioutil` functions with their new definitions in `io` and `os` packages. --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-10-13 00:38:22 -07:00
if bz, err = os.ReadFile(filename); err != nil {
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
goto returnError
}
if err = json.Unmarshal(bz, &u); err != nil {
goto returnError
}
cfg.currentUpgrade = u
return cfg.currentUpgrade
returnError:
Logger.Error().Err(err).Str("filename", filename).Msg("failed to read")
feat: file watcher for cosmovisor (#8590) Adding upgrade file watcher for cosmovisor. Currently the comswisor upgrade mechanism relays on parsing log messages. This is not reliable: + depends on the log level output (x/upgrade uses INFO) + can be hacked by accidentally logging user user content + can be broken by using upgrade name which will break the regex pattern. closes: #7703 closes: #8523 closes: #8651 closes: #8793 closes: #8964 **Depends on**: - #9652 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
2021-08-11 08:03:48 -07:00
cfg.currentUpgrade.Name = "_"
return cfg.currentUpgrade
}
feat(cosmovisor): strict boolean argument parsing (#10018) ## Description Closes: #10017 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-08-30 08:17:12 -07:00
// checks and validates env option
func booleanOption(name string, defaultVal bool) (bool, error) {
p := strings.ToLower(os.Getenv(name))
switch p {
case "":
return defaultVal, nil
case "false":
return false, nil
case "true":
return true, nil
}
return false, fmt.Errorf("env variable %q must have a boolean value (\"true\" or \"false\"), got %q", name, p)
}
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
// DetailString returns a multi-line string with details about this config.
func (cfg Config) DetailString() string {
configEntries := []struct{ name, value string }{
{EnvHome, cfg.Home},
{EnvName, cfg.Name},
{EnvDownloadBin, fmt.Sprintf("%t", cfg.AllowDownloadBinaries)},
{EnvRestartUpgrade, fmt.Sprintf("%t", cfg.RestartAfterUpgrade)},
{EnvInterval, fmt.Sprintf("%s", cfg.PollInterval)},
{EnvSkipBackup, fmt.Sprintf("%t", cfg.UnsafeSkipBackup)},
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
{EnvDataBackupPath, cfg.DataBackupPath},
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
{EnvPreupgradeMaxRetries, fmt.Sprintf("%d", cfg.PreupgradeMaxRetries)},
}
derivedEntries := []struct{ name, value string }{
{"Root Dir", cfg.Root()},
{"Upgrade Dir", cfg.BaseUpgradeDir()},
{"Genesis Bin", cfg.GenesisBin()},
{"Monitored File", cfg.UpgradeInfoFilePath()},
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
{"Data Backup Dir", cfg.DataBackupPath},
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
}
var sb strings.Builder
sb.WriteString("Configurable Values:\n")
for _, kv := range configEntries {
sb.WriteString(fmt.Sprintf(" %s: %s\n", kv.name, kv.value))
}
sb.WriteString("Derived Values:\n")
dnl := 0
for _, kv := range derivedEntries {
if len(kv.name) > dnl {
dnl = len(kv.name)
}
}
dFmt := fmt.Sprintf(" %%%ds: %%s\n", dnl)
for _, kv := range derivedEntries {
sb.WriteString(fmt.Sprintf(dFmt, kv.name, kv.value))
}
return sb.String()
}