diff --git a/acl/policy.go b/acl/policy.go index d1d5dcc4c..07fa36457 100644 --- a/acl/policy.go +++ b/acl/policy.go @@ -174,7 +174,10 @@ func expandNamespacePolicy(policy string) []string { NamespaceCapabilityReadScalingPolicy, } - write := append(read, []string{ + write := make([]string, len(read)) + copy(write, read) + + write = append(write, []string{ NamespaceCapabilityScaleJob, NamespaceCapabilitySubmitJob, NamespaceCapabilityDispatchJob, diff --git a/client/client.go b/client/client.go index e351101b9..927fe4a0e 100644 --- a/client/client.go +++ b/client/client.go @@ -2833,8 +2833,12 @@ func (c *Client) setGaugeForMemoryStats(nodeID string, hStats *stats.HostStats, // setGaugeForCPUStats proxies metrics for CPU specific statistics func (c *Client) setGaugeForCPUStats(nodeID string, hStats *stats.HostStats, baseLabels []metrics.Label) { + + labels := make([]metrics.Label, len(baseLabels)) + copy(labels, baseLabels) + for _, cpu := range hStats.CPU { - labels := append(baseLabels, metrics.Label{ + labels := append(labels, metrics.Label{ Name: "cpu", Value: cpu.CPU, }) @@ -2848,8 +2852,12 @@ func (c *Client) setGaugeForCPUStats(nodeID string, hStats *stats.HostStats, bas // setGaugeForDiskStats proxies metrics for disk specific statistics func (c *Client) setGaugeForDiskStats(nodeID string, hStats *stats.HostStats, baseLabels []metrics.Label) { + + labels := make([]metrics.Label, len(baseLabels)) + copy(labels, baseLabels) + for _, disk := range hStats.DiskStats { - labels := append(baseLabels, metrics.Label{ + labels := append(labels, metrics.Label{ Name: "disk", Value: disk.Device, }) @@ -2877,7 +2885,7 @@ func (c *Client) setGaugeForAllocationStats(nodeID string, baseLabels []metrics. metrics.SetGaugeWithLabels([]string{"client", "allocated", "cpu"}, float32(allocated.Flattened.Cpu.CpuShares), baseLabels) for _, n := range allocated.Flattened.Networks { - labels := append(baseLabels, metrics.Label{ + labels := append(baseLabels, metrics.Label{ //nolint:gocritic Name: "device", Value: n.Device, }) @@ -2903,7 +2911,7 @@ func (c *Client) setGaugeForAllocationStats(nodeID string, baseLabels []metrics. } unallocatedMbits := n.MBits - usedMbits - labels := append(baseLabels, metrics.Label{ + labels := append(baseLabels, metrics.Label{ //nolint:gocritic Name: "device", Value: n.Device, }) diff --git a/client/pluginmanager/drivermanager/manager.go b/client/pluginmanager/drivermanager/manager.go index 5f5a19bc7..f74963bb0 100644 --- a/client/pluginmanager/drivermanager/manager.go +++ b/client/pluginmanager/drivermanager/manager.go @@ -258,7 +258,7 @@ func (m *manager) waitForFirstFingerprint(ctx context.Context, cancel context.Ca mu.Lock() defer mu.Unlock() - updated := append(driversByStatus[lastHeath], name) + updated := append(driversByStatus[lastHeath], name) //nolint:gocritic driversByStatus[lastHeath] = updated } diff --git a/command/alloc_status.go b/command/alloc_status.go index 769711657..edb649c0a 100644 --- a/command/alloc_status.go +++ b/command/alloc_status.go @@ -556,7 +556,7 @@ func (c *AllocStatusCommand) outputTaskResources(alloc *api.Allocation, task str c.Ui.Output("Task Resources") var addr []string for _, nw := range resource.Networks { - ports := append(nw.DynamicPorts, nw.ReservedPorts...) + ports := append(nw.DynamicPorts, nw.ReservedPorts...) //nolint:gocritic for _, port := range ports { addr = append(addr, fmt.Sprintf("%v: %v:%v\n", port.Label, nw.IP, port.Value)) } diff --git a/helper/noxssrw/noxssrw.go b/helper/noxssrw/noxssrw.go index d9991974b..a5b1cd28a 100644 --- a/helper/noxssrw/noxssrw.go +++ b/helper/noxssrw/noxssrw.go @@ -131,7 +131,7 @@ func (w *NoXSSResponseWriter) Write(p []byte) (int, error) { } // >= 512 bytes available, set the Content-Type and flush. - all := append(w.buf, p...) + all := append(w.buf, p...) //nolint:gocritic contentType := http.DetectContentType(all) // Prefix match to exclude the character set which may be user diff --git a/scheduler/util.go b/scheduler/util.go index de009e6fc..b87e75e4d 100644 --- a/scheduler/util.go +++ b/scheduler/util.go @@ -238,7 +238,7 @@ func diffSystemAllocs( // Build a mapping of nodes to all their allocs. nodeAllocs := make(map[string][]*structs.Allocation, len(allocs)) for _, alloc := range allocs { - nallocs := append(nodeAllocs[alloc.NodeID], alloc) + nallocs := append(nodeAllocs[alloc.NodeID], alloc) //nolint:gocritic nodeAllocs[alloc.NodeID] = nallocs }