Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: update to go1.19 #14132

Merged
merged 2 commits into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/14132.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
build: update to go1.19
```
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ executors:
go:
working_directory: /go/src/github.com/hashicorp/nomad
docker:
- image: docker.mirror.hashicorp.services/golang:1.18.5
- image: docker.mirror.hashicorp.services/golang:1.19
resource_class: medium
environment:
<<: *common_envs
Expand All @@ -470,7 +470,7 @@ executors:
resource_class: large
environment: &machine_env
<<: *common_envs
GOLANG_VERSION: 1.18.5
GOLANG_VERSION: 1.19

go-macos:
working_directory: ~/go/src/github.com/hashicorp/nomad
Expand All @@ -479,7 +479,7 @@ executors:
environment:
<<: *common_envs
GOPATH: /Users/distiller/go
GOLANG_VERSION: 1.18.5
GOLANG_VERSION: 1.19

go-windows:
machine:
Expand All @@ -491,7 +491,7 @@ executors:
GOPATH: c:\gopath
GOBIN: c:\gopath\bin
GOTESTSUM_PATH: c:\tmp\test-reports
GOLANG_VERSION: 1.18.5
GOLANG_VERSION: 1.19
GOTESTSUM_VERSION: 1.7.0
VAULT_VERSION: 1.4.1

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
- 'website/**'
env:
VERBOSE: 1
GO_VERSION: 1.18.5
GO_VERSION: 1.19
GOBIN: /usr/local/bin
GOTESTARCH: amd64
CONSUL_VERSION: 1.11.3
Expand Down
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.18.5
1.19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be good to also set a patch version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the .0 release chops off the .0 (we do the same thing!)

5 changes: 3 additions & 2 deletions client/allocdir/alloc_dir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ func TestAllocDir_BuildAlloc(t *testing.T) {
}

// HACK: This function is copy/pasted from client.testutil to prevent a test
// import cycle, due to testutil transitively importing allocdir. This
// should be fixed after DriverManager is implemented.
//
// import cycle, due to testutil transitively importing allocdir. This
// should be fixed after DriverManager is implemented.
func MountCompatible(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("Windows does not support mount")
Expand Down
5 changes: 3 additions & 2 deletions client/allochealth/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,9 @@ func (t *Tracker) setTaskHealth(healthy, terminal bool) {
// returns true if health is propagated and no more health monitoring is needed
//
// todo: this is currently being shared by watchConsulEvents and watchNomadEvents,
// and must be split up if/when we support registering services (and thus checks)
// of different providers.
//
// and must be split up if/when we support registering services (and thus checks)
// of different providers.
func (t *Tracker) setCheckHealth(healthy bool) bool {
t.lock.Lock()
defer t.lock.Unlock()
Expand Down
4 changes: 2 additions & 2 deletions client/allocrunner/taskrunner/envoy_bootstrap_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ func newEnvoyBootstrapHook(c *envoyBootstrapHookConfig) *envoyBootstrapHook {
}

// getConsulNamespace will resolve the Consul namespace, choosing between
// - agent config (low precedence)
// - task group config (high precedence)
// - agent config (low precedence)
// - task group config (high precedence)
func (h *envoyBootstrapHook) getConsulNamespace() string {
var namespace string
if h.consulConfig.Namespace != "" {
Expand Down
6 changes: 3 additions & 3 deletions client/allocrunner/taskrunner/envoy_version_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ func (h *envoyVersionHook) tweakImage(configured string, supported map[string][]
// semver sanitizes the envoy version string coming from Consul into the format
// used by the Envoy project when publishing images (i.e. proper semver). This
// resulting string value does NOT contain the 'v' prefix for 2 reasons:
// 1) the version library does not include the 'v'
// 2) its plausible unofficial images use the 3 numbers without the prefix for
// tagging their own images
// 1. the version library does not include the 'v'
// 2. its plausible unofficial images use the 3 numbers without the prefix for
// tagging their own images
func semver(chosen string) (string, error) {
v, err := version.NewVersion(chosen)
if err != nil {
Expand Down
24 changes: 12 additions & 12 deletions client/allocrunner/taskrunner/plugin_supervisor_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import (
// to their requisite plugin manager.
//
// It provides a few things to a plugin task running inside Nomad. These are:
// * A mount to the `csi_plugin.mount_dir` where the plugin will create its csi.sock
// * A mount to `local/csi` that node plugins will use to stage volume mounts.
// * When the task has started, it starts a loop of attempting to connect to the
// plugin, to perform initial fingerprinting of the plugins capabilities before
// notifying the plugin manager of the plugin.
// - A mount to the `csi_plugin.mount_dir` where the plugin will create its csi.sock
// - A mount to `local/csi` that node plugins will use to stage volume mounts.
// - When the task has started, it starts a loop of attempting to connect to the
// plugin, to perform initial fingerprinting of the plugins capabilities before
// notifying the plugin manager of the plugin.
type csiPluginSupervisorHook struct {
logger hclog.Logger
alloc *structs.Allocation
Expand Down Expand Up @@ -247,13 +247,13 @@ func (h *csiPluginSupervisorHook) Poststart(_ context.Context, _ *interfaces.Tas
// the passed in context is terminated.
//
// The supervisor works by:
// - Initially waiting for the plugin to become available. This loop is expensive
// and may do things like create new gRPC Clients on every iteration.
// - After receiving an initial healthy status, it will inform the plugin catalog
// of the plugin, registering it with the plugins fingerprinted capabilities.
// - We then perform a more lightweight check, simply probing the plugin on a less
// frequent interval to ensure it is still alive, emitting task events when this
// status changes.
// - Initially waiting for the plugin to become available. This loop is expensive
// and may do things like create new gRPC Clients on every iteration.
// - After receiving an initial healthy status, it will inform the plugin catalog
// of the plugin, registering it with the plugins fingerprinted capabilities.
// - We then perform a more lightweight check, simply probing the plugin on a less
// frequent interval to ensure it is still alive, emitting task events when this
// status changes.
//
// Deeper fingerprinting of the plugin is implemented by the csimanager.
func (h *csiPluginSupervisorHook) ensureSupervisorLoop(ctx context.Context) {
Expand Down
8 changes: 4 additions & 4 deletions client/allocrunner/taskrunner/remotetask_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ func (h *remoteTaskHook) Name() string {
}

// Prestart performs 2 remote task driver related tasks:
// 1. If there is no local handle, see if there is a handle propagated from a
// previous alloc to be restored.
// 2. If the alloc is lost make sure the task signal is set to detach instead
// of kill.
// 1. If there is no local handle, see if there is a handle propagated from a
// previous alloc to be restored.
// 2. If the alloc is lost make sure the task signal is set to detach instead
// of kill.
func (h *remoteTaskHook) Prestart(ctx context.Context, req *interfaces.TaskPrestartRequest, resp *interfaces.TaskPrestartResponse) error {
if h.tr.getDriverHandle() != nil {
// Driver handle already exists so don't try to load remote
Expand Down
10 changes: 5 additions & 5 deletions client/allocrunner/taskrunner/restarts/restarts.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ func (r *RestartTracker) GetCount() int {

// GetState returns the tasks next state given the set exit code and start
// error. One of the following states are returned:
// * TaskRestarting - Task should be restarted
// * TaskNotRestarting - Task should not be restarted and has exceeded its
// restart policy.
// * TaskTerminated - Task has terminated successfully and does not need a
// restart.
// - TaskRestarting - Task should be restarted
// - TaskNotRestarting - Task should not be restarted and has exceeded its
// restart policy.
// - TaskTerminated - Task has terminated successfully and does not need a
// restart.
//
// If TaskRestarting is returned, the duration is how long to wait until
// starting the task again.
Expand Down
4 changes: 2 additions & 2 deletions client/allocrunner/taskrunner/task_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,7 @@ func (tr *TaskRunner) UpdateStats(ru *cstructs.TaskResourceUsage) {
}
}

//TODO Remove Backwardscompat or use tr.Alloc()?
// TODO Remove Backwardscompat or use tr.Alloc()?
func (tr *TaskRunner) setGaugeForMemory(ru *cstructs.TaskResourceUsage) {
alloc := tr.Alloc()
var allocatedMem float32
Expand Down Expand Up @@ -1445,7 +1445,7 @@ func (tr *TaskRunner) setGaugeForMemory(ru *cstructs.TaskResourceUsage) {
}
}

//TODO Remove Backwardscompat or use tr.Alloc()?
// TODO Remove Backwardscompat or use tr.Alloc()?
func (tr *TaskRunner) setGaugeForCPU(ru *cstructs.TaskResourceUsage) {
alloc := tr.Alloc()
var allocatedCPU float32
Expand Down
6 changes: 3 additions & 3 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ type ClientStatsReporter interface {
}

// AllocRunner is the interface implemented by the core alloc runner.
//TODO Create via factory to allow testing Client with mock AllocRunners.
// TODO Create via factory to allow testing Client with mock AllocRunners.
type AllocRunner interface {
Alloc() *structs.Allocation
AllocState() *arstate.State
Expand Down Expand Up @@ -1252,8 +1252,8 @@ func (c *Client) restoreState() error {
// wait until it gets allocs from server to launch them.
//
// See:
// * https://github.com/hashicorp/nomad/pull/6207
// * https://github.com/hashicorp/nomad/issues/5984
// - https://github.com/hashicorp/nomad/pull/6207
// - https://github.com/hashicorp/nomad/issues/5984
//
// COMPAT(0.12): remove once upgrading from 0.9.5 is no longer supported
func (c *Client) hasLocalState(alloc *structs.Allocation) bool {
Expand Down
3 changes: 2 additions & 1 deletion client/dynamicplugins/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ type PluginInfo struct {

// PluginConnectionInfo is the data required to connect to the plugin.
// note: We currently only support Unix Domain Sockets, but this may be expanded
// to support other connection modes in the future.
//
// to support other connection modes in the future.
type PluginConnectionInfo struct {
// SocketPath is the path to the plugins api socket.
SocketPath string
Expand Down
19 changes: 10 additions & 9 deletions client/pluginmanager/csimanager/doc.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
/**
/*
*
csimanager manages locally running CSI Plugins on a Nomad host, and provides a
few different interfaces.

It provides:
- a pluginmanager.PluginManager implementation that is used to fingerprint and
heartbeat local node plugins
- (TODO) a csimanager.AttachmentWaiter implementation that can be used to wait for an
external CSIVolume to be attached to the node before returning
- (TODO) a csimanager.NodeController implementation that is used to manage the node-local
portions of the CSI specification, and encompassess volume staging/publishing
- (TODO) a csimanager.VolumeChecker implementation that can be used by hooks to ensure
their volumes are healthy(ish)
- a pluginmanager.PluginManager implementation that is used to fingerprint and
heartbeat local node plugins
- (TODO) a csimanager.AttachmentWaiter implementation that can be used to wait for an
external CSIVolume to be attached to the node before returning
- (TODO) a csimanager.NodeController implementation that is used to manage the node-local
portions of the CSI specification, and encompassess volume staging/publishing
- (TODO) a csimanager.VolumeChecker implementation that can be used by hooks to ensure
their volumes are healthy(ish)
*/
package csimanager
1 change: 0 additions & 1 deletion client/state/08types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
// changed over the life-cycle of the alloc_runner in Nomad 0.8.
//
// https://github.com/hashicorp/nomad/blob/v0.8.6/client/alloc_runner.go#L146-L153
//
type allocRunnerMutableState08 struct {
// AllocClientStatus does not need to be upgraded as it is computed
// from task states.
Expand Down
17 changes: 8 additions & 9 deletions client/state/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,14 @@ func backupDB(bdb *bbolt.DB, dst string) error {

// UpgradeAllocs upgrades the boltdb schema. Example 0.8 schema:
//
// * allocations
// * 15d83e8a-74a2-b4da-3f17-ed5c12895ea8
// * echo
// - simple-all (342 bytes)
// - alloc (2827 bytes)
// - alloc-dir (166 bytes)
// - immutable (15 bytes)
// - mutable (1294 bytes)
//
// allocations
// 15d83e8a-74a2-b4da-3f17-ed5c12895ea8
// echo
// simple-all (342 bytes)
// alloc (2827 bytes)
// alloc-dir (166 bytes)
// immutable (15 bytes)
// mutable (1294 bytes)
func UpgradeAllocs(logger hclog.Logger, tx *boltdd.Tx) error {
btx := tx.BoltTx()
allocationsBucket := btx.Bucket(allocationsBucketName)
Expand Down
1 change: 0 additions & 1 deletion client/taskenv/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,6 @@ func (b *Builder) SetDriverNetwork(n *drivers.DriverNetwork) *Builder {
// Handled by setAlloc -> otherPorts:
//
// Task: NOMAD_TASK_{IP,PORT,ADDR}_<task>_<label> # Always host values
//
func buildNetworkEnv(envMap map[string]string, nets structs.Networks, driverNet *drivers.DriverNetwork) {
for _, n := range nets {
for _, p := range n.ReservedPorts {
Expand Down
6 changes: 3 additions & 3 deletions command/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
// Config is the configuration for the Nomad agent.
//
// time.Duration values have two parts:
// - a string field tagged with an hcl:"foo" and json:"-"
// - a time.Duration field in the same struct and a call to duration
// in config_parse.go ParseConfigFile
// - a string field tagged with an hcl:"foo" and json:"-"
// - a time.Duration field in the same struct and a call to duration
// in config_parse.go ParseConfigFile
//
// All config structs should have an ExtraKeysHCL field to check for
// unexpected keys
Expand Down
2 changes: 1 addition & 1 deletion command/agent/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ func TestConfig_templateNetworkInterface(t *testing.T) {
{
name: "insignificant whitespace",
clientConfig: &ClientConfig{
Enabled: true,
Enabled: true,
NetworkInterface: ` {{GetAllInterfaces | attr "name" }}`,
},
expectedInterface: iface.Name,
Expand Down
1 change: 0 additions & 1 deletion command/agent/consul/check_watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func newFakeCheckRestarter(w *checkWatcher, allocID, taskName, checkName string,
// watching and is normally fulfilled by a TaskRunner.
//
// Restarts are recorded in the []restarts field and re-Watch the check.
//func (c *fakeCheckRestarter) Restart(source, reason string, failure bool) {
func (c *fakeCheckRestarter) Restart(ctx context.Context, event *structs.TaskEvent, failure bool) error {
c.mu.Lock()
defer c.mu.Unlock()
Expand Down
3 changes: 1 addition & 2 deletions command/agent/consul/namespaces_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ func (ns *NamespacesClient) allowable(now time.Time) bool {

// List returns a list of Consul Namespaces.
//
// TODO(shoenig): return empty string instead of "default" when namespaces are not
// enabled. (Coming in followup PR).
// TODO(shoenig): return empty string instead of "default" when namespaces are not enabled. (Coming in followup PR).
func (ns *NamespacesClient) List() ([]string, error) {
if !ns.allowable(time.Now()) {
// TODO(shoenig): lets return the empty string instead, that way we do not
Expand Down
7 changes: 4 additions & 3 deletions command/agent/consul/self.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ func Namespaces(info Self) bool {
// feature returns whether the indicated feature is enabled by Consul and the
// associated License.
// possible values as of v1.9.5+ent:
// Automated Backups, Automated Upgrades, Enhanced Read Scalability,
// Network Segments, Redundancy Zone, Advanced Network Federation,
// Namespaces, SSO, Audit Logging
//
// Automated Backups, Automated Upgrades, Enhanced Read Scalability,
// Network Segments, Redundancy Zone, Advanced Network Federation,
// Namespaces, SSO, Audit Logging
func feature(name string, info Self) bool {
lic, licOK := info["Stats"]["license"].(map[string]interface{})
if !licOK {
Expand Down
Loading