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

Fix geoip databases index access after system feature migration #121196

Merged
merged 9 commits into from
Feb 6, 2025

Conversation

joegallo
Copy link
Contributor

@joegallo joegallo commented Jan 29, 2025

There's a difference in the index resolution between a net new system index and a net new system index behind an alias. This PR adds to an integration test in order to capture the wider scenario, but it also adds a unit test that hits just this one precise detail.

The change to the IndexAbstractionResolver is very small, and I think it makes sense and is defensible, but this isn't an area of the code I know especially well, so I'd love an expert's eyes in the review.

@joegallo joegallo added >bug :Data Management/Ingest Node Execution or management of Ingest Pipelines including GeoIP Team:Core/Infra Meta label for core/infra team Team:Data Management Meta label for data/management team Team:Security Meta label for security team v9.0.0 v8.18.0 labels Jan 29, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @joegallo, I've created a changelog YAML for you.

@joegallo
Copy link
Contributor Author

joegallo commented Jan 29, 2025

I think there's at least one implied missing test in IndexAbstractionResolverTests that could cover this scenario. It'd be nice to have a unit test for it. (edit: Done, see later comment.)

These existing tests pass regardless of that value, but the test I'm
about to add needs the changed behavior.
This fails on main, but once merged in with my branch it'll pass.
@joegallo
Copy link
Contributor Author

I added a unit test in 4308559 that fails in the commit on which it was written (because that commit is based on main) but that passed on this branch after the merge commit because it works with the changes from this branch.

@joegallo
Copy link
Contributor Author

Backporting this PR to 8.18 and 8.x is going to look slightly different than the code that hits main. I've pre-gamed that as 8.x...joegallo:elasticsearch:fix-geoip-access-after-reindex-8.x.

@gmarouli
Copy link
Contributor

gmarouli commented Feb 4, 2025

The change to the IndexAbstractionResolver is very small, and I think it makes sense and is defensible, but this isn't an area of the code I know especially well, so I'd love an expert's eyes in the review.

So this is a bit of a weird territory, the combination of access and system indices is not well established. I tried to get to the bottom of this when I was refactoring the IndexNameExpressionResolver but I did not go far.

According to system level access:

For system data streams and "net-new" system indices (see {@link SystemIndexDescriptor#isNetNew()}), access levels should be used to reject requests entirely (see javadoc).

So if I read the above correctly what we are doing here, is not what we want. Our main issue is that the legacy indices that were allowed access now become net-new and they lose access. Right?

I have documented in IndexNameExpressionResolver.SystemResourceAccess that we already have contradicting code here, but before we make it even more complicated, let's think it through a bit. What do you think?

However there is backwards compatibility mode and I think this is what we count here, right?

... there was a desire for "net-new" system indices to opt in to the post-8.0 behavior of having access blocked in most cases, but this caused problems with certain APIs (see #74687), so this access level was added as a
workaround. Once we no longer have to support accessing existing system indices, this can and should be removed, along with the net-new property of system indices in general.

So, I am definitely not an expert but at least what you did matches what I read in the javadoc.

@masseyke masseyke added the v9.0.0 label Feb 4, 2025
@masseyke masseyke marked this pull request as ready for review February 6, 2025 19:25
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

@elasticsearchmachine elasticsearchmachine removed Team:Core/Infra Meta label for core/infra team Team:Security Meta label for security team labels Feb 6, 2025
Copy link
Member

@masseyke masseyke left a comment

Choose a reason for hiding this comment

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

I am fairly sure that this is correct. If I am missing something, it is easily-enough reversible. So LGTM.

@masseyke masseyke added the auto-backport Automatically create backport pull requests when merged label Feb 6, 2025
@masseyke masseyke merged commit 2bf9874 into elastic:main Feb 6, 2025
22 checks passed
joegallo added a commit to joegallo/elasticsearch that referenced this pull request Feb 6, 2025
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
9.0
8.18 Commit could not be cherrypicked due to conflicts
8.x Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 121196

masseyke pushed a commit to masseyke/elasticsearch that referenced this pull request Feb 6, 2025
masseyke pushed a commit to masseyke/elasticsearch that referenced this pull request Feb 6, 2025
elasticsearchmachine pushed a commit that referenced this pull request Feb 6, 2025
#121196) (#121955)

* Fix geoip databases index access after system feature migration (#121196)

* fixing the test for 8.x

---------

Co-authored-by: Joe Gallo <[email protected]>
elasticsearchmachine pushed a commit that referenced this pull request Feb 7, 2025
…#121196) (#121953)

* Fix geoip databases index access after system feature migration (#121196)

* fixing the test for 8.x

---------

Co-authored-by: Joe Gallo <[email protected]>
@joegallo joegallo deleted the fix-geoip-access-after-reindex branch February 10, 2025 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged >bug :Data Management/Ingest Node Execution or management of Ingest Pipelines including GeoIP Team:Data Management Meta label for data/management team v8.18.0 v8.19.0 v9.0.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants