-
Notifications
You must be signed in to change notification settings - Fork 33
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
refactor: target status -> discoverability reconciler #958
Conversation
0e94177
to
d9829f5
Compare
conditions := gw.Status.DeepCopy().Conditions | ||
|
||
// TODO: What happens for multiple policies of the same kind - | ||
// TODO: Should it be conditions per listener? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say so. TLSPolicy and DNSPolicy still don't support targeting individual listeners (#891), but the AuthPolicy and RateLimitPolicy do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I've something working where the Gateway.Status.Conditions[XPolicyAffected]
lists xPolicies that just specifically targets the gateway. The listener status in Gateway.Status.ListenersStatus
will list inherited gateway policies and policies targetting specifically the listener. I think this is nicer and more informative to at least know which policies affect which sections of the gateway 🤔
Example:
conditions:
- lastTransitionTime: "2024-10-29T09:30:44Z"
message: Resource accepted
observedGeneration: 1
reason: Accepted
status: "True"
type: Accepted
- lastTransitionTime: "2024-10-29T09:30:49Z"
message: Resource programmed, assigned to service(s) kuadrant-ingressgateway-istio.gateway-system.svc.cluster.local:80
observedGeneration: 1
reason: Programmed
status: "True"
type: Programmed
- lastTransitionTime: "2024-10-29T09:37:57Z"
message: Object affected by RateLimitPolicy [gateway-system/gw-rlp]
observedGeneration: 1
reason: Accepted
status: "True"
type: kuadrant.io/RateLimitPolicyAffected
listeners:
- attachedRoutes: 0
conditions:
- lastTransitionTime: "2024-10-29T09:30:44Z"
message: No errors found
observedGeneration: 1
reason: Accepted
status: "True"
type: Accepted
- lastTransitionTime: "2024-10-29T09:30:44Z"
message: No errors found
observedGeneration: 1
reason: NoConflicts
status: "False"
type: Conflicted
- lastTransitionTime: "2024-10-29T09:30:44Z"
message: No errors found
observedGeneration: 1
reason: Programmed
status: "True"
type: Programmed
- lastTransitionTime: "2024-10-29T09:30:44Z"
message: No errors found
observedGeneration: 1
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
- lastTransitionTime: "2024-10-29T09:37:39Z"
message: Object affected by RateLimitPolicy [gateway-system/gw-rlp gateway-system/section-rlp]
observedGeneration: 1
reason: Accepted
status: "True"
type: kuadrant.io/RateLimitPolicyAffected
name: http
supportedKinds:
- group: gateway.networking.k8s.io
kind: HTTPRoute
- group: gateway.networking.k8s.io
kind: GRPCRoute
What do you think? 🤔
for _, policyKind := range policyKinds { | ||
// Policies targeting gateway and listeners | ||
path := []machinery.Targetable{gw} | ||
path = append(path, topology.Targetables().Children(gw)...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this will not work on Gateways with 2+ listeners. It would yield a path Gateway → Listener 1 → Listener 2 → … → Listener N
b6680c5
to
ade9318
Compare
ade9318
to
5af7788
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally it seems better than before. I compared the status of the gateways and httproutes on the this branch and off main. The setup I used has bad tls configurations which cause errors. In this work those error were reported better. This work also show what DNS policies affected a httproute in the httproute status. I am assuming this was an improvement and not an error in the implementation.
The only comments I have is on the structure of the code its self. It is stuff that I feel we should address but at the same time I am okay if we address it after GA.
@Boomatang Thanks for the review 👍 On:
This was an unintentional improvement from the refactor from simply including the
I think it's a nice addition, but not sure do we want this in general to have the Maybe @mikenairn @guicassolato or @maleck13 can comment if we want this for |
Well for me it comes down to is this useful for the end user. I think it is useful to know your HTTPRoute is covered by TLSPolicy or DNSPolicy. Do you have an example of the status message? I only would have a concern if we were leaking additional info but I doubt we are so +1 from me |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me.
I see no issue with it, makes sense to show that it is affected by these policies also. |
@maleck13 This would be an example status condition for status:
parents:
- conditions:
- lastTransitionTime: "2024-11-05T09:47:22Z"
message: Object affected by TLSPolicy [istio-system/gw-tls]
observedGeneration: 1
reason: Accepted
status: "True"
type: kuadrant.io/TLSPolicyAffected
controllerName: kuadrant.io/policy-controller
parentRef:
group: gateway.networking.k8s.io
kind: Gateway
name: istio-ingressgateway
namespace: istio-system A more complicated one for say - conditions:
- lastTransitionTime: "2024-11-05T09:51:35Z"
message: Object affected by RateLimitPolicy [default/route-rlp gateway-system/section-rlp gateway-system/gw-rlp]
observedGeneration: 1
reason: Accepted
status: "True"
type: kuadrant.io/RateLimitPolicyAffected
controllerName: kuadrant.io/policy-controller
parentRef:
group: gateway.networking.k8s.io
kind: Gateway
name: kuadrant-ingressgateway
namespace: gateway-system |
Thanks @KevFan looks good. I say merge it |
8098ca7
to
70ddfdd
Compare
…onciler Signed-off-by: KevFan <[email protected]>
…reconciler Signed-off-by: KevFan <[email protected]>
Signed-off-by: KevFan <[email protected]>
Signed-off-by: KevFan <[email protected]>
Signed-off-by: KevFan <[email protected]>
Signed-off-by: KevFan <[email protected]>
Signed-off-by: KevFan <[email protected]>
Signed-off-by: KevFan <[email protected]>
70ddfdd
to
b8a499a
Compare
Signed-off-by: KevFan <[email protected]>
* refactor: initial target status -> gateway policy discoverability reconciler Signed-off-by: KevFan <[email protected]> * refactor: initial target status -> http route policy discoverability reconciler Signed-off-by: KevFan <[email protected]> * feat: policyAffectedBy condition is ListenerStatus Signed-off-by: KevFan <[email protected]> * refactor: list all policies in httproute affected by condition Signed-off-by: KevFan <[email protected]> * refactor: smaller function for gateway discoverability Signed-off-by: KevFan <[email protected]> * refactor: breakdown to methods/functions + integration tests Signed-off-by: KevFan <[email protected]> * refactor: methods/functions Signed-off-by: KevFan <[email protected]> * tests: additional tests for auth, dns and tls Signed-off-by: KevFan <[email protected]> * gomod: tidy Signed-off-by: KevFan <[email protected]> --------- Signed-off-by: KevFan <[email protected]>
Description
Closes: #830 #829 #828 #827
xPolicyAffected
condition to Listeners status, listing accepted policies targeting the gateway and the listener (if any)xPolicyAffected
condtions to list accepted policies in path that may affect the targetablleVerification
kuadrant.io/RateLimitPolicyAffected
condition isObject affected by RateLimitPolicy [gateway-system/gw-rlp]
forGateway.Status.Condtions
andGateway.Status.Listener[].Condition
kuadrant.io/RateLimitPolicyAffected
condition isObject affected by RateLimitPolicy [gateway-system/gw-rlp]
forRoute.Status.Condtions
gw-rlp
is listed along withsection-rlp
for the targeted listener. All other listener status and the parent gatway condition should only listgw-rlp
gw-rlp
andsection-rlp
in the affection conditionroute-rlp
,section-rlp
andgw-rlp
and in the affection conditionroute-rlp
is not listed in the gateway or gateway listener status