Skip to content

Conversation

hc-github-team-nomad-core
Copy link
Contributor

Backport

This PR is auto-generated from #26178 to be assessed for backporting due to the inclusion of the label backport/1.10.x.

The below text is copied from the body of the original PR.


Description

The nomad monitor export command introduces the ability for nomad to export logs a given agent has written to journald or to the nomad log file. Journald logs can be requested for a specific period of time while we just return the agent's entire nomad log file. Introducing this RPC is a prerequisite for adding journald logs to the nomad support bundle.

Pasting a link to a comment deep in the thread regarding fixes for inconsistencies related to ending the stream.
#26178 (comment)

Testing & Reproduction steps

Links

Contributor Checklist

  • Changelog Entry If this PR changes user-facing behavior, please generate and add a
    changelog entry using the make cl command.
  • Testing Please add tests to cover any new functionality or to demonstrate bug fixes and
    ensure regressions will be caught.
  • Documentation If the change impacts user-facing functionality such as the CLI, API, UI,
    and job configuration, please update the Nomad website documentation to reflect this. Refer to
    the website README for docs guidelines. Please also consider whether the
    change requires notes within the upgrade guide.

Pulled this from the Contributor checklist for new cli commands, I struck out a few items that didn't seem to fit this use case but I'm happy to revisit them if I was wrong there.

CLI Command Checklist

  • Consider similar commands in Consul, Vault, and other tools. Is there
    prior art we should match? Arguments, flags, env vars, etc?
  • New file in command/ or in an existing file if a subcommand
  • Test new command in command/ package
  • Implement autocomplete
  • Update help text
  • Register new command in command/commands.go
  • Implement and test new HTTP endpoint in command/agent/<command>_endpoint.go
  • Register new URL paths in command/agent/http.go
  • Implement and test new RPC endpoint in nomad/<command>_endpoint.go
  • Implement and test new Client RPC endpoint in
    client/<command>_endpoint.go (For client endpoints like Filesystem only)
  • Implement and test new nomad/structs/ package Request and Response structs (cstructs, but still)
  • Implement and test new api/ package helper methods
    I added a monitorHelper function to more cleanly share the existing monitor code in /api/agent.go. I did not add an additional test for the helper or the MonitorExport command. Mostly because I'd have to update the Client Config structs to be able to set the LogFile value on the api Client. But the only difference between the Monitor & MonitorExport commands in api/agent.go is which path is passed to the monitorHelper and helper is exercised in the existing monitor tests.

* [ ] For nested commands make sure all intermediary subcommands exist (for
example, nomad acl, nomad acl policy, and nomad acl policy apply must
all be valid commands)

* [ ] If the command has a status subcommand consider adding a search context
in nomad/search_endpoint.go and update command/status.go

* [ ] Implement -json (returns raw API response)
* [ ] Implement -t (format API response using gotemplate)
* [ ] Implement -verbose (expands truncated UUIDs, adds other detail)
* [ ] Implement and test new api/ package Request and Response structs

Docs

Reviewer Checklist

  • Backport Labels Please add the correct backport labels as described by the internal
    backporting document.
  • Commit Type Ensure the correct merge method is selected which should be "squash and merge"
    in the majority of situations. The main exceptions are long-lived feature branches or merges where
    history should be preserved.
  • Enterprise PRs If this is an enterprise only PR, please add any required changelog entry
    within the public repository.

Overview of commits

@tehut tehut merged commit 44c0cd1 into release/1.10.x Aug 1, 2025
32 checks passed
@tehut tehut deleted the backport/f-NMD-855/monitor_external/duly-included-spider branch August 1, 2025 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants