Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes reconciling Internal Traffic Policy changes and adds test #2060

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .chloggen/fix-otel-collector-service-reconciliation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action)
component: operator

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Fixes reconciling otel-collector service's internal traffic policy changes.

# One or more tracking issues related to the change
issues: [2061]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
1 change: 1 addition & 0 deletions pkg/collector/reconcile/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func expectedServices(ctx context.Context, params manifests.Params, expected []*
}
updated.Spec.Ports = desired.Spec.Ports
updated.Spec.Selector = desired.Spec.Selector
updated.Spec.InternalTrafficPolicy = desired.Spec.InternalTrafficPolicy

patch := client.MergeFrom(existing)

Expand Down
16 changes: 16 additions & 0 deletions pkg/collector/reconcile/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ func TestExpectedServices(t *testing.T) {
assert.Equal(t, instanceUID, actual.OwnerReferences[0].UID)
assert.Equal(t, "Newest", actual.Spec.Selector["app.kubernetes.io/version"])
})
t.Run("should update service on internal traffic policy change", func(t *testing.T) {
serviceInstance := service("test-collector", params().Instance.Spec.Ports)
createObjectIfNotExists(t, "test-collector", serviceInstance)

newService := serviceWithInternalTrafficPolicy("test-collector", params().Instance.Spec.Ports, v1.ServiceInternalTrafficPolicyLocal)
err := expectedServices(context.Background(), params(), []*v1.Service{newService})
assert.NoError(t, err)

actual := v1.Service{}
exists, err := populateObjectIfExists(t, &actual, types.NamespacedName{Namespace: "default", Name: "test-collector"})

assert.NoError(t, err)
assert.True(t, exists)
assert.Equal(t, instanceUID, actual.OwnerReferences[0].UID)
assert.Equal(t, v1.ServiceInternalTrafficPolicyLocal, *actual.Spec.InternalTrafficPolicy)
})
}

func TestDeleteServices(t *testing.T) {
Expand Down