Skip to content

Commit fc5c7cb

Browse files
committed
add sp config to backend ref
1 parent 62bcd00 commit fc5c7cb

18 files changed

+474
-1030
lines changed

internal/controller/manager.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,13 @@ func StartManager(cfg config.Config) error {
140140
GenericValidator: genericValidator,
141141
PolicyValidator: policyManager,
142142
},
143-
EventRecorder: recorder,
144-
MustExtractGVK: mustExtractGVK,
145-
PlusSecrets: plusSecrets,
146-
ExperimentalFeatures: cfg.ExperimentalFeatures,
143+
EventRecorder: recorder,
144+
MustExtractGVK: mustExtractGVK,
145+
PlusSecrets: plusSecrets,
146+
FeatureFlags: graph.FeatureFlags{
147+
Plus: cfg.Plus,
148+
Experimental: cfg.ExperimentalFeatures,
149+
},
147150
})
148151

149152
var handlerCollector handlerMetricsCollector = collectors.NewControllerNoopCollector()

internal/controller/nginx/config/upstreams_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ func TestExecuteUpstreams_NginxPlus(t *testing.T) {
229229
Name: "session-persistence",
230230
Expiry: "30m",
231231
Path: "/session",
232-
SessionType: dataplane.SessionPersistenceCookie,
232+
SessionType: dataplane.CookieTypeSessionPersistence,
233233
},
234234
},
235235
{
@@ -245,7 +245,7 @@ func TestExecuteUpstreams_NginxPlus(t *testing.T) {
245245
Name: "session-persistence",
246246
Expiry: "100h",
247247
Path: "/v1/users",
248-
SessionType: dataplane.SessionPersistenceCookie,
248+
SessionType: dataplane.CookieTypeSessionPersistence,
249249
},
250250
},
251251
{
@@ -259,7 +259,7 @@ func TestExecuteUpstreams_NginxPlus(t *testing.T) {
259259
},
260260
SessionPersistence: dataplane.SessionPersistenceConfig{
261261
Name: "session-persistence",
262-
SessionType: dataplane.SessionPersistenceCookie,
262+
SessionType: dataplane.CookieTypeSessionPersistence,
263263
},
264264
},
265265
}
@@ -921,7 +921,7 @@ func TestCreateUpstreamPlus(t *testing.T) {
921921
SessionPersistence: dataplane.SessionPersistenceConfig{
922922
Name: "session-persistence",
923923
Expiry: "45m",
924-
SessionType: dataplane.SessionPersistenceCookie,
924+
SessionType: dataplane.CookieTypeSessionPersistence,
925925
Path: "/app",
926926
},
927927
},
@@ -938,7 +938,7 @@ func TestCreateUpstreamPlus(t *testing.T) {
938938
SessionPersistence: http.UpstreamSessionPersistence{
939939
Name: "session-persistence",
940940
Expiry: "45m",
941-
SessionType: string(dataplane.SessionPersistenceCookie),
941+
SessionType: string(dataplane.CookieTypeSessionPersistence),
942942
Path: "/app",
943943
},
944944
},

internal/controller/state/change_processor.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ type ChangeProcessorConfig struct {
6464
GatewayCtlrName string
6565
// GatewayClassName is the name of the GatewayClass resource.
6666
GatewayClassName string
67-
// ExperimentalFeatures indicates if experimental features are enabled.
68-
ExperimentalFeatures bool
67+
// FeaturesFlags holds the feature flags for building the Graph.
68+
FeatureFlags graph.FeatureFlags
6969
}
7070

7171
// ChangeProcessorImpl is an implementation of ChangeProcessor.
@@ -278,7 +278,7 @@ func (c *ChangeProcessorImpl) Process() *graph.Graph {
278278
c.cfg.PlusSecrets,
279279
c.cfg.Validators,
280280
c.cfg.Logger,
281-
c.cfg.ExperimentalFeatures,
281+
c.cfg.FeatureFlags,
282282
)
283283

284284
return c.latestGraph

internal/controller/state/conditions/conditions.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ const (
4242
// not yet supported.
4343
RouteReasonUnsupportedField v1.RouteConditionReason = "UnsupportedField"
4444

45-
// RouteReasonInvalidSessionPersistence is used with the "Accepted" (true) condition when the Route
46-
// contains invalid session persistence configuration.
47-
RouteReasonInvalidSessionPersistence v1.RouteConditionReason = "InvalidSessionPersistence"
48-
4945
// RouteReasonInvalidGateway is used with the "Accepted" (false) condition when the Gateway the Route
5046
// references is invalid.
5147
RouteReasonInvalidGateway v1.RouteConditionReason = "InvalidGateway"
@@ -397,17 +393,6 @@ func NewRouteAcceptedUnsupportedField(msg string) Condition {
397393
}
398394
}
399395

400-
// NewRouteAcceptedInvalidSessionPersistenceConfiguration returns a Condition that indicates that the
401-
// Route is accepted but invalid session persistence configuration was ignored.
402-
func NewRouteAcceptedInvalidSessionPersistenceConfiguration(msg string) Condition {
403-
return Condition{
404-
Type: string(v1.RouteConditionAccepted),
405-
Status: metav1.ConditionTrue,
406-
Reason: string(RouteReasonInvalidSessionPersistence),
407-
Message: fmt.Sprintf("Session Persistence configuration ignored: %s", msg),
408-
}
409-
}
410-
411396
// NewRoutePartiallyInvalid returns a Condition that indicates that the Route contains a combination
412397
// of both valid and invalid rules.
413398
//

internal/controller/state/dataplane/configuration.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -774,12 +774,6 @@ func buildUpstreams(
774774
}
775775

776776
for _, br := range rule.BackendRefs {
777-
var spForThisBackend *graph.SessionPersistenceConfig
778-
// only set session persistence for regular backends
779-
if rule.SessionPersistence != nil && !br.IsMirrorBackend && !br.IsInferencePool {
780-
spForThisBackend = rule.SessionPersistence
781-
}
782-
783777
if upstream := buildUpstream(
784778
ctx,
785779
logger,
@@ -789,7 +783,7 @@ func buildUpstreams(
789783
referencedServices,
790784
uniqueUpstreams,
791785
allowedAddressType,
792-
spForThisBackend,
786+
br.SessionPersistence,
793787
); upstream != nil {
794788
uniqueUpstreams[upstream.Name] = *upstream
795789
}
@@ -844,7 +838,6 @@ func buildUpstream(
844838
}
845839

846840
var errMsg string
847-
848841
eps, err := resolveUpstreamEndpoints(
849842
ctx,
850843
logger,
@@ -871,7 +864,7 @@ func buildUpstream(
871864
Name: sessionPersistence.Name,
872865
Expiry: sessionPersistence.Expiry,
873866
Path: sessionPersistence.Path,
874-
SessionType: SessionPersistenceCookie,
867+
SessionType: CookieTypeSessionPersistence,
875868
}
876869
}
877870

0 commit comments

Comments
 (0)