-
Notifications
You must be signed in to change notification settings - Fork 464
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
feat: initial impl of removing usage gloo proxy #10397
Conversation
@@ -47,10 +48,11 @@ func filterDelegatedChildren( | |||
// make a copy; multiple parents can delegate to the same child so we can't modify a shared reference | |||
clone := c.Clone() | |||
|
|||
child, ok := clone.Object.(*gwv1.HTTPRoute) | |||
origChild, ok := clone.Object.(*ir.HttpRouteIR) |
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.
s/origChild/childIR
projects/gateway2/translator/irtranslator/delegation_helpers.go
Outdated
Show resolved
Hide resolved
add code-gen for k8s clients, so we can have a fake client, to make translator_case_test work again. - change slice-to-pointer in our types to just slices to workaround codegen bug (kubernetes/code-generator#166)
} | ||
|
||
// in case multiple policies attached to the same resouce, we sort by policy creation time. | ||
func (d *directResponse) CreationTime() time.Time { |
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.
It feels like this will be very repeated and build some spaghetti. Is there a way we can make this not a policy requirement or have a standard load of it into a policy?
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.
the reason i introduced it is so i can sort policies by creation time in the IR (in the attached policies slice)
this helps with:
- prevent translation from happening when no policies changed (krt will dedupe events if the previous IR is equal to the new IR).
- given that all of these go in a slice, wanted to have consistent order incase order matters (though it probably shouldnt)
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.
couple of comments from a partial review pass
func(c skubeclient.ClientGetter, namespace string, o metav1.ListOptions) (runtime.Object, error) { | ||
return ourCli.GatewayV1alpha1().Upstreams(namespace).List(context.Background(), o) | ||
}, | ||
func(c skubeclient.ClientGetter, namespace string, o metav1.ListOptions) (watch.Interface, error) { | ||
return ourCli.GatewayV1alpha1().Upstreams(namespace).Watch(context.Background(), o) | ||
}, |
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.
Capturing ourCli as a closure in the registered list/watch functions. Feels odd but I don't see right off hand why it wouldn't work...
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.
the motivation here is that i can use fake client to test these;
i think client getter basically does the same thing using the istio client.. cc @stevenctl WDYT?
func (d *builtinPlugin) Equals(in any) bool { | ||
// we don't really need equality check here, because this policy is embedded in the httproute, | ||
// and we have generation based equality checks for that already. | ||
return true |
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.
should this be false
so that these are never equal and will always behave as though they need to update under any possible change?
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.
it should be true, false will cause excessive jitter.
in this specific case, it is not a problem because a built in type is embdded in the httproute CR, so we will catch it in the httproute equals (that is based off of the generation).
i'll try to see if its easy to add equals here for readability sake
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 had not really grokked how this works when I wrote the comment. I had assumed we create a collection of builtinplugins and so assuming every plugin was equal would break but we don't use it that way.
That being said, should this code live somewhere else, maybe under translater/httproute?
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.
it's here because policy attachment happens in the collections in policy.go..
I do agree that it might worth moving policy.go to translator package; but prefer to do it in a follow-up
} | ||
} | ||
|
||
func getFactionPercent(f gwv1.HTTPRequestMirrorFilter) *envoy_config_core_v3.RuntimeFractionalPercent { |
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.
func getFactionPercent(f gwv1.HTTPRequestMirrorFilter) *envoy_config_core_v3.RuntimeFractionalPercent { | |
func getFractionPercent(f gwv1.HTTPRequestMirrorFilter) *envoy_config_core_v3.RuntimeFractionalPercent { |
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.
the suggestion has an r
in the end so i can't apply it. will push this in shortly
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.
updated, but you probably already pushed, good either way
func InitCollectionsWithGateways(ctx context.Context, | ||
kubeRawGateways krt.Collection[*gwv1.Gateway], | ||
httpRoutes krt.Collection[*gwv1.HTTPRoute], | ||
tcproutes krt.Collection[*gwv1a2.TCPRoute], | ||
refgrants *RefGrantIndex, | ||
extensions extensionsplug.Plugin, istioClient kube.Client, krtopts krtutil.KrtOptions) (*GatweayIndex, *RoutesIndex, krt.Collection[ir.Upstream], krt.Collection[ir.EndpointsForUpstream]) { |
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.
nit: formatting
return i.getUpstream(kctx, resolved.GetGroupKind(), types.NamespacedName{Namespace: resolved.Namespace, Name: resolved.Name}, ref.Port) | ||
} | ||
|
||
type GatweayIndex struct { |
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.
type GatweayIndex struct { | |
type GatewayIndex struct { |
@@ -72,30 +78,31 @@ func filterDelegatedChildren( | |||
} | |||
|
|||
for _, match := range rule.Matches { | |||
match := *match.DeepCopy() |
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.
why do we need a deepcopy?
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.
to make sure we are not changing what's in the krt cache.
I believe controller runtime used to do that automatically for us
…t error. it needed to move to the IR translator
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.
do we want to completely delete these plugins already?
alternatively we can keep them around until the necessary functionality is ported into the new framework
- fixing equals on httprouteir - correctly setting ref grant/unknown kind conditions
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.
A great start that we can start reimplementing alot such as the required checks that we havent quite gotten passing
this is part of #10363
To enable opaque extendibility, we can't use protobuf based IR.
This pr changes the plugin model:
2 plugin stages:
Added some example CRDs, by no means in final form.
still WIP, there's a bunch of intentional panics in the code; created draft PR for early feedback