Skip to content

Commit

Permalink
fix: Authorino race condition
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Nairn <[email protected]>
  • Loading branch information
mikenairn committed Oct 24, 2024
1 parent 6e09671 commit 9062703
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/library/kuadrant/apimachinery_status_conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,28 @@ func (o *AffectedPolicyMap) RemoveAffectedPolicy(p Policy) {

// IsPolicyAffected checks if the provided Policy is affected based on the tracking map maintained.
func (o *AffectedPolicyMap) IsPolicyAffected(p Policy) bool {
o.mu.Lock()
defer o.mu.Unlock()

return o.policies[p.GetUID()] != nil
}

// IsPolicyOverridden checks if the provided Policy is affected based on the tracking map maintained.
// It is overridden if there is policies affecting it
func (o *AffectedPolicyMap) IsPolicyOverridden(p Policy) bool {
return o.IsPolicyAffected(p) && len(o.policies[p.GetUID()]) > 0
pAffected := o.IsPolicyAffected(p)

o.mu.Lock()
defer o.mu.Unlock()

return pAffected && len(o.policies[p.GetUID()]) > 0
}

// PolicyAffectedBy returns the clients keys that a policy is Affected by
func (o *AffectedPolicyMap) PolicyAffectedBy(p Policy) []client.ObjectKey {
o.mu.Lock()
defer o.mu.Unlock()

return o.policies[p.GetUID()]
}

Expand Down

0 comments on commit 9062703

Please sign in to comment.