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: Context being cancelled and better Policy status #1012

Merged
merged 2 commits into from
Nov 14, 2024

Conversation

Boomatang
Copy link
Contributor

@Boomatang Boomatang commented Nov 12, 2024

The GetKuadrantFromTopology was somehow cancelling the context of functions that called it.

This improves the policy status of ratelimit policies when there is no kuadrant CR on cluster, or it was removed.

Closes: #1004
Closes: #1011

Reproduce error

Install kuadrant from main.
Create the a working ratelimit example. RateLimitPolicy for Platform Engineers

Delete the kuadrant CR. Then check the state of the wasm plugin. It would be expected that this would be removed. However it will not. Restarting the kuadrant deployment will fix the issue and clean the resources up. Also the status in the ratelimiting policy will say it is still accepted.

Install the operator from this branch and get the cluster back into the state before the deletion of the kuadrant CR. This time when the Kuadrant CR is remove the wasm plugin will be removed and the enforced status will be false.

Comment on lines 115 to +119
func (r *RateLimitPolicyStatusUpdater) enforcedCondition(policy *kuadrantv1.RateLimitPolicy, topology *machinery.Topology, state *sync.Map) *metav1.Condition {
kObj := GetKuadrantFromTopology(topology)
if kObj == nil {
return kuadrant.EnforcedCondition(policy, kuadrant.NewErrSystemResource("kuadrant"), false)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this also be done for AuthPolicy ? The current condition for AuthPolicy without Kuadrant installed is:

  status:
    conditions:
    - lastTransitionTime: "2024-11-13T08:50:35Z"
      message: AuthPolicy has been accepted
      reason: Accepted
      status: "True"
      type: Accepted
    - lastTransitionTime: "2024-11-13T08:50:54Z"
      message: 'AuthPolicy has encountered some issues: missing auth effective policies
        stored in the reconciliation state'
      reason: Unknown
      status: "False"
      type: Enforced

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this should have being done.

@@ -40,9 +40,9 @@ var (
)

func GetLimitadorFromTopology(topology *machinery.Topology) (*limitadorv1alpha1.Limitador, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: what about returning only *limitadorv1alpha1.Limitador ?

I do not consider as an error when (kuadrant managed) limitador does not exist. It is a state or reality, not an error.

The GetKuadrantFromTopology was somehow cancelling the context of
functions that called it.

This improves the policy status of ratelimit policies when there is no
kuadrant CR on cluster, or it was removed.

Signed-off-by: Jim Fitzpatrick <[email protected]>
Add changes based on PR comments

Signed-off-by: Jim Fitzpatrick <[email protected]>
Copy link
Contributor

@KevFan KevFan left a comment

Choose a reason for hiding this comment

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

Verified! Looks good to me 👍

@Boomatang Boomatang merged commit 87be3fb into Kuadrant:main Nov 14, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Context cancelled if kuadrant CR is not found Policy Status not updated when kuadrant is remove
3 participants