Skip to content

[Spacetime][Fleet] Introduce airgapped config for bundled packages#202435

Merged
criamico merged 17 commits intoelastic:mainfrom
criamico:136617_airgapped_bundled_packages
Dec 11, 2024
Merged

[Spacetime][Fleet] Introduce airgapped config for bundled packages#202435
criamico merged 17 commits intoelastic:mainfrom
criamico:136617_airgapped_bundled_packages

Conversation

@criamico
Copy link
Copy Markdown
Contributor

@criamico criamico commented Dec 2, 2024

Closes #136617
Closes #167195

Summary

[Spacetime] Improving Integrations experience on airgapped envs using the existing xpack.fleet.isAirGapped configuration key:

  • Loading integrations is now much faster and doesn't attempt to contact the registry at all
  • Installing an uninstalled bundled packages should now be possible
    NOTE: Setting the isAirGapped skips the calls to registry altogether

Testing

  • In kibana.dev.yml:
    • Make sure that APM and other bundled packages are not present in preconfiguration
    • Configure xpack.fleet.isAirGapped: true
  • Copy the zip files from the EPR for some common bundled packages to them in them in kibana/x-pack/plugins/fleet/target/bundled_packages
  • Navigate to Integrations and verify that the page loads faster than in the past (it would take long because of retries)
  • Navigate to apm page or toapp/integrations/detail/apm-8.4.2/overview
  • Try to install it it should succeed correctly

Checklist

@criamico criamico added Team:Fleet Team label for Observability Data Collection Fleet team Spacetime release_note:fix backport:skip This PR does not require backporting labels Dec 2, 2024
@criamico criamico self-assigned this Dec 2, 2024
@criamico criamico marked this pull request as ready for review December 2, 2024 11:20
@criamico criamico requested a review from a team as a code owner December 2, 2024 11:20
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/fleet (Team:Fleet)

@criamico
Copy link
Copy Markdown
Contributor Author

criamico commented Dec 2, 2024

@elasticmachine merge upstream

@juliaElastic
Copy link
Copy Markdown
Contributor

Tested the scenario in the description and it seems to work.
I am wondering though how would users discover the correct URL to navigate to a bundled package, since loading the integrations landing page takes a long time to load.
Maybe we could use the isAirGapped flag to also prevent reaching out to the epr URL for any requests, so the bundled packages would load quickly on the landing page.

@criamico
Copy link
Copy Markdown
Contributor Author

criamico commented Dec 2, 2024

Maybe we could use the isAirGapped flag to also prevent reaching out to the epr URL for any requests, so the bundled packages would load quickly on the landing page.

@juliaElastic I think you're right, I was also thinking something like that. I didn't have much time to work on this issue last week so I opened the PR with what I had working.

As a follow up we could even show the isAirgapped flag on the settings page to make it more visible.

@kpollich
Copy link
Copy Markdown
Member

kpollich commented Dec 2, 2024

Maybe we could use the isAirGapped flag to also prevent reaching out to the epr URL for any requests, so the bundled packages would load quickly on the landing page.

I think we could do this in the epm/requests.ts module to make sure these requests can never fire. This would be a root fix for any external requests to EPR. We can handle this in a follow-up PR that closes #167195

@criamico
Copy link
Copy Markdown
Contributor Author

criamico commented Dec 2, 2024

I think we could do this in the epm/requests.ts module to make sure these requests can never fire. This would be a root fix for any external requests to EPR.

@kpollich @juliaElastic
I pushed 61ff101 that does just that. I tested it locally and it's actually faster than I thought, so this could actually fix #167195 too.

EDIT: I need to fix some linting errors and do some more testing, so I'm putting this back to draft

@criamico criamico marked this pull request as draft December 2, 2024 16:43
@criamico
Copy link
Copy Markdown
Contributor Author

criamico commented Dec 4, 2024

@elasticmachine merge upstream

@criamico criamico marked this pull request as ready for review December 5, 2024 10:47
@criamico
Copy link
Copy Markdown
Contributor Author

criamico commented Dec 5, 2024

@kpollich @juliaElastic
The way I'm using isAirGapped config here, I'm excluding altogether the calls to the registry. I'm thinking that this could be an issue if the user has RegistryUrl (or registryProxyUrl) set up along with isAirGapped, as the local registry won't be reached at all. I could add additional checks to avoid stopping the calls when registryUrl is present. What do you think?

@kpollich
Copy link
Copy Markdown
Member

kpollich commented Dec 5, 2024

I could add additional checks to avoid stopping the calls when registryUrl is present. What do you think?

I think the condition should be something like isAirgapped && !(registryUrl || registryProxyUrl) e.g. "if this is an airgapped environment with no configured registry URL" e.g.

const hasRegistryUrl = registryUrl || registryProxyURl
const shouldSkipRegistryRequests = isAirgapped && !hasRegistryUrl

@criamico
Copy link
Copy Markdown
Contributor Author

criamico commented Dec 5, 2024

I could add additional checks to avoid stopping the calls when registryUrl is present. What do you think?

I think the condition should be something like isAirgapped && !(registryUrl || registryProxyUrl) e.g. "if this is an airgapped environment with no configured registry URL" e.g.

const hasRegistryUrl = registryUrl || registryProxyURl
const shouldSkipRegistryRequests = isAirgapped && !hasRegistryUrl

@kpollich
That's what I was thinking too. It would only leave unresolved the case when the registryUrl is configured but unreachable. I'm not sure what should be the approach in that case.

@kpollich
Copy link
Copy Markdown
Member

kpollich commented Dec 5, 2024

when the registryUrl is configured but unreachable

I think we want errors to surface in this case because it's a configuration issue that the user needs to resolve. So this seems acceptable to me.

@criamico
Copy link
Copy Markdown
Contributor Author

criamico commented Dec 9, 2024

@elasticmachine merge upstream

@criamico
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

if (res) {
return res?.body;
}
throw new RegistryResponseError('isAirGapped config enabled, registry not reacheable');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this line for testing?


const shouldSkipRegistryRequests = isAirGapped && !hasRegistryUrls;

return { hasRegistryUrls, isAirGapped, shouldSkipRegistryRequests };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should probably create a documentation request to clarify what combination of configs prevents requests to EPR

Copy link
Copy Markdown
Contributor

@juliaElastic juliaElastic Dec 11, 2024

Choose a reason for hiding this comment

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

I think we should skip requests when isAirGapped:true is set, regardless of whether registryUrl is set. Currently if I set both, the requests are still made.

Tested without registryUrl and isAirGapped:true, it looks good, I'm seeing the integrations load quickly and the installed integrations are also showing up.
For some reason I don't see all bundled packages, e.g. endpoint which is not installed.

image image

Copy link
Copy Markdown
Contributor Author

@criamico criamico Dec 11, 2024

Choose a reason for hiding this comment

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

I think we should skip requests when isAirGapped:true is set, regardless of whether registryUrl is set. Currently if I set both, the requests are still made.

This was my first idea too but having an airgapped environment with a local registry is a legit use case that we are already supporting (see the docs).

If I just block the requests when isAirGapped is set to true, I'm going to break this use case for many users, that's why @kpollich proposed to check both conditions.

For some reason I don't see all bundled packages, e.g. endpoint which is not installed.

I noticed it too, I'm not sure why. I can open a follow up ticket to check what's going on.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see, it's ok then

Copy link
Copy Markdown
Contributor

@juliaElastic juliaElastic left a comment

Choose a reason for hiding this comment

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

LGTM

@criamico
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@criamico criamico enabled auto-merge (squash) December 11, 2024 15:35
@criamico criamico merged commit c3f96bb into elastic:main Dec 11, 2024
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

cc @criamico

@criamico criamico deleted the 136617_airgapped_bundled_packages branch December 12, 2024 08:12
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
…lastic#202435)

Closes elastic#136617
Closes elastic#167195

## Summary
[Spacetime] Improving Integrations experience on airgapped envs using
the existing `xpack.fleet.isAirGapped` configuration key:
- Loading integrations is now much faster and doesn't attempt to contact
the registry at all
- Installing an uninstalled bundled packages should now be possible
NOTE: Setting the `isAirGapped` skips the calls to registry altogether

### Testing
- In `kibana.dev.yml`:
- Make sure that APM and other bundled packages are not present in
preconfiguration
- Configure `xpack.fleet.registryUrl` to an unreacheable host, i.e.
`xpack.fleet.registryUrl: http://notworking`
  - Configure `xpack.fleet.isAirGapped: true`
- Copy the zip files from the EPR for some common bundled packages to
them in `them in kibana/x-pack/plugins/fleet/target/bundled_packages`
- Navigate to Integrations and verify that the page loads faster than in
the past (it would take long because of retries)
- Navigate to apm page or to`app/integrations/detail/apm-8.4.2/overview`
- Try to install it it should succeed correctly


### Checklist

- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@chais0n
Copy link
Copy Markdown

chais0n commented Mar 6, 2025

Just to add some context here - All of my customers are Air-gapped and every single one of them hosts a local EPR container. However, in testing and other situations, it would be nice that it didn't take the page forever to load if they don't have a Registry URL configured.

This makes perfect sense to me:

const hasRegistryUrl = registryUrl || registryProxyURl
const shouldSkipRegistryRequests = isAirgapped && !hasRegistryUrl

If they have a Registry URL configured and it's not working then I agree that is a configuration/environment issue that needs to be investigated.

maximpn added a commit that referenced this pull request Dec 3, 2025
…uilt rules OOM tests in 8.19 (#245087)

**Partially addresses:** #188090

## Summary

Fleet doesn't have #202435 backported to 8.19. It blocks package removal for packages installed by direct upload. With #228777 we have a We have a mock prebuilt rules package installed via upload at the global hook.

This PR fixes the issue by skipping mock prebuilt rules package installation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:fix Spacetime Team:Fleet Team label for Observability Data Collection Fleet team v9.0.0

Projects

None yet

6 participants