Skip to content

Commit

Permalink
Upgrade go-msgpack to v2 2.1.1
Browse files Browse the repository at this point in the history
And set the `time.Time` option to use the go-msgpack-1.1.5-compatible
encoding in all the places, since that is the (now previous) version
in `go.mod`.

v2 2.1.1 was specifically designe to honor backwards compatibility
with 1.1.5 and 0.5.5, and to clean up the code base to be more
maintainable. There may performance lost with the 1.1.5 to 2.1.1
migration since the fastpath code was removed, but the increased safety
is probably worth it. See
[the release notes for go-msgkack 2.1.0](https://github.com/hashicorp/go-msgpack/releases/tag/v2.1.0)
for more details.

I tested this by running this code, and booting up a cluster with
a node also running the prior version of Nomad (before the upgrade).
Before I made the changes to set the right `time.Time` option, the
previous-version node would throw a bunch of time-decoding errors.
After fixing the option, the node came up smoothly, even after
changing leadership between them.

This relies on
- [ ] hashicorp/serf#705
- [ ] hashicorp/raft-boltdb#38
- [ ] hashicorp/raft#577
- [ ] hashicorp/memberlist#292

and maybe
- [ ] hashicorp/net-rpc-msgpackrpc#12
  • Loading branch information
Christopher Swenson committed Oct 25, 2023
1 parent de28760 commit 84f9688
Show file tree
Hide file tree
Showing 89 changed files with 204 additions and 167 deletions.
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ deps: ## Install build and development dependencies
go install gotest.tools/gotestsum@v1.10.0
go install github.com/hashicorp/hcl/v2/cmd/hclfmt@d0c4fa8b0bbc2e4eeccd1ed2a32c2089ed8c5cf1
go install github.com/golang/protobuf/protoc-gen-go@v1.3.4
go install github.com/hashicorp/go-msgpack/codec/codecgen@v1.1.5
go install github.com/hashicorp/go-msgpack/v2/codec/codecgen@v2.1.1
go install github.com/bufbuild/buf/cmd/buf@v0.36.0
go install github.com/hashicorp/go-changelog/cmd/changelog-build@latest
go install golang.org/x/tools/cmd/stringer@v0.1.12
Expand Down
2 changes: 1 addition & 1 deletion client/agent_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"io"
"time"

"github.com/hashicorp/go-msgpack/codec"
"github.com/hashicorp/go-msgpack/v2/codec"

"github.com/hashicorp/nomad/command/agent/host"
"github.com/hashicorp/nomad/command/agent/monitor"
Expand Down
2 changes: 1 addition & 1 deletion client/agent_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"testing"
"time"

"github.com/hashicorp/go-msgpack/codec"
"github.com/hashicorp/go-msgpack/v2/codec"
"github.com/hashicorp/nomad/acl"
"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/client/config"
Expand Down
2 changes: 1 addition & 1 deletion client/alloc_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"time"

"github.com/armon/go-metrics"
"github.com/hashicorp/go-msgpack/codec"
"github.com/hashicorp/go-msgpack/v2/codec"
"github.com/hashicorp/nomad/acl"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/helper/pointer"
Expand Down
2 changes: 1 addition & 1 deletion client/alloc_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"testing"
"time"

"github.com/hashicorp/go-msgpack/codec"
"github.com/hashicorp/go-msgpack/v2/codec"
"github.com/hashicorp/nomad/acl"
"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/client/config"
Expand Down
2 changes: 1 addition & 1 deletion client/fs_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"time"

metrics "github.com/armon/go-metrics"
"github.com/hashicorp/go-msgpack/codec"
"github.com/hashicorp/go-msgpack/v2/codec"
"github.com/hpcloud/tail/watch"

"github.com/hashicorp/nomad/acl"
Expand Down
2 changes: 1 addition & 1 deletion client/fs_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"testing"
"time"

"github.com/hashicorp/go-msgpack/codec"
"github.com/hashicorp/go-msgpack/v2/codec"
"github.com/hashicorp/nomad/acl"
"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/client/allocdir"
Expand Down
2 changes: 1 addition & 1 deletion client/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"time"

metrics "github.com/armon/go-metrics"
"github.com/hashicorp/go-msgpack/codec"
"github.com/hashicorp/go-msgpack/v2/codec"
"github.com/hashicorp/nomad/client/servers"
"github.com/hashicorp/nomad/helper"
inmem "github.com/hashicorp/nomad/helper/codec"
Expand Down
2 changes: 1 addition & 1 deletion client/state/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"os"

hclog "github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-msgpack/codec"
"github.com/hashicorp/go-msgpack/v2/codec"
"github.com/hashicorp/nomad/client/dynamicplugins"
"github.com/hashicorp/nomad/helper/boltdd"
"github.com/hashicorp/nomad/nomad/structs"
Expand Down
2 changes: 1 addition & 1 deletion client/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package structs

//go:generate codecgen -c github.com/hashicorp/go-msgpack/codec -st codec -d 102 -t codegen_generated -o structs.generated.go structs.go
//go:generate codecgen -c github.com/hashicorp/go-msgpack/v2/codec -st codec -d 102 -t codegen_generated -o structs.generated.go structs.go

import (
"errors"
Expand Down
2 changes: 1 addition & 1 deletion client/testutil/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"testing"
"time"

"github.com/hashicorp/go-msgpack/codec"
"github.com/hashicorp/go-msgpack/v2/codec"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion command/agent/agent_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

"github.com/docker/docker/pkg/ioutils"
log "github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-msgpack/codec"
"github.com/hashicorp/go-msgpack/v2/codec"
"github.com/hashicorp/nomad/api"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/command/agent/host"
Expand Down
2 changes: 1 addition & 1 deletion command/agent/agent_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"testing"
"time"

msgpackrpc "github.com/hashicorp/net-rpc-msgpackrpc"
msgpackrpc "github.com/hashicorp/net-rpc-msgpackrpc/v2"
"github.com/hashicorp/nomad/acl"
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/ci"
Expand Down
2 changes: 1 addition & 1 deletion command/agent/alloc_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"github.com/golang/snappy"
"github.com/gorilla/websocket"
"github.com/hashicorp/go-msgpack/codec"
"github.com/hashicorp/go-msgpack/v2/codec"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/plugins/drivers"
Expand Down
2 changes: 1 addition & 1 deletion command/agent/event_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"strings"

"github.com/docker/docker/pkg/ioutils"
"github.com/hashicorp/go-msgpack/codec"
"github.com/hashicorp/go-msgpack/v2/codec"
"github.com/hashicorp/nomad/nomad/structs"
"golang.org/x/sync/errgroup"
)
Expand Down
2 changes: 1 addition & 1 deletion command/agent/fs_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"strings"

"github.com/docker/docker/pkg/ioutils"
"github.com/hashicorp/go-msgpack/codec"
"github.com/hashicorp/go-msgpack/v2/codec"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/nomad/structs"
)
Expand Down
2 changes: 1 addition & 1 deletion command/agent/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/gorilla/websocket"
"github.com/hashicorp/go-connlimit"
log "github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-msgpack/codec"
"github.com/hashicorp/go-msgpack/v2/codec"
multierror "github.com/hashicorp/go-multierror"
"github.com/rs/cors"
"golang.org/x/time/rate"
Expand Down
2 changes: 1 addition & 1 deletion command/agent/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"testing"
"time"

"github.com/hashicorp/go-msgpack/codec"
"github.com/hashicorp/go-msgpack/v2/codec"
"github.com/hashicorp/nomad/acl"
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/ci"
Expand Down
2 changes: 1 addition & 1 deletion command/agent/operator_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"strings"
"time"

"github.com/hashicorp/go-msgpack/codec"
"github.com/hashicorp/go-msgpack/v2/codec"
"github.com/hashicorp/raft"

"github.com/hashicorp/nomad/api"
Expand Down
2 changes: 1 addition & 1 deletion command/data_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"text/template"

"github.com/Masterminds/sprig/v3"
"github.com/hashicorp/go-msgpack/codec"
"github.com/hashicorp/go-msgpack/v2/codec"
)

var (
Expand Down
5 changes: 4 additions & 1 deletion command/raft_tools/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import (
)

func RaftState(p string) (store *raftboltdb.BoltStore, firstIdx uint64, lastIdx uint64, err error) {
s, err := raftboltdb.NewBoltStore(p)
s, err := raftboltdb.New(raftboltdb.Options{
Path: p,
MsgpackUseNewTimeFormat: true,
})
if err != nil {
return nil, 0, 0, fmt.Errorf("failed to open raft logs: %v", err)
}
Expand Down
30 changes: 20 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ replace (
// Nomad is built using the current source of the API module.
replace github.com/hashicorp/nomad/api => ./api

replace github.com/hashicorp/nomad/client => ./client

require (
github.com/LK4D4/joincontext v0.0.0-20171026170139-1724345da6d5
github.com/Masterminds/sprig/v3 v3.2.3
Expand Down Expand Up @@ -61,14 +63,14 @@ require (
github.com/hashicorp/go-immutable-radix/v2 v2.0.0
github.com/hashicorp/go-kms-wrapping/v2 v2.0.12
github.com/hashicorp/go-memdb v1.3.4
github.com/hashicorp/go-msgpack v1.1.5
github.com/hashicorp/go-msgpack/v2 v2.1.1
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-plugin v1.4.10
github.com/hashicorp/go-secure-stdlib/listenerutil v0.1.4
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2
github.com/hashicorp/go-set v0.1.8
github.com/hashicorp/go-set/v2 v2.0.0-alpha.3
github.com/hashicorp/go-sockaddr v1.0.2
github.com/hashicorp/go-sockaddr v1.0.5
github.com/hashicorp/go-syslog v1.0.0
github.com/hashicorp/go-uuid v1.0.3
github.com/hashicorp/go-version v1.6.0
Expand All @@ -77,8 +79,8 @@ require (
github.com/hashicorp/hcl/v2 v2.9.2-0.20220525143345-ab3cae0737bc
github.com/hashicorp/hil v0.0.0-20210521165536-27a72121fd40
github.com/hashicorp/logutils v1.0.0
github.com/hashicorp/memberlist v0.5.0
github.com/hashicorp/net-rpc-msgpackrpc v0.0.0-20151116020338-a14192a58a69
github.com/hashicorp/memberlist v0.5.1-0.20231024164941-f2362678b85d
github.com/hashicorp/net-rpc-msgpackrpc/v2 v2.0.0
github.com/hashicorp/nomad/api v0.0.0-20230103221135-ce00d683f9be
github.com/hashicorp/raft v1.5.0
github.com/hashicorp/raft-autopilot v0.1.6
Expand All @@ -91,7 +93,7 @@ require (
github.com/kr/pretty v0.3.1
github.com/kr/text v0.2.0
github.com/mattn/go-colorable v0.1.13
github.com/miekg/dns v1.1.50
github.com/miekg/dns v1.1.56
github.com/mitchellh/cli v1.1.5
github.com/mitchellh/colorstring v0.0.0-20150917214807-8631ce90f286
github.com/mitchellh/copystructure v1.2.0
Expand Down Expand Up @@ -127,7 +129,7 @@ require (
go.uber.org/goleak v1.2.1
golang.org/x/crypto v0.14.0
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63
golang.org/x/sync v0.3.0
golang.org/x/sync v0.4.0
golang.org/x/sys v0.13.0
golang.org/x/time v0.3.0
google.golang.org/grpc v1.55.0
Expand Down Expand Up @@ -197,7 +199,7 @@ require (
github.com/gojuno/minimock/v3 v3.0.6 // indirect
github.com/golang-jwt/jwt/v4 v4.4.3 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
Expand All @@ -213,7 +215,7 @@ require (
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7 // indirect
github.com/hashicorp/go-secure-stdlib/reloadutil v0.1.1 // indirect
github.com/hashicorp/go-secure-stdlib/tlsutil v0.1.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/mdns v1.0.4 // indirect
github.com/hashicorp/vault/api/auth/kubernetes v0.3.0 // indirect
github.com/hashicorp/vic v1.5.1-0.20190403131502-bbfe86ec9443 // indirect
Expand Down Expand Up @@ -268,12 +270,12 @@ require (
github.com/vmware/govmomi v0.18.0 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect
golang.org/x/tools v0.14.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.114.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand All @@ -285,3 +287,11 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
kernel.org/pub/linux/libs/security/libcap/psx v1.2.66 // indirect
)

replace github.com/hashicorp/raft => /Users/swenson/projects/raft

replace github.com/hashicorp/raft-boltdb/v2 => /Users/swenson/projects/raft-boltdb/v2

replace github.com/hashicorp/memberlist => /Users/swenson/projects/memberlist

replace github.com/hashicorp/serf => /Users/swenson/projects/serf
Loading

0 comments on commit 84f9688

Please sign in to comment.