Skip to content

Commit 947be82

Browse files
authored
Merge pull request #1361 from 94DanielBrown/main
chore: add `GroupChangeLog` feature gate to fix es indexing cardinality
2 parents 281d998 + 230b55f commit 947be82

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ require (
2525
github.com/fluxcd/pkg/http/fetch v0.15.0
2626
github.com/fluxcd/pkg/kustomize v1.16.0
2727
github.com/fluxcd/pkg/runtime v0.53.1
28-
github.com/fluxcd/pkg/ssa v0.44.0
28+
github.com/fluxcd/pkg/ssa v0.45.1
2929
github.com/fluxcd/pkg/tar v0.11.0
3030
github.com/fluxcd/pkg/testserver v0.10.0
3131
github.com/fluxcd/source-controller/api v1.4.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ github.com/fluxcd/pkg/runtime v0.53.1 h1:S+QRSoiU+LH1sTvJLNvT1x3E5hBq/sjOsRHazA7
191191
github.com/fluxcd/pkg/runtime v0.53.1/go.mod h1:8vkIhS1AhkmjC98LRm5xM+CRG5KySFTXpJWk+ZdtT4I=
192192
github.com/fluxcd/pkg/sourceignore v0.11.0 h1:xzpYmc5/t/Ck+/DkJSX3r+VbahDRIAn5kbv04fynWUo=
193193
github.com/fluxcd/pkg/sourceignore v0.11.0/go.mod h1:ri2FvlzX8ep2iszOK5gF/riYq2TNgpVvsfJ2QY0dLWI=
194-
github.com/fluxcd/pkg/ssa v0.44.0 h1:FnINKo29HheKMkCTqfsY5y994ObLk09N1Ldb6MtBJ3c=
195-
github.com/fluxcd/pkg/ssa v0.44.0/go.mod h1:8Anf7XVZ0zxOve7HXbDaW1s0gfmP95ksJBlKfDYinhQ=
194+
github.com/fluxcd/pkg/ssa v0.45.1 h1:ISl84TJwRP/GuZXrKiR9Tf8JOnG5XFgtjcYoR4XQYf4=
195+
github.com/fluxcd/pkg/ssa v0.45.1/go.mod h1:8Anf7XVZ0zxOve7HXbDaW1s0gfmP95ksJBlKfDYinhQ=
196196
github.com/fluxcd/pkg/tar v0.11.0 h1:pjf/rzr6HNAPiuxT59mtba9tfBtdNiSQ/UqduG8vZ2I=
197197
github.com/fluxcd/pkg/tar v0.11.0/go.mod h1:+kiP25NqibWMpFWgizyPEMqnMJIux7bCgEy+4pfxyI4=
198198
github.com/fluxcd/pkg/testserver v0.10.0 h1:g5l6mX9GndovWXCTW9xCPbL6YQYgphwe4Ee6cuBmLcA=

internal/controller/kustomization_controller.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ type KustomizationReconciler struct {
104104
ConcurrentSSA int
105105
DisallowedFieldManagers []string
106106
StrictSubstitutions bool
107+
GroupChangeLog bool
107108
}
108109

109110
// KustomizationReconcilerOptions contains options for the KustomizationReconciler.
@@ -799,7 +800,11 @@ func (r *KustomizationReconciler) apply(ctx context.Context,
799800
if changeSet != nil && len(changeSet.Entries) > 0 {
800801
resultSet.Append(changeSet.Entries)
801802

802-
log.Info("server-side apply for cluster definitions completed", "output", changeSet.ToMap())
803+
if r.GroupChangeLog {
804+
log.Info("server-side apply for cluster definitions completed", "output", changeSet.ToGroupedMap())
805+
} else {
806+
log.Info("server-side apply for cluster definitions completed", "output", changeSet.ToMap())
807+
}
803808
for _, change := range changeSet.Entries {
804809
if HasChanged(change.Action) {
805810
changeSetLog.WriteString(change.String() + "\n")
@@ -825,7 +830,11 @@ func (r *KustomizationReconciler) apply(ctx context.Context,
825830
if changeSet != nil && len(changeSet.Entries) > 0 {
826831
resultSet.Append(changeSet.Entries)
827832

828-
log.Info("server-side apply for cluster class types completed", "output", changeSet.ToMap())
833+
if r.GroupChangeLog {
834+
log.Info("server-side apply for cluster definitions completed", "output", changeSet.ToGroupedMap())
835+
} else {
836+
log.Info("server-side apply for cluster class types completed", "output", changeSet.ToMap())
837+
}
829838
for _, change := range changeSet.Entries {
830839
if HasChanged(change.Action) {
831840
changeSetLog.WriteString(change.String() + "\n")
@@ -852,7 +861,11 @@ func (r *KustomizationReconciler) apply(ctx context.Context,
852861
if changeSet != nil && len(changeSet.Entries) > 0 {
853862
resultSet.Append(changeSet.Entries)
854863

855-
log.Info("server-side apply completed", "output", changeSet.ToMap(), "revision", revision)
864+
if r.GroupChangeLog {
865+
log.Info("server-side apply for cluster definitions completed", "output", changeSet.ToGroupedMap())
866+
} else {
867+
log.Info("server-side apply completed", "output", changeSet.ToMap(), "revision", revision)
868+
}
856869
for _, change := range changeSet.Entries {
857870
if HasChanged(change.Action) {
858871
changeSetLog.WriteString(change.String() + "\n")

internal/features/features.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ const (
4444
// should fail if a variable without a default value is declared in files
4545
// but is missing from the input vars.
4646
StrictPostBuildSubstitutions = "StrictPostBuildSubstitutions"
47+
48+
// GroupChangelog controls groups kubernetes objects names on log output
49+
// reduces cardinality of logs when logging to elasticsearch
50+
GroupChangeLog = "GroupChangeLog"
4751
)
4852

4953
var features = map[string]bool{
@@ -59,6 +63,9 @@ var features = map[string]bool{
5963
// StrictPostBuildSubstitutions
6064
// opt-in from v1.3
6165
StrictPostBuildSubstitutions: false,
66+
// GroupChangeLog
67+
// opt-in from v1.5
68+
GroupChangeLog: false,
6269
}
6370

6471
// FeatureGates contains a list of all supported feature gates and

main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ func main() {
234234
os.Exit(1)
235235
}
236236

237+
groupChangeLog, err := features.Enabled(features.GroupChangeLog)
238+
if err != nil {
239+
setupLog.Error(err, "unable to check feature gate "+features.GroupChangeLog)
240+
os.Exit(1)
241+
}
242+
237243
if err = (&controller.KustomizationReconciler{
238244
ControllerName: controllerName,
239245
DefaultServiceAccount: defaultServiceAccount,
@@ -251,6 +257,7 @@ func main() {
251257
StatusPoller: polling.NewStatusPoller(mgr.GetClient(), mgr.GetRESTMapper(), pollingOpts),
252258
DisallowedFieldManagers: disallowedFieldManagers,
253259
StrictSubstitutions: strictSubstitutions,
260+
GroupChangeLog: groupChangeLog,
254261
}).SetupWithManager(ctx, mgr, controller.KustomizationReconcilerOptions{
255262
DependencyRequeueInterval: requeueDependency,
256263
HTTPRetry: httpRetry,

0 commit comments

Comments
 (0)