Skip to content

Conversation

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

Backport

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

🚨

Warning automatic cherry-pick of commits failed. If the first commit failed,
you will see a blank no-op commit below. If at least one commit succeeded, you
will see the cherry-picked commits up to, not including, the commit where
the merge conflict occurred.

The person who merged in the original PR is:
@tehut
This person should resolve the merge-conflict(s) by either:

  • Manually completing the cherry picks into this branch
  • Creating a new branch and manually cherry-picking all commits being backported

merge conflict error: POST https://api.github.com/repos/hashicorp/nomad/merges: 409 Merge conflict []

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


Description

Support requested the ability to retrieve historical journald logs as part of the debug capture returned by nomad operator debug. PR #26178 introduced a MonitorExport() RPC capable of streaming the contents of an agent's log file (if file logging is enabled) or its journald logs.

This PR adds that functionality to operator debug with the inclusion of either a log-file-export=true flag or a -log-lookback=<duration> flag. An agent's historical log capture runs alongside the capture of running logs and results in both monitor.log and monitor_export.log files appearing in each agent's debug capture.

Note to reviewers: I exported a test helper from PR #26178 for this new test case. The helper generates a golden log file for testing against stream results. And since the helper is now exported, I also refactored a few tests from that PR to use it as well since they were using the same mechanism.

Testing & Reproduction steps

To run locally:

  1. Build branch
  2. Run a debug command with one of the historical log operators e.g nomad operator debug -duration=10s -interval=5s -log-file-export=true
  3. Unzip the debug archive to display a monitor.log and monitor_export.log file for each agent in the cluster.
    

Example below

Screenshot 2025-08-01 at 4 35 25 PM

Links

Requested in: NMD-141

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.

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

Copy link

hashicorp-cla-app bot commented Aug 4, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes


temp seems not to be a GitHub user.
You need a GitHub account to be able to sign the CLA.
If you have already a GitHub account, please add the email address used for this commit to your account.

Have you signed the CLA already but the status is still pending? Recheck it.

#26410)

* Add -log-file-export and -log-lookback commands to add historical log to
debug capture
* use monitor.PrepFile() helper for other historical log tests
@tehut tehut force-pushed the backport/f-NMD-141-debug-export/trivially-causal-goose branch from a1fd2e2 to c3b00dd Compare August 4, 2025 21:32
@tehut tehut marked this pull request as ready for review August 4, 2025 22:18
@tehut tehut requested review from a team as code owners August 4, 2025 22:19
@tehut tehut merged commit 636857d into release/1.10.x Aug 5, 2025
38 checks passed
@tehut tehut deleted the backport/f-NMD-141-debug-export/trivially-causal-goose branch August 5, 2025 17:15
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.

4 participants