Skip to content

Commit 1e533f2

Browse files
infernus01tekton-robot
authored andcommitted
fix(pruner): ensure enforcedConfigLevel is always defaulted and DeepCopy is correct
The SetDefaults change in commit 774867c guarded GlobalConfig.SetDefaults() behind a nil check to allow users to set historyLimit to null without it resetting. However, this meant enforcedConfigLevel was never filled in when a user provided a partial global-config (e.g. only ttlSecondsAfterFinished). The pruner controller then defaulted to the "resource" level internally, which silently ignores all namespace-level selector rules. Additionally, DeepCopyInto for TektonPrunerConfig copied the *GlobalConfig pointer instead of the underlying struct. This caused the Knative defaulting webhook to see no difference between the original and the copy after SetDefaults ran, so the patch was always null and defaults were never applied. Signed-off-by: Shubham Bhardwaj <shubbhar@redhat.com>
1 parent 49a148f commit 1e533f2

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

pkg/apis/operator/v1alpha1/tektonpruner_defaults.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,8 @@ func (p *Pruner) SetDefaults() {
3535
if p.GlobalConfig == nil {
3636
p.GlobalConfig = &config.GlobalConfig{}
3737
p.GlobalConfig.SetDefaults()
38+
} else if p.GlobalConfig.EnforcedConfigLevel == nil {
39+
v := config.EnforcedConfigLevelGlobal
40+
p.GlobalConfig.EnforcedConfigLevel = &v
3841
}
3942
}

pkg/apis/operator/v1alpha1/tektonpruner_types.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,8 @@ func (p *Pruner) IsDisabled() bool {
111111

112112
func (in *TektonPrunerConfig) DeepCopyInto(out *TektonPrunerConfig) {
113113
*out = *in
114-
return
114+
if in.GlobalConfig != nil {
115+
out.GlobalConfig = new(config.GlobalConfig)
116+
*out.GlobalConfig = *in.GlobalConfig
117+
}
115118
}

0 commit comments

Comments
 (0)