fix: cosmovisor go install and upgrade path case sensitiveness (#12918)
This commit is contained in:
parent
c670fece2a
commit
6f6e7e941b
@ -37,6 +37,12 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
## [Unreleased]
|
||||
<!-- NOTE: when creating a new release, update cosmovisor/cmd/cosmovisor/cmd/version.go:Version -->
|
||||
|
||||
## v1.2.1 2022-08-15
|
||||
|
||||
* [\12918](https://github.com/cosmos/cosmos-sdk/pull/12918) Fix failure when installing cosmovisor via `go install`.
|
||||
* [\12918](https://github.com/cosmos/cosmos-sdk/pull/12918) Automatically set version using module version.
|
||||
* [\12918](https://github.com/cosmos/cosmos-sdk/pull/12918) Fix plan path case sensitivity issue.
|
||||
|
||||
## v1.2.0 2022-07-26
|
||||
|
||||
### Features
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
#!/usr/bin/make -f
|
||||
|
||||
VERSION := $(shell echo $(shell git describe --always --match "cosmovisor/v*") | sed 's/^cosmovisor[/]//')
|
||||
|
||||
all: cosmovisor test
|
||||
|
||||
cosmovisor:
|
||||
go build -ldflags="-X 'github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor/cmd.Version=$(VERSION)'" -mod=readonly ./cmd/cosmovisor
|
||||
go build -mod=readonly ./cmd/cosmovisor
|
||||
|
||||
test:
|
||||
go test -mod=readonly -race ./...
|
||||
|
||||
@ -3,20 +3,20 @@
|
||||
`cosmovisor` is a small process manager for Cosmos SDK application binaries that monitors the governance module for incoming chain upgrade proposals. If it sees a proposal that gets approved, `cosmovisor` can automatically download the new binary, stop the current binary, switch from the old binary to the new one, and finally restart the node with the new binary.
|
||||
|
||||
<!-- TOC -->
|
||||
- [Design](#design)
|
||||
- [Contributing](#contributing)
|
||||
- [Setup](#setup)
|
||||
- [Installation](#installation)
|
||||
- [Command Line Arguments And Environment Variables](#command-line-arguments-and-environment-variables)
|
||||
- [Folder Layout](#folder-layout)
|
||||
- [Usage](#usage)
|
||||
- [Initialization](#initialization)
|
||||
- [Detecting Upgrades](#detecting-upgrades)
|
||||
- [Auto-Download](#auto-download)
|
||||
- [Example: SimApp Upgrade](#example-simapp-upgrade)
|
||||
- [Chain Setup](#chain-setup)
|
||||
|
||||
|
||||
* [Design](#design)
|
||||
* [Contributing](#contributing)
|
||||
* [Setup](#setup)
|
||||
* [Installation](#installation)
|
||||
* [Command Line Arguments And Environment Variables](#command-line-arguments-and-environment-variables)
|
||||
* [Folder Layout](#folder-layout)
|
||||
* [Usage](#usage)
|
||||
* [Initialization](#initialization)
|
||||
* [Detecting Upgrades](#detecting-upgrades)
|
||||
* [Auto-Download](#auto-download)
|
||||
* [Example: SimApp Upgrade](#example-simapp-upgrade)
|
||||
* [Chain Setup](#chain-setup)
|
||||
* [Prepare Cosmovisor and Start the Chain](#prepare-cosmovisor-and-start-the-chain)
|
||||
* [Update App](#update-app)
|
||||
|
||||
## Design
|
||||
|
||||
@ -35,25 +35,27 @@ Cosmovisor is designed to be used as a wrapper for a `Cosmos SDK` app:
|
||||
|
||||
Cosmovisor is part of the Cosmos SDK monorepo, but it's a separate module with it's own release schedule.
|
||||
|
||||
Release branches have the following format `release/cosmovisor/vA.B.x`, where A and B are a number (e.g. `release/cosmovisor/v0.1.x`). Releases are tagged using the following format: `cosmovisor/vA.B.C`.
|
||||
Release branches have the following format `release/cosmovisor/vA.B.x`, where A and B are a number (e.g. `release/cosmovisor/v1.2.x`). Releases are tagged using the following format: `cosmovisor/vA.B.C`.
|
||||
|
||||
## Setup
|
||||
|
||||
### Installation
|
||||
|
||||
You can download Cosmovisor from the [Github releases](https://github.com/cosmos/cosmos-sdk/releases/tag/cosmovisor%2Fv1.2.1).
|
||||
|
||||
To install the latest version of `cosmovisor`, run the following command:
|
||||
|
||||
```sh
|
||||
go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@latest
|
||||
```
|
||||
|
||||
To install a previous version, you can specify the version. IMPORTANT: Chains that use Cosmos-SDK v0.44.3 or earlier (eg v0.44.2) and want to use auto-download feature MUST use Cosmovisor v0.1.0
|
||||
To install a previous version, you can specify the version. IMPORTANT: Chains that use Cosmos-SDK v0.44.3 or earlier (eg v0.44.2) and want to use auto-download feature MUST use `cosmovisor v0.1.0`
|
||||
|
||||
```sh
|
||||
go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@v0.1.0
|
||||
```
|
||||
|
||||
You can run `cosmovisor version` to check the Cosmovisor version (works only with Cosmovisor >1.1.0).
|
||||
Run `cosmovisor version` to check the cosmovisor version.
|
||||
|
||||
You can also install from source by pulling the cosmos-sdk repository and switching to the correct version and building as follows:
|
||||
|
||||
|
||||
@ -1,15 +1,10 @@
|
||||
# Cosmovisor v1.2.0 Release Notes
|
||||
|
||||
### New Features
|
||||
|
||||
With the `cosmovisor init` command, all the necessary folders for using cosmovisor are automatically created. You do not need to manually symlink the chain binary anymore.
|
||||
|
||||
We've added a new configuration option: `DAEMON_RESTART_DELAY` (as env variable). When set, Cosmovisor will wait that delay between the node halt and backup. See the [README](https://github.com/cosmos/cosmos-sdk/blob/main/cosmovisor/README.md#command-line-arguments-and-environment-variables) file for more details.
|
||||
# Cosmovisor v1.2.1 Release Notes
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fix Cosmovisor binary usage for pre-upgrade. Cosmovisor was using the wrong binary when running a `pre-upgrade` command.
|
||||
|
||||
* Fix failure when installing cosmovisor via `go install`.
|
||||
* Fix plan path case sensitivity issue.
|
||||
|
||||
### Changelog
|
||||
|
||||
For more details, please see the [CHANGELOG](https://github.com/cosmos/cosmos-sdk/blob/cosmovisor/v1.1.0/cosmovisor/CHANGELOG.md).
|
||||
For more details, please see the [CHANGELOG](https://github.com/cosmos/cosmos-sdk/blob/cosmovisor/v1.2.1/cosmovisor/CHANGELOG.md).
|
||||
|
||||
@ -144,6 +144,13 @@ func (s *argsTestSuite) TestConfigPaths() {
|
||||
expectGenesis: fmt.Sprintf("/longer/prefix/%s/genesis/bin/yourd", rootName),
|
||||
expectUpgrade: "/longer/prefix/cosmovisor/upgrades/some%20spaces/bin/yourd",
|
||||
},
|
||||
"handle casing": {
|
||||
cfg: Config{Home: "/longer/prefix/", Name: "appd"},
|
||||
upgradeName: "myUpgrade",
|
||||
expectRoot: fmt.Sprintf("/longer/prefix/%s", rootName),
|
||||
expectGenesis: fmt.Sprintf("/longer/prefix/%s/genesis/bin/appd", rootName),
|
||||
expectUpgrade: "/longer/prefix/cosmovisor/upgrades/myUpgrade/bin/appd",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
|
||||
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/cosmovisor"
|
||||
@ -15,12 +16,8 @@ func init() {
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
}
|
||||
|
||||
var (
|
||||
// Version represents Cosmovisor version value. Overwritten during build
|
||||
Version = "1.2.0"
|
||||
// OutputFlag defines the output format flag
|
||||
OutputFlag = "output"
|
||||
)
|
||||
// OutputFlag defines the output format flag
|
||||
var OutputFlag = "output"
|
||||
|
||||
var versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
@ -37,8 +34,17 @@ var versionCmd = &cobra.Command{
|
||||
},
|
||||
}
|
||||
|
||||
func getVersion() string {
|
||||
version, ok := debug.ReadBuildInfo()
|
||||
if !ok {
|
||||
panic("failed to get cosmovisor version")
|
||||
}
|
||||
|
||||
return strings.TrimSpace(version.Main.Version)
|
||||
}
|
||||
|
||||
func printVersion(logger *zerolog.Logger, args []string) error {
|
||||
fmt.Println("cosmovisor version: ", Version)
|
||||
fmt.Printf("cosmovisor version: %s\n", getVersion())
|
||||
|
||||
if err := Run(logger, append([]string{"version"}, args...)); err != nil {
|
||||
return fmt.Errorf("failed to run version command: %w", err)
|
||||
@ -66,7 +72,7 @@ func printVersionJSON(logger *zerolog.Logger, args []string) error {
|
||||
Version string `json:"cosmovisor_version"`
|
||||
AppVersion json.RawMessage `json:"app_version"`
|
||||
}{
|
||||
Version: Version,
|
||||
Version: getVersion(),
|
||||
AppVersion: json.RawMessage(buf.String()),
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@ -126,5 +126,3 @@ require (
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
sigs.k8s.io/yaml v1.3.0 // indirect
|
||||
)
|
||||
|
||||
replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
|
||||
|
||||
@ -373,6 +373,11 @@ github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x
|
||||
github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
|
||||
github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/gogo/gateway v1.1.0 h1:u0SuhL9+Il+UbjM9VIE3ntfRujKbvVpFvNB4HbjeVQ0=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
|
||||
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
|
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||
github.com/golang-sql/sqlexp v0.0.0-20170517235910-f1bb20e5a188/go.mod h1:vXjM/+wXQnTPR4KqTKDgJukSZ6amVRtWMPEjE6sQoK8=
|
||||
@ -642,6 +647,8 @@ github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8
|
||||
github.com/julz/importas v0.1.0/go.mod h1:oSFU2R4XK/P7kNBrnL/FEQlDGN1/6WoxXEjSSXO0DV0=
|
||||
github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
|
||||
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
|
||||
@ -903,8 +910,6 @@ github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqn
|
||||
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 h1:MkV+77GLUNo5oJ0jf870itWm3D0Sjh7+Za9gazKc5LQ=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/regen-network/cosmos-proto v0.3.1 h1:rV7iM4SSFAagvy8RiyhiACbWEGotmqzywPxOvwMdxcg=
|
||||
github.com/regen-network/protobuf v1.3.3-alpha.regen.1 h1:OHEc+q5iIAXpqiqFKeLpu5NwTIkVXUs48vFMwzqpqY4=
|
||||
github.com/regen-network/protobuf v1.3.3-alpha.regen.1/go.mod h1:2DjTFR1HhMQhiWC5sZ4OhQ3+NtdbZ6oBDKQwq5Ou+FI=
|
||||
github.com/remyoudompheng/go-dbus v0.0.0-20121104212943-b7232d34b1d5/go.mod h1:+u151txRmLpwxBmpYn9z3d1sdJdjRPQpsXuYeY9jNls=
|
||||
github.com/remyoudompheng/go-liblzma v0.0.0-20190506200333-81bf2d431b96/go.mod h1:90HvCY7+oHHUKkbeMCiHt1WuFR2/hPJ9QrljDG+v6ls=
|
||||
github.com/remyoudompheng/go-misc v0.0.0-20190427085024-2d6ac652a50e/go.mod h1:80FQABjoFzZ2M5uEa6FUaJYEmqU2UOKojlFVak1UAwI=
|
||||
@ -1437,8 +1442,10 @@ golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxb
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
@ -1624,7 +1631,6 @@ google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfG
|
||||
google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200324203455-a04cca1dde73/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
|
||||
@ -158,9 +158,5 @@ func parseUpgradeInfoFile(filename string) (upgradetypes.Plan, error) {
|
||||
return upgradetypes.Plan{}, fmt.Errorf("invalid upgrade-info.json content; name and height must be not empty; got: %v", ui)
|
||||
}
|
||||
|
||||
// Normalize name to prevent operator error in upgrade name case sensitivity
|
||||
// errors.
|
||||
ui.Name = strings.ToLower(ui.Name)
|
||||
|
||||
return ui, err
|
||||
}
|
||||
|
||||
@ -14,39 +14,52 @@ func TestParseUpgradeInfoFile(t *testing.T) {
|
||||
filename string
|
||||
expectUpgrade upgradetypes.Plan
|
||||
expectErr bool
|
||||
}{{
|
||||
filename: "f1-good.json",
|
||||
expectUpgrade: upgradetypes.Plan{Name: "upgrade1", Info: "some info", Height: 123},
|
||||
expectErr: false,
|
||||
}, {
|
||||
filename: "f2-bad-type.json",
|
||||
expectUpgrade: upgradetypes.Plan{},
|
||||
expectErr: true,
|
||||
}, {
|
||||
filename: "f2-bad-type-2.json",
|
||||
expectUpgrade: upgradetypes.Plan{},
|
||||
expectErr: true,
|
||||
}, {
|
||||
filename: "f3-empty.json",
|
||||
expectUpgrade: upgradetypes.Plan{},
|
||||
expectErr: true,
|
||||
}, {
|
||||
filename: "f4-empty-obj.json",
|
||||
expectUpgrade: upgradetypes.Plan{},
|
||||
expectErr: true,
|
||||
}, {
|
||||
filename: "f5-partial-obj-1.json",
|
||||
expectUpgrade: upgradetypes.Plan{},
|
||||
expectErr: true,
|
||||
}, {
|
||||
filename: "f5-partial-obj-2.json",
|
||||
expectUpgrade: upgradetypes.Plan{},
|
||||
expectErr: true,
|
||||
}, {
|
||||
filename: "unknown.json",
|
||||
expectUpgrade: upgradetypes.Plan{},
|
||||
expectErr: true,
|
||||
}}
|
||||
}{
|
||||
{
|
||||
filename: "f1-good.json",
|
||||
expectUpgrade: upgradetypes.Plan{Name: "upgrade1", Info: "some info", Height: 123},
|
||||
expectErr: false,
|
||||
},
|
||||
{
|
||||
filename: "f2-good.json",
|
||||
expectUpgrade: upgradetypes.Plan{Name: "Upgrade2", Info: "some info", Height: 125},
|
||||
expectErr: false,
|
||||
},
|
||||
{
|
||||
filename: "f2-bad-type.json",
|
||||
expectUpgrade: upgradetypes.Plan{},
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
filename: "f2-bad-type-2.json",
|
||||
expectUpgrade: upgradetypes.Plan{},
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
filename: "f3-empty.json",
|
||||
expectUpgrade: upgradetypes.Plan{},
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
filename: "f4-empty-obj.json",
|
||||
expectUpgrade: upgradetypes.Plan{},
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
filename: "f5-partial-obj-1.json",
|
||||
expectUpgrade: upgradetypes.Plan{},
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
filename: "f5-partial-obj-2.json",
|
||||
expectUpgrade: upgradetypes.Plan{},
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
filename: "unknown.json",
|
||||
expectUpgrade: upgradetypes.Plan{},
|
||||
expectErr: true,
|
||||
}}
|
||||
|
||||
for i := range cases {
|
||||
tc := cases[i]
|
||||
|
||||
1
cosmovisor/testdata/upgrade-files/f2-good.json
vendored
Normal file
1
cosmovisor/testdata/upgrade-files/f2-good.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"name": "Upgrade2", "info": "some info", "height": 125}
|
||||
Loading…
Reference in New Issue
Block a user