Skip to content

Commit b816595

Browse files
michel-latermanmergify[bot]
authored andcommitted
Clean up message when audit/uninstall returns 401 (#6735)
* Clean up message when audit/uninstall returns 401 * Update internal/pkg/agent/install/uninstall.go Co-authored-by: Craig MacKenzie <[email protected]> --------- Co-authored-by: Craig MacKenzie <[email protected]> (cherry picked from commit c82d568) # Conflicts: # internal/pkg/agent/install/uninstall_test.go
1 parent d81f037 commit b816595

File tree

3 files changed

+40
-1
lines changed

3 files changed

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

internal/pkg/agent/install/uninstall.go

+3
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ func notifyFleetAuditUninstall(ctx context.Context, log *logp.Logger, pt *progre
200200
// Do not retry if it was a context error, or an error with the request.
201201
if errors.Is(err, context.Canceled) {
202202
return ctx.Err()
203+
} else if errors.Is(err, fleetclient.ErrInvalidAPIKey) {
204+
pt.Describe("API key is invalid (normal if already unenrolled), notification dropped.")
205+
return nil
203206
} else if errors.As(err, &reqErr) {
204207
pt.Describe(fmt.Sprintf("notify Fleet: encountered unretryable error: %v", err))
205208
return err

internal/pkg/agent/install/uninstall_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ import (
2626
"github.com/elastic/elastic-agent/internal/pkg/agent/application/secret"
2727
"github.com/elastic/elastic-agent/internal/pkg/agent/configuration"
2828
"github.com/elastic/elastic-agent/internal/pkg/agent/vault"
29+
<<<<<<< HEAD
2930
"github.com/elastic/elastic-agent/internal/pkg/fleetapi/client"
31+
=======
32+
"github.com/elastic/elastic-agent/internal/pkg/fleetapi"
33+
>>>>>>> c82d568b8 (Clean up message when audit/uninstall returns 401 (#6735))
3034
"github.com/elastic/elastic-agent/internal/pkg/remote"
3135
)
3236

@@ -164,7 +168,7 @@ func TestNotifyFleetAuditUnenroll(t *testing.T) {
164168
w.WriteHeader(http.StatusUnauthorized)
165169
}))
166170
},
167-
err: client.ErrInvalidAPIKey,
171+
err: nil,
168172
}, {
169173
name: "returns 409",
170174
getServer: func() *httptest.Server {

0 commit comments

Comments
 (0)