Skip to content
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

[Fleet] Create new API to manage download_source setting #134889

Merged
merged 11 commits into from
Jun 24, 2022

Conversation

criamico
Copy link
Contributor

@criamico criamico commented Jun 22, 2022

Summary

First part of #133828

  • Create a new API /api/fleet/agent_download_sources around managing agent download sources. It will allow the user to specify the address of a custom registry where the agent can be downloaded from. The default value is artifactory.elastic.co, but the user can change the default to another value, however only one default can exist.
  • Adding openapi documentation for the new endpoints - the new docs can be read here
  • Adding a new service downloadSourceService
  • Adding two methods to AgentPolicyService to handle the new download sources values in agent policies.
  • Updating the plugin preconfiguration to set the default value of download source at Fleet startup.

There will be a subsequent PR to update the compilation logic of elastic-agent.yml.

It was decided to not add it to /settings api to maintain a similar structure to outputs, so it was added a new saved object ingest-download-sources.

Endpoints:

  • List: GET api/fleet/agent_download_sources - On a fresh start of fleet this should return
{
 "items": [
   {
     "id": "fleet-default-download-source",
     "name": "default",
     "is_default": true,
     "host": "artifactory.elastic.co"
   }
 ],
 "page": 1,
 "perPage": 10000,
 "total": 1
}
  • Get single entry: GET /api/fleet/agent_download_sources/{sourceId}

  • Create a new entry:

    POST /api/fleet/agent_download_sources
    {
      "name": "host4",
      "host": "http://local-registry",
      "is_default": "true"
    }
    
  • Update existing entry:

 PUT /api/fleet/agent_download_sources/{sourceId}
 {
   "name": "host4",
   "host": "http://local-registry",
   "is_default": "false"
 }
  • Delete existing entry: DELETE kbn:/api/fleet/agent_download_sources/{sourceId}

Checklist

@criamico criamico self-assigned this Jun 22, 2022
@criamico criamico added Team:Fleet Team label for Observability Data Collection Fleet team v8.4.0 release_note:feature Makes this part of the condensed release notes labels Jun 22, 2022
@criamico criamico changed the title Download source/new api [Fleet] Create new API to manage download_source setting Jun 22, 2022
@criamico criamico marked this pull request as ready for review June 22, 2022 10:51
@criamico criamico requested a review from a team as a code owner June 22, 2022 10:51
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@criamico criamico requested a review from a team as a code owner June 22, 2022 13:02
Copy link
Member

@kpollich kpollich left a comment

Choose a reason for hiding this comment

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

I don't really have any problems with the code - it's mostly boilerplate API CRUD stuff and lines up with basically every other API resource we have, so all looks good there.

I do have one question about the source_id field. It seems like this is pulled from outputs which define an output_id field, but I'm struggling to understand why we need that, especially since we set the saved objects' id and source_id to the same values on create.

Do you have any context around why we'd need these two attributes rather than just relying on id?

@criamico
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
fleet 720 723 +3

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
fleet 1309 1340 +31

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
fleet 95.0KB 95.9KB +876.0B

Saved Objects .kibana field count

Every field in each saved object type adds overhead to Elasticsearch. Kibana needs to keep the total field count below Elasticsearch's default limit of 1000 fields. Only specify field mappings for the fields you wish to search on or query. See https://www.elastic.co/guide/en/kibana/master/development-plugin-saved-objects.html#_mappings

id before after diff
ingest-download-sources - 5 +5
Unknown metric groups

API count

id before after diff
fleet 1436 1467 +31

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @criamico

@criamico criamico merged commit fd3bb16 into elastic:main Jun 24, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:feature Makes this part of the condensed release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants