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

Show node attribute in node-status #313

Merged
merged 1 commit into from
Oct 22, 2015
Merged

Show node attribute in node-status #313

merged 1 commit into from
Oct 22, 2015

Conversation

achanda
Copy link
Contributor

@achanda achanda commented Oct 21, 2015

Adds node attributes to the node-status command when a single
node ID is passed

Closes #303

@achanda
Copy link
Contributor Author

achanda commented Oct 21, 2015

Currently this looks like this:

Abhishek@dev:~/gosrc/bin$ nomad node-status 2649b1ef-de9a-1427-9a19-42b899725ece
ID         = 2649b1ef-de9a-1427-9a19-42b899725ece
Name       = dev
Class      = <none>
Datacenter = dc1
Drain      = false
Status     = ready
Attributes = cpu.numcores:128, cpu.frequency:2600.000000, driver.docker.version:1.8.3, hostname:dev, platform.gce.machine-type:n1-standard-16, storage.bytestotal:105654812672, driver.docker:1, driver.exec:1, driver.rkt.version:rkt version 0.9.0, memory.totalbytes:63332859904, platform.gce.scheduling.on-host-maintenance:MIGRATE, storage.bytesfree:91570016256, driver.java.runtime:OpenJDK Runtime Environment (IcedTea 2.5.6) (7u79-2.5.6-0ubuntu1.14.04.1), os.version:14.04, platform.gce.cpu-platform:Intel Sandy Bridge, platform.gce.network.default:true, platform.gce.tag.https-server:true, driver.java:1, driver.java.vm:OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode), driver.rkt:1, platform.gce.network.default.ip:10.240.209.200, platform.gce.scheduling.automatic-restart:TRUE, os.name:ubuntu, platform.gce.hostname:dev.c.cloudblocks.cloudscaling.com.internal, platform.gce.network.default.external-ip.0:104.197.131.232, cpu.totalcompute:332800.000000, driver.java.version:1.7.0_79, driver.rkt.appc.version:0.9., kernel.version:3.19.0-30-generic, network.ip-address:10.240.209.200, storage.volume:/dev/sda1, arch:amd64, cpu.modelname:Intel(R) Xeon(R) CPU @ 2.60GHz, kernel.name:linux, platform.gce.id:13085678475098123138, platform.gce.zone:us-central1-a, platform.gce.tag.http-server:true

### Allocations
ID  EvalID  JobID  TaskGroup  DesiredStatus  ClientStatus

Trying to see how to make this equally human and machine readable. Open to feedback.

@@ -111,6 +116,7 @@ func (c *NodeStatusCommand) Run(args []string) int {
fmt.Sprintf("Datacenter|%s", node.Datacenter),
fmt.Sprintf("Drain|%v", node.Drain),
fmt.Sprintf("Status|%s", node.Status),
fmt.Sprintf("Attributes|%s", strings.Join(attributes, ", ")),
Copy link
Contributor

Choose a reason for hiding this comment

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

indent is off by one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's because of the + sign. If you click on 'View', you will see that it lines up.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is because that line uses spaces instead of tabs. gofmt should fix it. @achanda Not sure which editor you use but I have mine set to run gofmt when I save a file -- helps with things like this.

var attributes []string
for k, v := range node.Attributes {
attributes = append(attributes, fmt.Sprintf("%s:%s", k, v))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would sort the keys and then create the attributes by iterating through the sorted keys and making the list. That way looking for a particular attribute in the output will be a lot easier!

Adds node attributes to the node-status command when a single
node ID is passed
@achanda
Copy link
Contributor Author

achanda commented Oct 22, 2015

Example looks like

Abhishek@dev:~/gosrc/bin$ nomad node-status cb31a305-3d23-b1ea-a06c-eb9adb37965b
ID         = cb31a305-3d23-b1ea-a06c-eb9adb37965b
Name       = dev
Class      = <none>
Datacenter = dc1
Drain      = false
Status     = ready
Attributes = arch:amd64, cpu.frequency:2600.000000, cpu.modelname:Intel(R) Xeon(R) CPU @ 2.60GHz, cpu.numcores:128, cpu.totalcompute:332800.000000, driver.docker:1, driver.docker.version:1.8.3, driver.exec:1, driver.java:1, driver.java.runtime:OpenJDK Runtime Environment (IcedTea 2.5.6) (7u79-2.5.6-0ubuntu1.14.04.1), driver.java.version:1.7.0_79, driver.java.vm:OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode), driver.rkt:1, driver.rkt.appc.version:0.9., driver.rkt.version:rkt version 0.9.0, hostname:dev, kernel.name:linux, kernel.version:3.19.0-30-generic, memory.totalbytes:63332859904, network.ip-address:10.240.209.200, os.name:ubuntu, os.version:14.04, platform.gce.cpu-platform:Intel Sandy Bridge, platform.gce.hostname:dev.c.cloudblocks.cloudscaling.com.internal, platform.gce.id:13085678475098123138, platform.gce.machine-type:n1-standard-16, platform.gce.network.default:true, platform.gce.network.default.external-ip.0:104.197.131.232, platform.gce.network.default.ip:10.240.209.200, platform.gce.scheduling.automatic-restart:TRUE, platform.gce.scheduling.on-host-maintenance:MIGRATE, platform.gce.tag.http-server:true, platform.gce.tag.https-server:true, platform.gce.zone:us-central1-a, storage.bytesfree:91253256192, storage.bytestotal:105654812672, storage.volume:/dev/sda1

### Allocations
ID  EvalID  JobID  TaskGroup  DesiredStatus  ClientStatus

@dadgar
Copy link
Contributor

dadgar commented Oct 22, 2015

Awesome! Thanks @achanda

dadgar added a commit that referenced this pull request Oct 22, 2015
Show node attribute in node-status
@dadgar dadgar merged commit 10ae428 into hashicorp:master Oct 22, 2015
@achanda achanda deleted the attributes branch October 22, 2015 17:03
benbuzbee pushed a commit to benbuzbee/nomad that referenced this pull request Jul 21, 2022
InmemTransport: respect timeout when sending
@github-actions
Copy link

github-actions bot commented May 7, 2023

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants