Skip to content

api/s/r/swarm: log backend errors at Debug level#45008

Merged
neersighted merged 1 commit intomoby:masterfrom
corhere:fix-spammy-cluster-api-logs
Feb 15, 2023
Merged

api/s/r/swarm: log backend errors at Debug level#45008
neersighted merged 1 commit intomoby:masterfrom
corhere:fix-spammy-cluster-api-logs

Conversation

@corhere
Copy link
Copy Markdown
Contributor

@corhere corhere commented Feb 15, 2023

- What I did
The errors are already returned to the client in the API response, so logging them to the daemon log is redundant. Log the errors at level Debug so as not to pollute the end-users' daemon logs with noise.

Refactor the logs to use structured fields. Add the request context to the log entry so that logrus hooks could annotate the log entries with contextual information about the API request in the hypothetical future.

- How I did it
Grepped for all logrus calls in cluster_routes.go and hand-edited them all.

- How to verify it
Code review?

- Description for the changelog

  • Errors handling Swarm API requests are now logged to the daemon log at Debug level instead of Error. These errors will continue to be returned to the client in the API request responses.

- A picture of a cute animal (not mandatory but encouraged)

The errors are already returned to the client in the API response, so
logging them to the daemon log is redundant. Log the errors at level
Debug so as not to pollute the end-users' daemon logs with noise.

Refactor the logs to use structured fields. Add the request context to
the log entry so that logrus hooks could annotate the log entries with
contextual information about the API request in the hypothetical future.

Fixes moby#44997

Signed-off-by: Cory Snider <csnider@mirantis.com>
@corhere corhere added area/api API kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. area/swarm area/daemon Core Engine labels Feb 15, 2023
@corhere corhere added this to the v-next milestone Feb 15, 2023
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

@neersighted neersighted merged commit 33eb63e into moby:master Feb 15, 2023
@xinfengliu
Copy link
Copy Markdown
Contributor

Thank you all for this fix. I see the label is v-next. Will we get it to v23.0 as well?

@neersighted
Copy link
Copy Markdown
Member

I'm fine with cherry-picking this to the 23.0 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api API area/daemon Core Engine area/swarm kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. process/cherry-picked

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improving logging level for "not found" log message

4 participants