-
Notifications
You must be signed in to change notification settings - Fork 141
controller: create HTTPRoute for each backend #537
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
Conversation
Signed-off-by: yweng14 <yweng14@bloomberg.net>
Signed-off-by: yweng14 <yweng14@bloomberg.net>
Signed-off-by: yweng14 <yweng14@bloomberg.net>
| Namespace: aiGatewayRoute.Namespace, | ||
| }, | ||
| Spec: gwapiv1.HTTPRouteSpec{}, | ||
| // List all HTTPRoutes in the same namespace as this aiGatewayRoute. |
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.
We can move to a separate function reconcileHTTPRoute as it is getting bigger
| if err = c.newHTTPRoute(ctx, &httpRoute, aiGatewayRoute); err != nil { | ||
| return fmt.Errorf("failed to construct a new HTTPRoute: %w", err) | ||
| // The naming convention of HTTRoute is <backendName>-<aiGatewayRouteName>, | ||
| // It is impossible that a HTTRRoute belongs to two AIGatewayRoute. |
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.
Can you have two AIGatewayRoute in the same namespace?
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.
Yes, it is possible that there are two AIGatewayRoute in the same namespace, and they have some same backends. In this implementation we create HTTPRoute per backend for each AIGatewayRoute.
| // Choose default backend whose name is alphabetically smallest. | ||
| if defaultBackend == nil || defaultBackend.Name > backend.Name { | ||
| defaultBackend = backend |
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.
What's the defaultBackend for?
| }, | ||
| Spec: gwapiv1.HTTPRouteSpec{}, | ||
| // List all HTTPRoutes in the same namespace as this aiGatewayRoute. | ||
| var existingHTTPRoutList gwapiv1.HTTPRouteList |
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.
existingHTTPRouteList
|
i believe we agreed that instead of making HTTPRoute for each Backend, we should support multiple AIGWR attached to one GW that will solve the limitation that this was initially trying to solve |
Commit Message
In this PR, I create HTTPRoute for each backend in the AIServiceBackend rules. When AIGatewayRouteController reconciles a AIGatewayRoute, it lists all the HTTPRoutes belongs to that AIGatewayRoute. It also constructs a de-duplicated backends from the rules of that AIGatewayRoute.
The controller creates new HTTRoutes for each backend if they do not exist before, and updates the HTTRoutes if they are already existed. We delete HTTPRoutes if they are not in the backends and only belong to that AIGatewayRoute.
The HTTRoute is created per backend and per AIGatewayRoute, naming convention is
<backendName>-<aiGatewayRouteName>, it makes the logic of HTTRoute lifecycle much clearer. Otherwise, I need merge owner references during update.Related Issues/PRs (if applicable)
Fix issue #509
Special notes for reviewers (if applicable)
N.A.