Skip to content

Commit 69e84a8

Browse files
authored
Fix hashing bug (open-telemetry#2899)
* add default annotation filter to prevent unnecessary reconciliation * oop * chlog * add comment
1 parent 792c47f commit 69e84a8

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

Diff for: .chloggen/fix-hashing-bug.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: bug_fix
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
5+
component: collector
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: Fixes a bug that would cause errant rollouts on a non-config related change.
9+
10+
# One or more tracking issues related to the change
11+
issues: [2899]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:

Diff for: internal/config/main.go

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func New(opts ...Option) Config {
7777
logger: logf.Log.WithName("config"),
7878
version: version.Get(),
7979
enableJavaInstrumentation: true,
80+
annotationsFilter: []string{"kubectl.kubernetes.io/last-applied-configuration"},
8081
}
8182
for _, opt := range opts {
8283
opt(&o)

Diff for: internal/config/options.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,12 @@ func WithLabelFilters(labelFilters []string) Option {
223223
}
224224
}
225225

226+
// WithAnnotationFilters is additive if called multiple times. It works off of a few default filters
227+
// to prevent unnecessary rollouts. The defaults include the following:
228+
// * kubectl.kubernetes.io/last-applied-configuration.
226229
func WithAnnotationFilters(annotationFilters []string) Option {
227230
return func(o *options) {
228-
229-
filters := []string{}
231+
filters := o.annotationsFilter
230232
for _, pattern := range annotationFilters {
231233
var result strings.Builder
232234

Diff for: internal/manifests/manifestutils/labels.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ import (
2626

2727
func IsFilteredSet(sourceSet string, filterSet []string) bool {
2828
for _, pattern := range filterSet {
29-
match, _ := regexp.MatchString(pattern, sourceSet)
30-
return match
29+
if match, _ := regexp.MatchString(pattern, sourceSet); match {
30+
return match
31+
}
3132
}
3233
return false
3334
}

0 commit comments

Comments
 (0)