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

agent: Fixed a bug where syslog error messages marked as notice. #24820

Merged
merged 2 commits into from
Jan 15, 2025

Conversation

jrasell
Copy link
Member

@jrasell jrasell commented Jan 9, 2025

The mapping between Nomad log level identifiers and syslog priorities did not handle the error level string correctly.

The change includes a new function which can be used for lookups in all places the conversion is needed. This function makes the translation easier to test.

Testing & Reproduction steps

Running on a Linux workstation (Ubuntu 24.04) I added the following lines to the /etc/rsyslog.conf before restarting rsyslog via sudo service rsyslog restart.

$template verbose, "%syslogseverity-text%, %syslogfacility%, %timegenerated%, %HOSTNAME%, %syslogtag%, %msg%\n"
*.* /var/log/all-messages.log;verbose

I then ran Nomad via sudo -i nomad agent -config=/home/jrasell/config.hcl using the following configuration to ensure errors are generated in the log:

enable_syslog = true
data_dir      = "/var/lib/nomad"

server {
  enabled          = true
  bootstrap_expect = 3
}

Error log lines are successfully and correctly entered via the err priority:

err, 16, Jan  9 10:29:42, workstation-0, nomad[26105]:,  worker: failed to dequeue evaluation: worker_id=c933e716-c5dc-c73a-571f-0bccb052a727 error="No cluster leader"
err, 16, Jan  9 10:29:42, workstation-0, nomad[26105]:,  worker: failed to dequeue evaluation: worker_id=5d982fbd-1d5f-c0eb-b091-f14d8afdd178 error="No cluster leader"
err, 16, Jan  9 10:29:42, workstation-0, nomad[26105]:,  worker: failed to dequeue evaluation: worker_id=a5c2f0dd-88d6-347f-4527-ef2b1d653987 error="No cluster leader"
err, 16, Jan  9 10:29:42, workstation-0, nomad[26105]:,  worker: failed to dequeue evaluation: worker_id=60463b64-adc9-d344-ad95-21b4dbd4214b error="No cluster leader"

Links

Jira: https://hashicorp.atlassian.net/browse/NET-11972

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.

The mapping between Nomad log level identifiers and syslog
priorities did not handle the error level string correctly.
@jrasell jrasell self-assigned this Jan 9, 2025
@jrasell jrasell added backport/ent/1.7.x+ent Changes are backported to 1.7.x+ent backport/ent/1.8.x+ent Changes are backported to 1.8.x+ent backport/1.9.x backport to 1.9.x release line labels Jan 9, 2025
@jrasell jrasell marked this pull request as ready for review January 9, 2025 11:19
@jrasell jrasell requested review from a team as code owners January 9, 2025 11:19
@jrasell jrasell merged commit 8d201a8 into main Jan 15, 2025
39 checks passed
@jrasell jrasell deleted the b-NET-11972 branch January 15, 2025 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/ent/1.7.x+ent Changes are backported to 1.7.x+ent backport/ent/1.8.x+ent Changes are backported to 1.8.x+ent backport/1.9.x backport to 1.9.x release line
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants