Skip to content

Commit 549cb1d

Browse files
committed
Review feedback
1 parent 105c349 commit 549cb1d

File tree

24 files changed

+429
-259
lines changed

24 files changed

+429
-259
lines changed

cmd/gateway/commands.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func createStaticModeCommand() *cobra.Command {
5656
leaderElectionDisableFlag = "leader-election-disable"
5757
leaderElectionLockNameFlag = "leader-election-lock-name"
5858
plusFlag = "nginx-plus"
59-
experimentalEnableFlag = "experimental-features-enable"
59+
gwAPIExperimentalFlag = "gateway-api-experimental-features"
6060
)
6161

6262
// flag values
@@ -97,7 +97,7 @@ func createStaticModeCommand() *cobra.Command {
9797

9898
plus bool
9999

100-
enableExperimental bool
100+
gwExperimentalFeatures bool
101101
)
102102

103103
cmd := &cobra.Command{
@@ -175,7 +175,7 @@ func createStaticModeCommand() *cobra.Command {
175175
Plus: plus,
176176
TelemetryReportPeriod: period,
177177
Version: version,
178-
ExperimentalFeatures: enableExperimental,
178+
ExperimentalFeatures: gwExperimentalFeatures,
179179
}
180180

181181
if err := static.StartManager(conf); err != nil {
@@ -290,8 +290,8 @@ func createStaticModeCommand() *cobra.Command {
290290
)
291291

292292
cmd.Flags().BoolVar(
293-
&enableExperimental,
294-
experimentalEnableFlag,
293+
&gwExperimentalFeatures,
294+
gwAPIExperimentalFlag,
295295
false,
296296
"Enable the experimental features of Gateway API which are supported by NGINX Gateway Fabric. "+
297297
"Requires the Gateway APIs installed from the experimental channel.",

deploy/helm-chart/templates/deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ spec:
5252
{{- else }}
5353
- --leader-election-disable
5454
{{- end }}
55-
{{- if .Values.nginxGateway.experimentalFeatures.enable }}
56-
- --experimental-features-enable
55+
{{- if .Values.nginxGateway.gwAPIExperimentalFeatures.enable }}
56+
- --gateway-api-experimental-features
5757
{{- end }}
5858
env:
5959
- name: POD_IP

deploy/helm-chart/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ nginxGateway:
5151
## extraVolumeMounts are the additional volume mounts for the nginx-gateway container.
5252
extraVolumeMounts: []
5353

54-
experimentalFeatures:
54+
gwAPIExperimentalFeatures:
5555
## Enable the experimental features of Gateway API which are supported by NGINX Gateway Fabric. Requires the Gateway
5656
## APIs installed from the experimental channel.
5757
enable: false

docs/developer/quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ This will build the docker images `nginx-gateway-fabric:<your-user>` and `nginx-
128128
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml
129129
```
130130
131-
Alternatively, install Gateway API CRDs from the experimental channel:
131+
If you're implementing experimental Gateway API features, install Gateway API CRDs from the experimental channel:
132132

133133
```shell
134134
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/experimental-install.yaml

internal/framework/status/setters_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,12 @@ func TestBtpStatusEqual(t *testing.T) {
865865
},
866866
}
867867
}
868+
prevMultiple := getPolicyStatus("ancestor1", "ns1", "ctlr1")
869+
prevMultiple.Ancestors = append(prevMultiple.Ancestors, getPolicyStatus("ancestor2", "ns2", "ctlr2").Ancestors...)
870+
871+
currMultiple := getPolicyStatus("ancestor1", "ns1", "ctlr1")
872+
currMultiple.Ancestors = append(currMultiple.Ancestors, getPolicyStatus("ancestor3", "ns3", "ctlr2").Ancestors...)
873+
868874
tests := []struct {
869875
name string
870876
controllerName string
@@ -907,6 +913,13 @@ func TestBtpStatusEqual(t *testing.T) {
907913
controllerName: "ctlr1",
908914
expEqual: false,
909915
},
916+
{
917+
name: "status not equal, different controller ancestor changed",
918+
previous: prevMultiple,
919+
current: currMultiple,
920+
controllerName: "ctlr1",
921+
expEqual: false,
922+
},
910923
}
911924

912925
for _, test := range tests {

internal/framework/status/statuses.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ type GatewayClassStatus struct {
116116
ObservedGeneration int64
117117
}
118118

119+
// AncestorStatus holds status-related information related to how the BackendTLSPolicy binds to a specific ancestorRef.
119120
type AncestorStatus struct {
120121
// GatewayNsName is the Namespaced name of the Gateway, which the ancestorRef references.
121122
GatewayNsName types.NamespacedName

internal/mode/static/build_statuses.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,7 @@ func buildBackendTLSPolicyStatuses(backendTLSPolicies map[types.NamespacedName]*
199199

200200
for nsname, backendTLSPolicy := range backendTLSPolicies {
201201
if backendTLSPolicy.IsReferenced {
202-
ignoreStatus := false
203-
if !backendTLSPolicy.Valid {
204-
for i := range backendTLSPolicy.Conditions {
205-
if backendTLSPolicy.Conditions[i].Reason == string(staticConds.BackendTLSPolicyReasonIgnored) {
206-
// We should not report the status of an ignored BackendTLSPolicy.
207-
ignoreStatus = true
208-
}
209-
}
210-
}
211-
if !ignoreStatus {
202+
if !backendTLSPolicy.Ignored {
212203
statuses[nsname] = status.BackendTLSPolicyStatus{
213204
AncestorStatuses: []status.AncestorStatus{
214205
{

internal/mode/static/build_statuses_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ func TestBuildBackendTLSPolicyStatuses(t *testing.T) {
619619
getBackendTLSPolicy := func(
620620
name string,
621621
valid bool,
622+
ignored bool,
622623
isReferenced bool,
623624
conditions []conditions.Condition,
624625
) *graph.BackendTLSPolicy {
@@ -631,15 +632,15 @@ func TestBuildBackendTLSPolicyStatuses(t *testing.T) {
631632
},
632633
},
633634
Valid: valid,
635+
Ignored: ignored,
634636
IsReferenced: isReferenced,
635637
Conditions: conditions,
636638
Gateway: types.NamespacedName{Name: "gateway", Namespace: "test"},
637639
}
638640
}
639641

640-
attachedConds := []conditions.Condition{staticConds.NewBackendTLSPolicyAttached()}
642+
attachedConds := []conditions.Condition{staticConds.NewBackendTLSPolicyAccepted()}
641643
invalidConds := []conditions.Condition{staticConds.NewBackendTLSPolicyInvalid("invalid backendTLSPolicy")}
642-
ignoredConds := []conditions.Condition{staticConds.NewBackendTLSPolicyIgnored("ignored backendTLSPolicy")}
643644

644645
tests := []struct {
645646
backendTLSPolicies map[types.NamespacedName]*graph.BackendTLSPolicy
@@ -653,7 +654,7 @@ func TestBuildBackendTLSPolicyStatuses(t *testing.T) {
653654
{
654655
name: "valid backendTLSPolicy",
655656
backendTLSPolicies: map[types.NamespacedName]*graph.BackendTLSPolicy{
656-
{Namespace: "test", Name: "valid-bt"}: getBackendTLSPolicy("valid-bt", true, true, attachedConds),
657+
{Namespace: "test", Name: "valid-bt"}: getBackendTLSPolicy("valid-bt", true, false, true, attachedConds),
657658
},
658659
expected: status.BackendTLSPolicyStatuses{
659660
{Namespace: "test", Name: "valid-bt"}: {
@@ -669,7 +670,7 @@ func TestBuildBackendTLSPolicyStatuses(t *testing.T) {
669670
{
670671
name: "invalid backendTLSPolicy",
671672
backendTLSPolicies: map[types.NamespacedName]*graph.BackendTLSPolicy{
672-
{Namespace: "test", Name: "invalid-bt"}: getBackendTLSPolicy("invalid-bt", false, true, invalidConds),
673+
{Namespace: "test", Name: "invalid-bt"}: getBackendTLSPolicy("invalid-bt", false, false, true, invalidConds),
673674
},
674675
expected: status.BackendTLSPolicyStatuses{
675676
{Namespace: "test", Name: "invalid-bt"}: {
@@ -685,16 +686,16 @@ func TestBuildBackendTLSPolicyStatuses(t *testing.T) {
685686
{
686687
name: "ignored or not referenced backendTLSPolicies",
687688
backendTLSPolicies: map[types.NamespacedName]*graph.BackendTLSPolicy{
688-
{Namespace: "test", Name: "ignored-bt"}: getBackendTLSPolicy("ignored-bt", false, true, ignoredConds),
689-
{Namespace: "test", Name: "not-referenced"}: getBackendTLSPolicy("not-referenced", true, false, nil),
689+
{Namespace: "test", Name: "ignored-bt"}: getBackendTLSPolicy("ignored-bt", false, true, true, nil),
690+
{Namespace: "test", Name: "not-referenced"}: getBackendTLSPolicy("not-referenced", true, false, false, nil),
690691
},
691692
expected: status.BackendTLSPolicyStatuses{},
692693
},
693694
{
694695
name: "mix valid and ignored backendTLSPolicies",
695696
backendTLSPolicies: map[types.NamespacedName]*graph.BackendTLSPolicy{
696-
{Namespace: "test", Name: "ignored-bt"}: getBackendTLSPolicy("ignored-bt", false, true, ignoredConds),
697-
{Namespace: "test", Name: "valid-bt"}: getBackendTLSPolicy("valid-bt", true, true, attachedConds),
697+
{Namespace: "test", Name: "ignored-bt"}: getBackendTLSPolicy("ignored-bt", false, true, true, nil),
698+
{Namespace: "test", Name: "valid-bt"}: getBackendTLSPolicy("valid-bt", true, false, true, attachedConds),
698699
},
699700
expected: status.BackendTLSPolicyStatuses{
700701
{Namespace: "test", Name: "valid-bt"}: {

internal/mode/static/manager.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,13 @@ func registerControllers(
388388
backendTLSObjs := []ctlrCfg{
389389
{
390390
objectType: &gatewayv1alpha2.BackendTLSPolicy{},
391+
options: []controller.Option{
392+
controller.WithK8sPredicate(k8spredicate.GenerationChangedPredicate{}),
393+
},
391394
},
392395
{
393396
// FIXME(ciarams87): If possible, use only metadata predicate
397+
// https://github.com/nginxinc/nginx-gateway-fabric/issues/1545
394398
objectType: &apiv1.ConfigMap{},
395399
},
396400
}

internal/mode/static/nginx/config/generator.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package config
22

33
import (
4-
"encoding/base64"
54
"path/filepath"
65

76
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/file"
@@ -96,15 +95,10 @@ func generatePEMFileName(id dataplane.SSLKeyPairID) string {
9695
}
9796

9897
func generateCertBundle(id dataplane.CertBundleID, cert []byte) file.File {
99-
data := make([]byte, base64.StdEncoding.DecodedLen(len(cert)))
100-
_, err := base64.StdEncoding.Decode(data, cert)
101-
if err != nil {
102-
data = cert
103-
}
10498
return file.File{
105-
Content: data,
99+
Content: cert,
106100
Path: generateCertBundleFileName(id),
107-
Type: file.TypeSecret,
101+
Type: file.TypeRegular,
108102
}
109103
}
110104

0 commit comments

Comments
 (0)