Skip to content

Don't remove a Namespace Index while it still contains AuthorizationPolicy#12088

Merged
adleong merged 6 commits intomainfrom
alex/index-empty
Feb 16, 2024
Merged

Don't remove a Namespace Index while it still contains AuthorizationPolicy#12088
adleong merged 6 commits intomainfrom
alex/index-empty

Conversation

@adleong
Copy link
Member

@adleong adleong commented Feb 16, 2024

In the inbound policy index, we maintain a policy index per namespace which holds various policy resources for that namespace. When a per namespace index becomes empty, we remove it. However, we were not considering authorization policy resources when determining if the index is empty. This could result in the index being removed even while it contained authorization policy resources, as long as all other resource types did not exist.

This can lead to incorrect inbound policy responses when the per namespace index is recreated, since it will not longer contain the authorization policy.

We update the is_empty() function to properly consider authorization policies as well. We also add some generally useful logging at debug and trace level.

TODO: add test

Signed-off-by: Alex Leong <[email protected]>
Signed-off-by: Alex Leong <[email protected]>
@adleong adleong requested a review from a team as a code owner February 16, 2024 01:09
Copy link
Member

@olix0r olix0r left a comment

Choose a reason for hiding this comment

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

some logging consistency nits...

How hard is it to write a test for this?

Copy link
Member

@mateiidavid mateiidavid left a comment

Choose a reason for hiding this comment

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

🚢

@adleong adleong merged commit 754d047 into main Feb 16, 2024
@adleong adleong deleted the alex/index-empty branch February 16, 2024 18:30
adleong added a commit that referenced this pull request Feb 16, 2024
* Allowed the `MutatingWebhookConfig` timeout value to be configured ([#12028])
  (thanks @mikebell90)
* Added a counter for items dropped from destination controller workqueue
  ([#12079])
* Fixed a spurious `linkerd check` error when using container images with
  digests ([#12059])
* Fixed an issue where inbound policy could be incorrect after certain policy
  resources are deleted ([#12088])

[#12028]: #12028
[#12079]: #12079
[#12059]: #12059
[#12088]: #12088

Signed-off-by: Alex Leong <[email protected]>
adleong added a commit that referenced this pull request Feb 17, 2024
…olicy (#12088)

In the inbound policy index, we maintain a policy index per namespace which holds various policy resources for that namespace.  When a per namespace index becomes empty, we remove it.  However, we were not considering authorization policy resources when determining if the index is empty.  This could result in the index being removed even while it contained authorization policy resources, as long as all other resource types did not exist.

This can lead to incorrect inbound policy responses when the per namespace index is recreated, since it will not longer contain the authorization policy.

We update the `is_empty()` function to properly consider authorization policies as well.  We also add some generally useful logging at debug and trace level.

Signed-off-by: Alex Leong <[email protected]>
Co-authored-by: Oliver Gould <[email protected]>
@adleong adleong mentioned this pull request Feb 19, 2024
adleong added a commit that referenced this pull request Feb 20, 2024
This stable release back-ports bugfixes and improvements from recent edge
releases.

* Introduced support for arbitrary labels in the `podMonitors` field in the
  control plane Helm chart (thanks @jseiser!) ([#11222]; fixes [#11175])
* Added a `prometheusUrl` field for the heartbeat job in the control plane Helm
  chart (thanks @david972!) ([#11343]; fixes [#11342])
* Updated the Destination controller to return `INVALID_ARGUMENT` status codes
  properly when a `ServiceProfile` is requested for a service that does not
  exist. ([#11980])
* Reduced the load on the Destination controller by only processing Server
  updates on workloads affected by the Server ([#12017])
* Changed how updates to a `Server` selector are handled in the destination
  service. When a `Server` that marks a port as opaque no longer selects a
  resource, the resource's opaqueness will reverted to default settings
  ([#12031]; fixes [#11995])
* Fixed a race condition in the destination service that could cause panics
  under very specific conditions ([#12022]; fixes [#12010])
* Fixed an issue where inbound policy could be incorrect after certain policy
  resources are deleted ([#12088])

[#11222]: #11222
[#11175]: #11175
[#11343]: #11343
[#11342]: #11342
[#11980]: #11980
[#12017]: #12017
[#11995]: #11995
[#12031]: #12031
[#12010]: #12010
[#12022]: #12022
[#12088]: #12088

Signed-off-by: Alex Leong <[email protected]>
Signed-off-by: David ALEXANDRE <[email protected]>
Signed-off-by: Justin S <[email protected]>
Co-authored-by: Oliver Gould <[email protected]>
Co-authored-by: Alejandro Pedraza <[email protected]>
Co-authored-by: David ALEXANDRE <[email protected]>
Co-authored-by: Justin Seiser <[email protected]>
adleong added a commit that referenced this pull request Mar 7, 2024
PR #12088 fixed an issue where removing and then re-adding certain policy resources could leave the policy index in an incorrect state. We add a test for the specific condition that triggered this behavior to prevent against future regressions.

Verified that this test fails prior to #12088 but passes on main.

Signed-off-by: Alex Leong <[email protected]>
GrigoriyMikhalkin pushed a commit to GrigoriyMikhalkin/linkerd2 that referenced this pull request Mar 10, 2024
PR linkerd#12088 fixed an issue where removing and then re-adding certain policy resources could leave the policy index in an incorrect state. We add a test for the specific condition that triggered this behavior to prevent against future regressions.

Verified that this test fails prior to linkerd#12088 but passes on main.

Signed-off-by: Alex Leong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants