Skip to content

Commit a7a9c95

Browse files
Fixes reconciling Internal Traffic Policy changes and adds test (#2060)
* Fixes reconciling Internal Traffic Policy changes and add tests * add changelog * issue in changelog
1 parent 8d3000e commit a7a9c95

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed
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. operator, target allocator, github action)
5+
component: operator
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: Fixes reconciling otel-collector service's internal traffic policy changes.
9+
10+
# One or more tracking issues related to the change
11+
issues: [2061]
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:

pkg/collector/reconcile/service.go

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ func expectedServices(ctx context.Context, params manifests.Params, expected []*
104104
}
105105
updated.Spec.Ports = desired.Spec.Ports
106106
updated.Spec.Selector = desired.Spec.Selector
107+
updated.Spec.InternalTrafficPolicy = desired.Spec.InternalTrafficPolicy
107108

108109
patch := client.MergeFrom(existing)
109110

pkg/collector/reconcile/service_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,22 @@ func TestExpectedServices(t *testing.T) {
7878
assert.Equal(t, instanceUID, actual.OwnerReferences[0].UID)
7979
assert.Equal(t, "Newest", actual.Spec.Selector["app.kubernetes.io/version"])
8080
})
81+
t.Run("should update service on internal traffic policy change", func(t *testing.T) {
82+
serviceInstance := service("test-collector", params().Instance.Spec.Ports)
83+
createObjectIfNotExists(t, "test-collector", serviceInstance)
84+
85+
newService := serviceWithInternalTrafficPolicy("test-collector", params().Instance.Spec.Ports, v1.ServiceInternalTrafficPolicyLocal)
86+
err := expectedServices(context.Background(), params(), []*v1.Service{newService})
87+
assert.NoError(t, err)
88+
89+
actual := v1.Service{}
90+
exists, err := populateObjectIfExists(t, &actual, types.NamespacedName{Namespace: "default", Name: "test-collector"})
91+
92+
assert.NoError(t, err)
93+
assert.True(t, exists)
94+
assert.Equal(t, instanceUID, actual.OwnerReferences[0].UID)
95+
assert.Equal(t, v1.ServiceInternalTrafficPolicyLocal, *actual.Spec.InternalTrafficPolicy)
96+
})
8197
}
8298

8399
func TestDeleteServices(t *testing.T) {

0 commit comments

Comments
 (0)