Skip to content

Commit 73f7918

Browse files
authored
EndpointSlice resources tracked by Graph (#1432)
Problem: EndpointSlice resources are currently being tracked by the relationship capturer, but to reduce the number of components we would like to track the resources in the Graph. Solution: Enable Graph to track EndpointSlice resources and Services. In addition, this PR refactors backend_refs to store the NamespacedName of a Service and a ServicePort instead of the actual Service. This is done to track non-existing referenced services. Also, refactors and removes the alwaysTruePredicate. Removes RelationshipCapturer.
1 parent 06d8a6b commit 73f7918

23 files changed

+1113
-1324
lines changed

internal/mode/static/manager.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import (
4545
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/file"
4646
ngxruntime "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/runtime"
4747
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state"
48-
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/relationship"
4948
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/resolver"
5049
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/validation"
5150
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/telemetry"
@@ -138,10 +137,9 @@ func StartManager(cfg config.Config) error {
138137
}
139138

140139
processor := state.NewChangeProcessorImpl(state.ChangeProcessorConfig{
141-
GatewayCtlrName: cfg.GatewayCtlrName,
142-
GatewayClassName: cfg.GatewayClassName,
143-
RelationshipCapturer: relationship.NewCapturerImpl(),
144-
Logger: cfg.Logger.WithName("changeProcessor"),
140+
GatewayCtlrName: cfg.GatewayCtlrName,
141+
GatewayClassName: cfg.GatewayClassName,
142+
Logger: cfg.Logger.WithName("changeProcessor"),
145143
Validators: validation.Validators{
146144
HTTPFieldsValidator: ngxvalidation.HTTPValidator{},
147145
},

internal/mode/static/state/change_processor.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222

2323
"github.com/nginxinc/nginx-gateway-fabric/internal/framework/gatewayclass"
2424
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/graph"
25-
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/relationship"
2625
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/validation"
2726
)
2827

@@ -55,8 +54,6 @@ type ChangeProcessor interface {
5554

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

117-
isReferenced := func(obj client.Object) bool {
118-
nsname := types.NamespacedName{Name: obj.GetName(), Namespace: obj.GetNamespace()}
114+
isReferenced := func(obj client.Object, nsname types.NamespacedName) bool {
119115
return processor.latestGraph != nil && processor.latestGraph.IsReferenced(obj, nsname)
120116
}
121117

122118
trackingUpdater := newChangeTrackingUpdater(
123-
cfg.RelationshipCapturer,
124119
extractGVK,
125120
[]changeTrackingUpdaterObjectTypeCfg{
126121
{
127122
gvk: extractGVK(&v1.GatewayClass{}),
128123
store: newObjectStoreMapAdapter(clusterStore.GatewayClasses),
129-
predicate: alwaysProcess{},
124+
predicate: nil,
130125
},
131126
{
132127
gvk: extractGVK(&v1.Gateway{}),
133128
store: newObjectStoreMapAdapter(clusterStore.Gateways),
134-
predicate: alwaysProcess{},
129+
predicate: nil,
135130
},
136131
{
137132
gvk: extractGVK(&v1.HTTPRoute{}),
138133
store: newObjectStoreMapAdapter(clusterStore.HTTPRoutes),
139-
predicate: alwaysProcess{},
134+
predicate: nil,
140135
},
141136
{
142137
gvk: extractGVK(&v1beta1.ReferenceGrant{}),
143138
store: newObjectStoreMapAdapter(clusterStore.ReferenceGrants),
144-
predicate: alwaysProcess{},
139+
predicate: nil,
145140
},
146141
{
147142
gvk: extractGVK(&apiv1.Namespace{}),
@@ -151,12 +146,12 @@ func NewChangeProcessorImpl(cfg ChangeProcessorConfig) *ChangeProcessorImpl {
151146
{
152147
gvk: extractGVK(&apiv1.Service{}),
153148
store: newObjectStoreMapAdapter(clusterStore.Services),
154-
predicate: nil,
149+
predicate: funcPredicate{stateChanged: isReferenced},
155150
},
156151
{
157152
gvk: extractGVK(&discoveryV1.EndpointSlice{}),
158153
store: nil,
159-
predicate: nil,
154+
predicate: funcPredicate{stateChanged: isReferenced},
160155
},
161156
{
162157
gvk: extractGVK(&apiv1.Secret{}),

0 commit comments

Comments
 (0)