Skip to content

Commit 5c42294

Browse files
authored
Merge branch 'main' into tests/nfr-tests-edge
2 parents d8d168a + 603611a commit 5c42294

File tree

8 files changed

+350
-56
lines changed

8 files changed

+350
-56
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ repos:
2626
exclude: (^examples/|^docs/|.*_test.go$)
2727

2828
- repo: https://github.com/gitleaks/gitleaks
29-
rev: v8.28.0
29+
rev: v8.29.0
3030
hooks:
3131
- id: gitleaks
3232

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/nginx/nginx-gateway-fabric/v2
33
go 1.24.2
44

55
require (
6-
github.com/envoyproxy/go-control-plane/envoy v1.35.0
6+
github.com/envoyproxy/go-control-plane/envoy v1.36.0
77
github.com/fsnotify/fsnotify v1.9.0
88
github.com/go-logr/logr v1.4.3
99
github.com/google/go-cmp v0.7.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ github.com/ebitengine/purego v0.8.4 h1:CF7LEKg5FFOsASUj0+QwaXf8Ht6TlFxg09+S9wz0o
4545
github.com/ebitengine/purego v0.8.4/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
4646
github.com/emicklei/go-restful/v3 v3.12.2 h1:DhwDP0vY3k8ZzE0RunuJy8GhNpPL6zqLkDf9B/a0/xU=
4747
github.com/emicklei/go-restful/v3 v3.12.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
48-
github.com/envoyproxy/go-control-plane/envoy v1.35.0 h1:ixjkELDE+ru6idPxcHLj8LBVc2bFP7iBytj353BoHUo=
49-
github.com/envoyproxy/go-control-plane/envoy v1.35.0/go.mod h1:09qwbGVuSWWAyN5t/b3iyVfz5+z8QWGrzkoqm/8SbEs=
48+
github.com/envoyproxy/go-control-plane/envoy v1.36.0 h1:yg/JjO5E7ubRyKX3m07GF3reDNEnfOboJ0QySbH736g=
49+
github.com/envoyproxy/go-control-plane/envoy v1.36.0/go.mod h1:ty89S1YCCVruQAm9OtKeEkQLTb+Lkz0k8v9W0Oxsv98=
5050
github.com/envoyproxy/protoc-gen-validate v1.2.1 h1:DEo3O99U8j4hBFwbJfrz9VtgcDfUKS7KJ7spH3d86P8=
5151
github.com/envoyproxy/protoc-gen-validate v1.2.1/go.mod h1:d/C80l/jxXLdfEIhX1W2TmLfsJ31lvEjwamM4DxlWXU=
5252
github.com/evanphx/json-patch v0.5.2 h1:xVCHIVMUu1wtM/VkR9jVZ45N3FhZfYMMYGorLCR8P3k=

internal/controller/nginx/modules/package-lock.json

Lines changed: 49 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/controller/nginx/modules/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"clean": "rm -rf node_modules coverage"
1111
},
1212
"devDependencies": {
13-
"@vitest/coverage-v8": "^4.0.6",
13+
"@vitest/coverage-v8": "^4.0.7",
1414
"prettier": "3.6.2",
15-
"vitest": "^4.0.6"
15+
"vitest": "^4.0.7"
1616
},
1717
"type": "module"
1818
}

internal/controller/provisioner/setter.go

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package provisioner
22

33
import (
44
"maps"
5+
"slices"
6+
"strings"
57

68
appsv1 "k8s.io/api/apps/v1"
79
autoscalingv2 "k8s.io/api/autoscaling/v2"
@@ -83,8 +85,56 @@ func serviceSpecSetter(
8385
objectMeta metav1.ObjectMeta,
8486
) controllerutil.MutateFn {
8587
return func() error {
88+
const managedKeysAnnotation = "gateway.nginx.org/internal-managed-annotation-keys"
89+
90+
// Track which annotation keys NGF currently manages
91+
currentManagedKeys := make(map[string]bool)
92+
for k := range objectMeta.Annotations {
93+
currentManagedKeys[k] = true
94+
}
95+
96+
// Get previously managed keys from existing service
97+
var previousManagedKeys map[string]bool
98+
if prevKeysStr, ok := service.Annotations[managedKeysAnnotation]; ok {
99+
previousManagedKeys = make(map[string]bool)
100+
for _, k := range strings.Split(prevKeysStr, ",") {
101+
if k != "" {
102+
previousManagedKeys[k] = true
103+
}
104+
}
105+
}
106+
107+
// Start with existing annotations (preserves external controller annotations)
108+
mergedAnnotations := make(map[string]string)
109+
for k, v := range service.Annotations {
110+
// Skip the internal tracking annotation
111+
if k == managedKeysAnnotation {
112+
continue
113+
}
114+
// Remove annotations that NGF previously managed but no longer wants
115+
if previousManagedKeys != nil && previousManagedKeys[k] && !currentManagedKeys[k] {
116+
continue // Remove this annotation
117+
}
118+
mergedAnnotations[k] = v
119+
}
120+
121+
// Apply NGF-managed annotations (take precedence)
122+
for k, v := range objectMeta.Annotations {
123+
mergedAnnotations[k] = v
124+
}
125+
126+
// Store current managed keys for next reconciliation
127+
if len(currentManagedKeys) > 0 {
128+
var managedKeysList []string
129+
for k := range currentManagedKeys {
130+
managedKeysList = append(managedKeysList, k)
131+
}
132+
slices.Sort(managedKeysList) // Sort for deterministic output
133+
mergedAnnotations[managedKeysAnnotation] = strings.Join(managedKeysList, ",")
134+
}
135+
86136
service.Labels = objectMeta.Labels
87-
service.Annotations = objectMeta.Annotations
137+
service.Annotations = mergedAnnotations
88138
service.Spec = spec
89139
return nil
90140
}

0 commit comments

Comments
 (0)