Skip to content

Commit 2fe35cb

Browse files
straistarumergify[bot]
authored andcommitted
Fix error logging for provider failures (#10217)
* Fix error logging for provider failures * Add changelog fragment * Omit nil error detail from logs (cherry picked from commit 0a5c2a4)
1 parent e0891ea commit 2fe35cb

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# REQUIRED
2+
# Kind can be one of:
3+
# - breaking-change: a change to previously-documented behavior
4+
# - deprecation: functionality that is being removed in a later release
5+
# - bug-fix: fixes a problem in a previous version
6+
# - enhancement: extends functionality but does not break or fix existing behavior
7+
# - feature: new functionality
8+
# - known-issue: problems that we are aware of in a given version
9+
# - security: impacts on the security of a product or a user’s deployment.
10+
# - upgrade: important information for someone upgrading from a prior version
11+
# - other: does not fit into any of the other categories
12+
kind: bug-fix
13+
14+
# REQUIRED for all kinds
15+
# Change summary; a 80ish characters long description of the change.
16+
summary: Fix an incorrectly formatted log message when a provider fails
17+
18+
# REQUIRED for breaking-change, deprecation, known-issue
19+
# Long description; in case the summary is not enough to describe the change
20+
# this field accommodate a description without length limits.
21+
# description:
22+
23+
# REQUIRED for breaking-change, deprecation, known-issue
24+
# impact:
25+
26+
# REQUIRED for breaking-change, deprecation, known-issue
27+
# action:
28+
29+
# REQUIRED for all kinds
30+
# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
31+
component: elastic-agent
32+
33+
# AUTOMATED
34+
# OPTIONAL to manually add other PR URLs
35+
# PR URL: A link the PR that added the changeset.
36+
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
37+
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
38+
# Please provide it if you are adding a fragment for a different PR.
39+
# pr: https://github.com/owner/repo/1234
40+
41+
# AUTOMATED
42+
# OPTIONAL to manually add other issue URLs
43+
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
44+
# If not present is automatically filled by the tooling with the issue linked to the PR number.
45+
# issue: https://github.com/owner/repo/1234

internal/pkg/composable/controller.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,11 @@ func (c *controller) startContextProvider(ctx context.Context, wg *sync.WaitGrou
469469
return
470470
}
471471
// all other exits are bad, even a nil error
472-
l.Errorf("provider %q failed to run (will retry in %s): %s", name, c.restartInterval.String(), err)
472+
cause := ""
473+
if err != nil {
474+
cause = fmt.Sprintf(": %v", err)
475+
}
476+
l.Errorf("provider %q failed to run (will retry in %s)%s", name, c.restartInterval.String(), cause)
473477
if fpok {
474478
// turn off fetch provider
475479
sendFetchProvider(ctx, fetchCh, name, nil)
@@ -527,7 +531,11 @@ func (c *controller) startDynamicProvider(ctx context.Context, wg *sync.WaitGrou
527531
return
528532
}
529533
// all other exits are bad, even a nil error
530-
l.Errorf("provider %q failed to run (will restart in %s): %s", name, c.restartInterval.String(), err)
534+
cause := ""
535+
if err != nil {
536+
cause = fmt.Sprintf(": %v", err)
537+
}
538+
l.Errorf("provider %q failed to run (will restart in %s)%s", name, c.restartInterval.String(), cause)
531539
select {
532540
case <-ctx.Done():
533541
return

0 commit comments

Comments
 (0)