-
Notifications
You must be signed in to change notification settings - Fork 596
Allows users to define GatewayClasses using any controller #12733
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
Open
chandler-solo
wants to merge
7
commits into
kgateway-dev:main
Choose a base branch
from
chandler-solo:chandler/controller-name-not-gatewayclass-name-matters-more
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
75e152f
Allows users to define GatewayClasses using any controller.
chandler-solo 5fb523c
fixup
chandler-solo 430ba7d
Merge remote-tracking branch 'origin/main' into chandler/controller-n…
chandler-solo ce483ac
refresh golden
chandler-solo b8f7925
removes EnvoyControllerName Input
chandler-solo d17ff1a
fixup re: 'make fmt' does not actually guarantee that CI's lint check…
chandler-solo c1f744c
Merge branch 'main' into chandler/controller-name-not-gatewayclass-na…
chandler-solo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| package deployer_test | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/kgateway-dev/kgateway/v2/pkg/deployer" | ||
| ) | ||
|
|
||
| // TestGetInMemoryGatewayParameters_ControllerNamePriority tests that the controller name | ||
| // takes priority over the class name when determining which gateway parameters to return. | ||
| func TestGetInMemoryGatewayParameters_ControllerNamePriority(t *testing.T) { | ||
| imageInfo := &deployer.ImageInfo{ | ||
| Registry: "test-registry", | ||
| Tag: "test-tag", | ||
| PullPolicy: "IfNotPresent", | ||
| } | ||
|
|
||
| const ( | ||
| envoyController = "kgateway.dev/kgateway" | ||
| agwController = "kgateway.dev/agentgateway" | ||
| waypointClass = "waypoint" | ||
| ) | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| controllerName string | ||
| className string | ||
| expectedAgwEnabled bool | ||
| expectedServicePorts int // waypoint has an extra port | ||
| description string | ||
| }{ | ||
| { | ||
| name: "agentgateway controller name - ignores class name", | ||
| controllerName: agwController, | ||
| className: waypointClass, // should be ignored | ||
| expectedAgwEnabled: true, | ||
| expectedServicePorts: 0, | ||
| description: "When controller name matches agentgateway, it should return agentgateway parameters regardless of class name", | ||
| }, | ||
| { | ||
| name: "waypoint class name takes priority over envoy controller", | ||
| controllerName: envoyController, | ||
| className: waypointClass, // waypoint class checked before controller | ||
| expectedAgwEnabled: false, | ||
| expectedServicePorts: 1, // waypoint adds a mesh port | ||
| description: "When both envoy controller and waypoint class match, waypoint class takes priority", | ||
| }, | ||
| { | ||
| name: "waypoint class name - no controller match", | ||
| controllerName: "some.other/controller", | ||
| className: waypointClass, | ||
| expectedAgwEnabled: false, | ||
| expectedServicePorts: 1, // waypoint adds a mesh port | ||
| description: "When controller name doesn't match known controllers, it should check class name for waypoint", | ||
| }, | ||
| { | ||
| name: "default - no matches", | ||
| controllerName: "some.other/controller", | ||
| className: "some-other-class", | ||
| expectedAgwEnabled: false, | ||
| expectedServicePorts: 0, | ||
| description: "When neither controller name nor class name match, it should return default gateway parameters", | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| cfg := deployer.InMemoryGatewayParametersConfig{ | ||
| ControllerName: tt.controllerName, | ||
| ClassName: tt.className, | ||
| ImageInfo: imageInfo, | ||
| WaypointClassName: waypointClass, | ||
| EnvoyControllerName: envoyController, | ||
| AgwControllerName: agwController, | ||
| OmitDefaultSecurityContext: false, | ||
| } | ||
|
|
||
| gwp := deployer.GetInMemoryGatewayParameters(cfg) | ||
|
|
||
| if gwp == nil { | ||
| t.Fatal("GetInMemoryGatewayParameters returned nil") | ||
| } | ||
|
|
||
| // Check if agentgateway is enabled | ||
| if gwp.Spec.Kube == nil { | ||
| t.Fatal("GatewayParameters.Spec.Kube is nil") | ||
| } | ||
|
|
||
| agwEnabled := gwp.Spec.Kube.Agentgateway != nil && | ||
| gwp.Spec.Kube.Agentgateway.Enabled != nil && | ||
| *gwp.Spec.Kube.Agentgateway.Enabled | ||
|
|
||
| if agwEnabled != tt.expectedAgwEnabled { | ||
| t.Errorf("%s: agentgateway enabled = %v, want %v", tt.description, agwEnabled, tt.expectedAgwEnabled) | ||
| } | ||
|
|
||
| // Check service ports for waypoint | ||
| var servicePorts int | ||
| if gwp.Spec.Kube.Service != nil && gwp.Spec.Kube.Service.Ports != nil { | ||
| servicePorts = len(gwp.Spec.Kube.Service.Ports) | ||
| } | ||
|
|
||
| if servicePorts != tt.expectedServicePorts { | ||
| t.Errorf("%s: service ports count = %d, want %d", tt.description, servicePorts, tt.expectedServicePorts) | ||
| } | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.