-
Notifications
You must be signed in to change notification settings - Fork 81
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
Add /api/fleet/agents/:id/audit/unenroll
endpoint
#3818
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'll also need to make a change to the ES templates in order to add audit_unenrolled_time
and audit_unenrolled_reason
to the agent documents. (edit: pr here)
I'll also make a followup PR to change the behaviour of the checkin API to clear the attributes that are set by the audit/unenroll API to allow Endpoint to mark itself as "orphaned" temporarily.
@@ -53,3 +53,7 @@ server_limits: | |||
interval: 1ms | |||
burst: 2000 | |||
max: 4000 | |||
audit_unenroll_limit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default/env limits for the audit/unenroll endpoint are set to the same values as the ack endpoint (excluding body which is set to 1 kb)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
51c2e3a
to
19ad629
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done!
Just a few comments, no blockers.
} | ||
|
||
if err := audit.bulk.Update(ctx, dl.FleetAgents, agent.Id, body, bulk.WithRefresh(), bulk.WithRetryOnConflict(3)); err != nil { | ||
return fmt.Errorf("auditUnenroll update: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems this will return a 500 error back to the caller, is that the correct error in the case its a conflict? Should it instead be the same conflict error in the case the field is set? I don't know if we want the caller to error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's detected much earlier on line 54 of handleAudit.go
https://github.com/elastic/fleet-server/pull/3818/files/#diff-bca31366226def7a73d6e6b142a9e17bbb4c2375a8f0fa16c5c81d4e6a374f13R54-R56
@@ -349,7 +349,7 @@ key: %s`, | |||
cfg.TLS = tlsCFG | |||
|
|||
st := NewStatusT(cfg, nil, nil) | |||
srv := NewServer(addr, cfg, nil, nil, nil, nil, st, sm, fbuild.Info{}, nil, nil, nil, nil, nil) | |||
srv := NewServer(addr, cfg, nil, nil, nil, nil, st, sm, fbuild.Info{}, nil, nil, nil, nil, nil, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has become a ton of parameters will most being nil
. Switching to a struct as a parameter would be better and cleaner. (don't do it in this PR, but an overall improvement)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #3823 to track
@@ -53,3 +53,7 @@ server_limits: | |||
interval: 1ms | |||
burst: 2000 | |||
max: 4000 | |||
audit_unenroll_limit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
|
||
for _, endpoint := range (&cfg.Inputs[0].Server).BindEndpoints() { | ||
apiServer := api.NewServer(endpoint, &cfg.Inputs[0].Server, ct, et, at, ack, st, sm, f.bi, ut, ft, pt, bulker, tracer) | ||
apiServer := api.NewServer(endpoint, &cfg.Inputs[0].Server, ct, et, at, ack, st, sm, f.bi, ut, ft, pt, auditT, bulker, tracer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
struct would be much better, this is a lot...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a typo and a question about an error message (non-blocking as it can also be fixed in a follow-up PR), looks good otherwise...
+1 on refactoring long lists of parameters into structs though... in those places the code is not very readable 😅
Co-authored-by: Paolo Chilà <[email protected]>
Quality Gate passedIssues Measures |
What is the problem this PR solves?
Uninstalled agents appear as offline in the fleet UI.
How does this PR solve the problem?
Add
/api/fleet/agents/:id/audit/unenroll
API that an elastic-agent or Endpoint process may use to annotate the agent document so the agent may appear with a different status.Changes from RFC
RFC here
Changes are:
audit_unenrolled_time
- time from requestaudit_unenrolled_reason
- reason from requestunenrolled_at
- server current time UTCupdated_at
- server current time UTC (new)removed change, was causing the api key auth to fail breaking integration and e2e testsactive
- set tofalse
(new)How to test this PR locally
make test-e2e
will run e2e tests as we need to change the elastic-agent or other test tools in order to use the endpointDesign Checklist
Checklist
./changelog/fragments
using the changelog toolRelated issues