-
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 PGP key retrieval endpoint #2977
Conversation
282df26
to
5b2694e
Compare
509bb48
to
19dc846
Compare
5cced0b
to
db5294f
Compare
@@ -260,6 +260,17 @@ the test BenchmarkXXXX and not unit tests) | |||
- `BENCHMARK_COUNT`: you can define the number of iterations go test will run. Having larger number helps | |||
remove run-to-run variations (Default: 8) | |||
|
|||
#### E2E Tests |
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.
🎉 nice to add some doc on how to run tests
I am wondering if we should read the key on start as we do for the the other filer we read from the config like ( |
return nil, err | ||
} | ||
pt.cache.SetPGPKey(key, p) | ||
pt.writeKeyToDir(ctx, zlog, key, p) |
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.
If we write the upstream key to disk, this mean if that key is updated user will have to manually update it on their fleet-server? does the cache is not good enough here?
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.
Yes, if the upstream key is updated the user will need to manually update the key on disk (or remove it)
edit: the issue is to have fleet-server serve a local key with the fallback being an upstream source.
I added caching because if this endpoint is ever used it is likely to serve very bursty traffic, caching the key from disk or from the network would reduce the work fleet-server does
Currently pgp key config can be specified through the fleet-server integration. I think we should keep it as is, it may be easier to do an emergency key replacement with the current behaviour (if upstream has changed and an old key is on disk), the user would just need to change |
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.
LGTM
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.
Thanks for addressing the cache changes 🚀
SonarQube Quality Gate |
after merge comment: was testing this with agent. everything seems fine |
What is the problem this PR solves?
Fleet-server must be able to have a request path where a valid PGP key will be served to requesting agents.
This endpoint must only be valid when the server runs HTTPS.
An operator must be able to change the key that is served.
How does this PR solve the problem?
Add a new endpoint
GET /api/agents/upgrades/{major}.{minor}.{patch}/pgp-public-key
that will return a PGP key.The endpoint needs a valid API key and is rate limited.
Currently the
major
,minor
, andpatch
values are ignored.The endpoint will server a PGP key from it's cache if one exists, otherwise it will serve the contents of a PGP key found on disk at
FLEETSERVER_BINARY_DIR/elastic-agent-upgrade-keys/default.pgp
. Note that the directory can be changed through configuration.The key value is added to cache if it exists.
If this file does not exist the fleet-server will retrieve the key from
https://artifacts.elastic.co/GPG-KEY-elastic-agent
and serve it's contents (writing them to cache and disk). The upstream URL can also be changed through configuration.Design Checklist
I have or intend to scale test my changes, ensuring it will work reliably with 100K+ agents connected.Checklist
./changelog/fragments
using the changelog toolRelated issues