mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
cli: operator debug: respect NOMAD_REGION env var (#25716)
properly filter out regions other than the one specified like the -namespace flag does
This commit is contained in:
3
.changelog/25716.txt
Normal file
3
.changelog/25716.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:bug
|
||||
cli: Respect NOMAD_REGION environment variable in operator debug command
|
||||
```
|
||||
@@ -51,10 +51,12 @@ type Meta struct {
|
||||
// Whether to force colorized output
|
||||
forceColor bool
|
||||
|
||||
// The region to send API requests
|
||||
// The value of the -region CLI flag to send with API requests
|
||||
// note: does not reflect any environment variables
|
||||
region string
|
||||
|
||||
// namespace to send API requests
|
||||
// The value of the -namespace CLI flag to send with API requests
|
||||
// note: does not reflect any environment variables
|
||||
namespace string
|
||||
|
||||
// token is used for ACLs to access privileged information
|
||||
@@ -203,6 +205,18 @@ func (m *Meta) Client() (*api.Client, error) {
|
||||
return api.NewClient(m.clientConfig())
|
||||
}
|
||||
|
||||
// Namespace returns the Nomad namespace used for API calls,
|
||||
// from either the -namespace flag, or the NOMAD_NAMESPACE env var.
|
||||
func (m *Meta) Namespace() string {
|
||||
return m.clientConfig().Namespace
|
||||
}
|
||||
|
||||
// Region returns the Nomad region used for API calls,
|
||||
// from either the -region flag, or the NOMAD_REGION env var.
|
||||
func (m *Meta) Region() string {
|
||||
return m.clientConfig().Region
|
||||
}
|
||||
|
||||
func (m *Meta) allNamespaces() bool {
|
||||
return m.clientConfig().Namespace == api.AllNamespacesNamespace
|
||||
}
|
||||
|
||||
@@ -512,7 +512,6 @@ func (c *OperatorDebugCommand) Run(args []string) int {
|
||||
}
|
||||
|
||||
c.opts = &api.QueryOptions{
|
||||
Region: c.Meta.region,
|
||||
AllowStale: allowStale,
|
||||
AuthToken: c.Meta.token,
|
||||
}
|
||||
@@ -612,7 +611,7 @@ func (c *OperatorDebugCommand) Run(args []string) int {
|
||||
}
|
||||
|
||||
// Filter for servers matching criteria
|
||||
c.serverIDs, err = filterServerMembers(c.members, serverIDs, c.region)
|
||||
c.serverIDs, err = filterServerMembers(c.members, serverIDs, c.Meta.Region())
|
||||
if err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("Failed to parse server list; err: %v", err))
|
||||
return 1
|
||||
@@ -638,8 +637,8 @@ func (c *OperatorDebugCommand) Run(args []string) int {
|
||||
c.Ui.Output("Starting debugger...")
|
||||
c.Ui.Output("")
|
||||
c.Ui.Output(fmt.Sprintf("Nomad CLI Version: %s", version.GetVersion().FullVersionNumber(true)))
|
||||
c.Ui.Output(fmt.Sprintf(" Region: %s", c.region))
|
||||
c.Ui.Output(fmt.Sprintf(" Namespace: %s", c.namespace))
|
||||
c.Ui.Output(fmt.Sprintf(" Region: %s", c.Meta.Region()))
|
||||
c.Ui.Output(fmt.Sprintf(" Namespace: %s", c.Meta.Namespace()))
|
||||
c.Ui.Output(fmt.Sprintf(" Servers: (%d/%d) %v", serverCaptureCount, serversFound, c.serverIDs))
|
||||
c.Ui.Output(fmt.Sprintf(" Clients: (%d/%d) %v", nodeCaptureCount, nodesFound, c.nodeIDs))
|
||||
if nodeCaptureCount > 0 && nodeCaptureCount == c.maxNodes {
|
||||
|
||||
Reference in New Issue
Block a user