Skip to content

Commit

Permalink
Merge branch 'hashicorp:main' into fix_log_streaming_missing_frames
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadiuss committed Dec 21, 2021
2 parents b5e29fe + 2d4e5b8 commit ab692ae
Show file tree
Hide file tree
Showing 95 changed files with 2,460 additions and 391 deletions.
3 changes: 3 additions & 0 deletions .changelog/11544.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:feature
ui: Add filters to allocations table in jobs/job/allocation view
```
3 changes: 3 additions & 0 deletions .changelog/11545.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
ui: Add filters to the allocation list in the client and task group details pages
```
3 changes: 3 additions & 0 deletions .changelog/11555.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
agent: Added `ui` configuration block
```
3 changes: 3 additions & 0 deletions .changelog/11557.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
ui: Display the Consul and Vault links configured in the agent
```
3 changes: 3 additions & 0 deletions .changelog/11675.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
cli: Added a `nomad eval list` command.
```
3 changes: 3 additions & 0 deletions .changelog/11678.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
cli: Fixed a bug where the `-stale` flag was not respected by `nomad operator debug`
```
3 changes: 3 additions & 0 deletions .changelog/11682.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
cli: Made the `operator raft info`, `operator raft logs`, `operator raft state`, and `operator snapshot state` commands visible to command line help.
```
3 changes: 3 additions & 0 deletions .changelog/11687.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
ui: Display section title in the navigation breadcrumbs
```
3 changes: 3 additions & 0 deletions .changelog/11710.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
api: Updated the evaluations list API to respect wildcard namespaces
```
3 changes: 3 additions & 0 deletions .changelog/11712.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
scheduler: Fixed a performance bug where `spread` and node affinity can cause a job to take longer than the nack timeout to be evaluated.
```
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ linters-settings:
- commentFormatting
- deprecatedComment
staticcheck:
# Only enable a single check to start.
# I(jrasell) will work on enabling additional checks when possible.
checks: ["ST1020"]
checks: ["ST1020", "ST1016"]

issues:
exclude:
Expand Down
11 changes: 11 additions & 0 deletions api/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,17 @@ func (a *Agent) Members() (*ServerMembers, error) {
return resp, nil
}

// Members is used to query all of the known server members
// with the ability to set QueryOptions
func (a *Agent) MembersOpts(opts *QueryOptions) (*ServerMembers, error) {
var resp *ServerMembers
_, err := a.client.query("/v1/agent/members", &resp, opts)
if err != nil {
return nil, err
}
return resp, nil
}

// ForceLeave is used to eject an existing node from the cluster.
func (a *Agent) ForceLeave(node string) error {
_, err := a.client.write("/v1/agent/force-leave?node="+node, nil, nil, nil)
Expand Down
9 changes: 9 additions & 0 deletions api/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ func (n *Nodes) PrefixList(prefix string) ([]*NodeListStub, *QueryMeta, error) {
return n.List(&QueryOptions{Prefix: prefix})
}

func (n *Nodes) PrefixListOpts(prefix string, opts *QueryOptions) ([]*NodeListStub, *QueryMeta, error) {
if opts == nil {
opts = &QueryOptions{Prefix: prefix}
} else {
opts.Prefix = prefix
}
return n.List(opts)
}

// Info is used to query a specific node by its ID.
func (n *Nodes) Info(nodeID string, q *QueryOptions) (*Node, *QueryMeta, error) {
var resp Node
Expand Down
3 changes: 2 additions & 1 deletion api/regions.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ func (c *Client) Regions() *Regions {
return &Regions{client: c}
}

// List returns a list of all of the regions.
// List returns a list of all of the regions from the server
// that serves the request. It is never forwarded to a leader.
func (r *Regions) List() ([]string, error) {
var resp []string
if _, err := r.client.query("/v1/regions", &resp, nil); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion client/allocdir/task_dir_nonlinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
package allocdir

// currently a noop on non-Linux platforms
func (d *TaskDir) unmountSpecialDirs() error {
func (t *TaskDir) unmountSpecialDirs() error {
return nil
}
4 changes: 2 additions & 2 deletions client/allocrunner/csi_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ func newCSIHook(ar *allocRunner, logger hclog.Logger, alloc *structs.Allocation,
}
}

func (h *csiHook) shouldRun() bool {
tg := h.alloc.Job.LookupTaskGroup(h.alloc.TaskGroup)
func (c *csiHook) shouldRun() bool {
tg := c.alloc.Job.LookupTaskGroup(c.alloc.TaskGroup)
for _, vol := range tg.Volumes {
if vol.Type == structs.VolumeTypeCSI {
return true
Expand Down
4 changes: 2 additions & 2 deletions client/allocrunner/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ func (s *State) Copy() *State {
}

// ClientTerminalStatus returns if the client status is terminal and will no longer transition
func (a *State) ClientTerminalStatus() bool {
switch a.ClientStatus {
func (s *State) ClientTerminalStatus() bool {
switch s.ClientStatus {
case structs.AllocClientStatusComplete, structs.AllocClientStatusFailed, structs.AllocClientStatusLost:
return true
default:
Expand Down
4 changes: 2 additions & 2 deletions client/allocrunner/taskrunner/script_check_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,9 @@ const (
// updateTTL updates the state to Consul, performing an exponential backoff
// in the case where the check isn't registered in Consul to avoid a race between
// service registration and the first check.
func (s *scriptCheck) updateTTL(ctx context.Context, msg, state string) error {
func (sc *scriptCheck) updateTTL(ctx context.Context, msg, state string) error {
for attempts := 0; ; attempts++ {
err := s.ttlUpdater.UpdateTTL(s.id, s.consulNamespace, msg, state)
err := sc.ttlUpdater.UpdateTTL(sc.id, sc.consulNamespace, msg, state)
if err == nil {
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3105,8 +3105,8 @@ func (g *group) Go(f func()) {
}()
}

func (c *group) AddCh(ch <-chan struct{}) {
c.Go(func() {
func (g *group) AddCh(ch <-chan struct{}) {
g.Go(func() {
<-ch
})
}
Expand Down
10 changes: 5 additions & 5 deletions client/fingerprint_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ func (fm *FingerprintManager) getNode() *structs.Node {
// identifying allowlisted and denylisted fingerprints/drivers. Then, for
// those which require periotic checking, it starts a periodic process for
// each.
func (fp *FingerprintManager) Run() error {
func (fm *FingerprintManager) Run() error {
// First, set up all fingerprints
cfg := fp.getConfig()
cfg := fm.getConfig()
// COMPAT(1.0) using inclusive language, whitelist is kept for backward compatibility.
allowlistFingerprints := cfg.ReadStringListToMap("fingerprint.allowlist", "fingerprint.whitelist")
allowlistFingerprintsEnabled := len(allowlistFingerprints) > 0
// COMPAT(1.0) using inclusive language, blacklist is kept for backward compatibility.
denylistFingerprints := cfg.ReadStringListToMap("fingerprint.denylist", "fingerprint.blacklist")

fp.logger.Debug("built-in fingerprints", "fingerprinters", fingerprint.BuiltinFingerprints())
fm.logger.Debug("built-in fingerprints", "fingerprinters", fingerprint.BuiltinFingerprints())

var availableFingerprints []string
var skippedFingerprints []string
Expand All @@ -96,12 +96,12 @@ func (fp *FingerprintManager) Run() error {
availableFingerprints = append(availableFingerprints, name)
}

if err := fp.setupFingerprinters(availableFingerprints); err != nil {
if err := fm.setupFingerprinters(availableFingerprints); err != nil {
return err
}

if len(skippedFingerprints) != 0 {
fp.logger.Debug("fingerprint modules skipped due to allow/denylist",
fm.logger.Debug("fingerprint modules skipped due to allow/denylist",
"skipped_fingerprinters", skippedFingerprints)
}

Expand Down
8 changes: 6 additions & 2 deletions command/agent/agent_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ func (s *HTTPServer) AgentSelfRequest(resp http.ResponseWriter, req *http.Reques
member = srv.LocalMember()
aclObj, err = srv.ResolveToken(secret)
} else {
// Not a Server; use the Client for token resolution
// Not a Server, so use the Client for token resolution. Note
// this gets forwarded to a server with AllowStale = true if
// the local ACL cache TTL has expired (30s by default)
aclObj, err = s.agent.Client().ResolveToken(secret)
}

Expand Down Expand Up @@ -677,7 +679,9 @@ func (s *HTTPServer) AgentHostRequest(resp http.ResponseWriter, req *http.Reques
aclObj, err = srv.ResolveToken(secret)
enableDebug = srv.GetConfig().EnableDebug
} else {
// Not a Server; use the Client for token resolution
// Not a Server, so use the Client for token resolution. Note
// this gets forwarded to a server with AllowStale = true if
// the local ACL cache TTL has expired (30s by default)
aclObj, err = s.agent.Client().ResolveToken(secret)
enableDebug = s.agent.Client().GetConfig().EnableDebug
}
Expand Down
16 changes: 8 additions & 8 deletions command/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -737,8 +737,8 @@ type Telemetry struct {
}

// PrefixFilters parses the PrefixFilter field and returns a list of allowed and blocked filters
func (t *Telemetry) PrefixFilters() (allowed, blocked []string, err error) {
for _, rule := range t.PrefixFilter {
func (a *Telemetry) PrefixFilters() (allowed, blocked []string, err error) {
for _, rule := range a.PrefixFilter {
if rule == "" {
continue
}
Expand Down Expand Up @@ -1448,8 +1448,8 @@ func (a *ACLConfig) Merge(b *ACLConfig) *ACLConfig {
}

// Merge is used to merge two server configs together
func (a *ServerConfig) Merge(b *ServerConfig) *ServerConfig {
result := *a
func (s *ServerConfig) Merge(b *ServerConfig) *ServerConfig {
result := *s

if b.Enabled {
result.Enabled = true
Expand Down Expand Up @@ -1583,13 +1583,13 @@ func (a *ServerConfig) Merge(b *ServerConfig) *ServerConfig {
result.EnabledSchedulers = append(result.EnabledSchedulers, b.EnabledSchedulers...)

// Copy the start join addresses
result.StartJoin = make([]string, 0, len(a.StartJoin)+len(b.StartJoin))
result.StartJoin = append(result.StartJoin, a.StartJoin...)
result.StartJoin = make([]string, 0, len(s.StartJoin)+len(b.StartJoin))
result.StartJoin = append(result.StartJoin, s.StartJoin...)
result.StartJoin = append(result.StartJoin, b.StartJoin...)

// Copy the retry join addresses
result.RetryJoin = make([]string, 0, len(a.RetryJoin)+len(b.RetryJoin))
result.RetryJoin = append(result.RetryJoin, a.RetryJoin...)
result.RetryJoin = make([]string, 0, len(s.RetryJoin)+len(b.RetryJoin))
result.RetryJoin = append(result.RetryJoin, s.RetryJoin...)
result.RetryJoin = append(result.RetryJoin, b.RetryJoin...)

return &result
Expand Down
4 changes: 2 additions & 2 deletions command/alloc_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func (l *AllocExecCommand) Synopsis() string {
return "Execute commands in task"
}

func (c *AllocExecCommand) AutocompleteFlags() complete.Flags {
return mergeAutocompleteFlags(c.Meta.AutocompleteFlags(FlagSetClient),
func (l *AllocExecCommand) AutocompleteFlags() complete.Flags {
return mergeAutocompleteFlags(l.Meta.AutocompleteFlags(FlagSetClient),
complete.Flags{
"--task": complete.PredictAnything,
"-job": complete.PredictAnything,
Expand Down
4 changes: 2 additions & 2 deletions command/alloc_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ func (f *AllocFSCommand) Synopsis() string {
return "Inspect the contents of an allocation directory"
}

func (c *AllocFSCommand) AutocompleteFlags() complete.Flags {
return mergeAutocompleteFlags(c.Meta.AutocompleteFlags(FlagSetClient),
func (f *AllocFSCommand) AutocompleteFlags() complete.Flags {
return mergeAutocompleteFlags(f.Meta.AutocompleteFlags(FlagSetClient),
complete.Flags{
"-H": complete.PredictNothing,
"-verbose": complete.PredictNothing,
Expand Down
4 changes: 2 additions & 2 deletions command/alloc_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func (l *AllocLogsCommand) Synopsis() string {
return "Streams the logs of a task."
}

func (c *AllocLogsCommand) AutocompleteFlags() complete.Flags {
return mergeAutocompleteFlags(c.Meta.AutocompleteFlags(FlagSetClient),
func (l *AllocLogsCommand) AutocompleteFlags() complete.Flags {
return mergeAutocompleteFlags(l.Meta.AutocompleteFlags(FlagSetClient),
complete.Flags{
"-stderr": complete.PredictNothing,
"-verbose": complete.PredictNothing,
Expand Down
4 changes: 2 additions & 2 deletions command/alloc_restart.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type AllocRestartCommand struct {
Meta
}

func (a *AllocRestartCommand) Help() string {
func (c *AllocRestartCommand) Help() string {
helpText := `
Usage: nomad alloc restart [options] <allocation> <task>
Expand Down Expand Up @@ -153,7 +153,7 @@ func validateTaskExistsInAllocation(taskName string, alloc *api.Allocation) erro
return fmt.Errorf("Could not find task named: %s, found:\n%s", taskName, formatList(foundTaskNames))
}

func (a *AllocRestartCommand) Synopsis() string {
func (c *AllocRestartCommand) Synopsis() string {
return "Restart a running allocation"
}

Expand Down
4 changes: 2 additions & 2 deletions command/alloc_signal.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type AllocSignalCommand struct {
Meta
}

func (a *AllocSignalCommand) Help() string {
func (c *AllocSignalCommand) Help() string {
helpText := `
Usage: nomad alloc signal [options] <allocation> <task>
Expand Down Expand Up @@ -141,7 +141,7 @@ func (c *AllocSignalCommand) Run(args []string) int {
return 0
}

func (a *AllocSignalCommand) Synopsis() string {
func (c *AllocSignalCommand) Synopsis() string {
return "Signal a running allocation"
}

Expand Down
4 changes: 2 additions & 2 deletions command/alloc_stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type AllocStopCommand struct {
Meta
}

func (a *AllocStopCommand) Help() string {
func (c *AllocStopCommand) Help() string {
helpText := `
Usage: nomad alloc stop [options] <allocation>
Alias: nomad stop
Expand Down Expand Up @@ -142,6 +142,6 @@ func (c *AllocStopCommand) Run(args []string) int {
return mon.monitor(resp.EvalID)
}

func (a *AllocStopCommand) Synopsis() string {
func (c *AllocStopCommand) Synopsis() string {
return "Stop and reschedule a running allocation"
}
13 changes: 9 additions & 4 deletions command/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@ func Commands(metaPtr *Meta, agentUi cli.Ui) map[string]cli.CommandFactory {
Meta: meta,
}, nil
},
"eval list": func() (cli.Command, error) {
return &EvalListCommand{
Meta: meta,
}, nil
},
"eval status": func() (cli.Command, error) {
return &EvalStatusCommand{
Meta: meta,
Expand Down Expand Up @@ -535,17 +540,17 @@ func Commands(metaPtr *Meta, agentUi cli.Ui) map[string]cli.CommandFactory {
Meta: meta,
}, nil
},
"operator raft _info": func() (cli.Command, error) {
"operator raft info": func() (cli.Command, error) {
return &OperatorRaftInfoCommand{
Meta: meta,
}, nil
},
"operator raft _logs": func() (cli.Command, error) {
"operator raft logs": func() (cli.Command, error) {
return &OperatorRaftLogsCommand{
Meta: meta,
}, nil
},
"operator raft _state": func() (cli.Command, error) {
"operator raft state": func() (cli.Command, error) {
return &OperatorRaftStateCommand{
Meta: meta,
}, nil
Expand All @@ -566,7 +571,7 @@ func Commands(metaPtr *Meta, agentUi cli.Ui) map[string]cli.CommandFactory {
Meta: meta,
}, nil
},
"operator snapshot _state": func() (cli.Command, error) {
"operator snapshot state": func() (cli.Command, error) {
return &OperatorSnapshotStateCommand{
Meta: meta,
}, nil
Expand Down
Loading

0 comments on commit ab692ae

Please sign in to comment.