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

api: nomad debug new /agent/host #8325

Merged
merged 28 commits into from
Jul 2, 2020
Merged

Conversation

langmartin
Copy link
Contributor

/agent/host is a new API endpoint that provides debug information about the agent's host environment from the perspective of the nomad process. #8306

@langmartin langmartin self-assigned this Jul 1, 2020
@langmartin langmartin added this to the 0.12.0 milestone Jul 1, 2020
@langmartin langmartin marked this pull request as ready for review July 1, 2020 15:47
Copy link
Contributor

@drewbailey drewbailey left a comment

Choose a reason for hiding this comment

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

lgtm!

api/agent.go Outdated Show resolved Hide resolved
Copy link
Member

@schmichael schmichael left a comment

Choose a reason for hiding this comment

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

Looks great overall! Redaction is a blocker, but otherwise we can ship anytime.

command/agent/host/host.go Outdated Show resolved Hide resolved
Comment on lines +11 to +42
// mountedPaths produces a list of mounts
func mountedPaths() []string {
fh, err := os.Open("/proc/mounts")
if err != nil {
return []string{err.Error()}
}
rd := bufio.NewReader(fh)

var paths []string
for {
str, err := rd.ReadString('\n')
if err != nil {
break
}

ln := strings.Split(str, " ")
switch ln[2] {
case "autofs", "binfmt_misc", "cgroup", "debugfs",
"devpts", "devtmpfs",
"fusectl", "fuse.lxcfs",
"hugetlbfs", "mqueue",
"proc", "pstore", "rpc_pipefs", "securityfs",
"sysfs", "tmpfs", "vboxsf":
continue
default:
}

paths = append(paths, ln[1])
}

return paths
}
Copy link
Member

Choose a reason for hiding this comment

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

I think this is our 3rd implementation of mount point enumeration:

  1. Used in /v1/client/stats - https://github.com/hashicorp/nomad/blob/v0.12.0-beta2/client/stats/host.go#L183-L209
  2. Used in client node fingerprinting - https://github.com/hashicorp/nomad/blob/v0.12.0-beta2/client/fingerprint/storage_unix.go#L16

We don't have to fix this up for 0.12.0, but would you mind investigating if there's an opportunity to share code here and file an issue if so?

Comment on lines +24 to +26
for _, c := range "ABCDEFGHIJKLMNOPQRSTUVWXYZ" {
d := string(c) + ":\\"
_, err := os.Stat(d)
Copy link
Member

Choose a reason for hiding this comment

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

Enumerating mount points on Windows is as simple as a b c 1 2 3 you and ... 🎶

command/agent/host/windows.go Outdated Show resolved Hide resolved
nomad/structs/structs.go Outdated Show resolved Hide resolved
@langmartin langmartin merged commit bde973e into master Jul 2, 2020
@langmartin langmartin deleted the f-nomad-debug-agent-host branch July 2, 2020 13:51
@github-actions
Copy link

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 Dec 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants