Skip to content
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

EndpointSlice resources tracked by Graph #1432

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
85648e2
Add Service and EndpointSlice logic to graph and some tests
bjee19 Dec 29, 2023
3abafb0
WIP, all tests pass but awaiting feedback
bjee19 Dec 29, 2023
148dcb2
Remove EndpointSlice from store and refactor upsert and delete
bjee19 Jan 3, 2024
c7eaca8
Refactor upsert and delete functions by adding nsname as parameter
bjee19 Jan 4, 2024
de5801c
Remove nsname from update parameters
bjee19 Jan 4, 2024
34ff73e
Refactor backendRefs to store ServicePort and SvcNsName
bjee19 Jan 9, 2024
06b723c
Clean up unused comments
bjee19 Jan 9, 2024
3750ef8
Lowercase panic statements
bjee19 Jan 11, 2024
9df85c1
Remove TODO statement
bjee19 Jan 11, 2024
c81b037
Fix function argument spacing
bjee19 Jan 11, 2024
4d8f275
Add panic statement to Resolve function
bjee19 Jan 11, 2024
fbe08a1
Refactor to use client.ObjectKeyFromObject
bjee19 Jan 11, 2024
caa48f6
Change error message to only include port
bjee19 Jan 11, 2024
1eec574
Remove ServiceNames from Route and move logic to service.go
bjee19 Jan 11, 2024
5109dcf
Remove capturer
bjee19 Jan 11, 2024
27fd279
Add service tests
bjee19 Jan 12, 2024
318302e
Add backendRef tests
bjee19 Jan 12, 2024
af48643
Refactor part of change processor tests to work correctly
bjee19 Jan 12, 2024
8e29ddd
Remove tests from change_processor
bjee19 Jan 12, 2024
d890a78
Fix function layout in change processor tests
bjee19 Jan 12, 2024
1e3d23b
Change function layout in change processor tests
bjee19 Jan 12, 2024
35b548a
Adjust comments in backendRef
bjee19 Jan 18, 2024
7852824
Remove FIXME
bjee19 Jan 18, 2024
22227f8
Add assert on Process call
bjee19 Jan 18, 2024
060d356
Refactor comments and logic in backendRefs
bjee19 Jan 18, 2024
feef30a
Remove unnecessary comments
bjee19 Jan 18, 2024
c7e6a39
Remove mentions of capturer
bjee19 Jan 18, 2024
bd0dad7
Refactor tests to not use pass/fail in name
bjee19 Jan 18, 2024
9bdc838
Remove some comments
bjee19 Jan 18, 2024
32307fb
Rename to ReferencedServices
bjee19 Jan 18, 2024
58d9c5c
Remove unnecessary checks in service
bjee19 Jan 18, 2024
a86a0d0
Move comment
bjee19 Jan 18, 2024
88e8d24
Rebase and remove FIXME
bjee19 Jan 18, 2024
8513f27
Add feedback from review
bjee19 Jan 19, 2024
4efe47e
Add persists to multiObjectStore
bjee19 Jan 19, 2024
1580fe1
Remove alwaysTrue predicate and resolve FIXME
bjee19 Jan 19, 2024
a42e2d2
Add back some change_processor tests
bjee19 Jan 20, 2024
cebcc7a
Remove persistedGVKs from changeTrackingUpdater
bjee19 Jan 22, 2024
b8d9a89
Change function documentation
bjee19 Jan 22, 2024
3146c18
Add namespace resources to multi k8s api resource change tests
bjee19 Jan 22, 2024
635178b
Add secret resources to change processor tests
bjee19 Jan 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions internal/mode/static/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import (
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/file"
ngxruntime "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/runtime"
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state"
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/relationship"
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/resolver"
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/validation"
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/telemetry"
Expand Down Expand Up @@ -138,10 +137,9 @@ func StartManager(cfg config.Config) error {
}

processor := state.NewChangeProcessorImpl(state.ChangeProcessorConfig{
GatewayCtlrName: cfg.GatewayCtlrName,
GatewayClassName: cfg.GatewayClassName,
RelationshipCapturer: relationship.NewCapturerImpl(),
Logger: cfg.Logger.WithName("changeProcessor"),
GatewayCtlrName: cfg.GatewayCtlrName,
GatewayClassName: cfg.GatewayClassName,
Logger: cfg.Logger.WithName("changeProcessor"),
Validators: validation.Validators{
HTTPFieldsValidator: ngxvalidation.HTTPValidator{},
},
Expand Down
19 changes: 7 additions & 12 deletions internal/mode/static/state/change_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"github.com/nginxinc/nginx-gateway-fabric/internal/framework/gatewayclass"
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/graph"
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/relationship"
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/validation"
)

Expand Down Expand Up @@ -55,8 +54,6 @@ type ChangeProcessor interface {

// ChangeProcessorConfig holds configuration parameters for ChangeProcessorImpl.
type ChangeProcessorConfig struct {
// RelationshipCapturer captures relationships between Kubernetes API resources and Gateway API resources.
RelationshipCapturer relationship.Capturer
// Validators validate resources according to data-plane specific rules.
Validators validation.Validators
// EventRecorder records events for Kubernetes resources.
Expand Down Expand Up @@ -114,34 +111,32 @@ func NewChangeProcessorImpl(cfg ChangeProcessorConfig) *ChangeProcessorImpl {
clusterState: clusterStore,
}

isReferenced := func(obj client.Object) bool {
nsname := types.NamespacedName{Name: obj.GetName(), Namespace: obj.GetNamespace()}
isReferenced := func(obj client.Object, nsname types.NamespacedName) bool {
bjee19 marked this conversation as resolved.
Show resolved Hide resolved
return processor.latestGraph != nil && processor.latestGraph.IsReferenced(obj, nsname)
}

trackingUpdater := newChangeTrackingUpdater(
cfg.RelationshipCapturer,
extractGVK,
[]changeTrackingUpdaterObjectTypeCfg{
{
gvk: extractGVK(&v1.GatewayClass{}),
store: newObjectStoreMapAdapter(clusterStore.GatewayClasses),
predicate: alwaysProcess{},
predicate: nil,
},
{
gvk: extractGVK(&v1.Gateway{}),
store: newObjectStoreMapAdapter(clusterStore.Gateways),
predicate: alwaysProcess{},
predicate: nil,
},
{
gvk: extractGVK(&v1.HTTPRoute{}),
store: newObjectStoreMapAdapter(clusterStore.HTTPRoutes),
predicate: alwaysProcess{},
predicate: nil,
},
{
gvk: extractGVK(&v1beta1.ReferenceGrant{}),
store: newObjectStoreMapAdapter(clusterStore.ReferenceGrants),
predicate: alwaysProcess{},
predicate: nil,
},
{
gvk: extractGVK(&apiv1.Namespace{}),
Expand All @@ -151,12 +146,12 @@ func NewChangeProcessorImpl(cfg ChangeProcessorConfig) *ChangeProcessorImpl {
{
gvk: extractGVK(&apiv1.Service{}),
store: newObjectStoreMapAdapter(clusterStore.Services),
predicate: nil,
predicate: funcPredicate{stateChanged: isReferenced},
},
{
gvk: extractGVK(&discoveryV1.EndpointSlice{}),
store: nil,
predicate: nil,
predicate: funcPredicate{stateChanged: isReferenced},
},
{
gvk: extractGVK(&apiv1.Secret{}),
Expand Down
Loading
Loading