From c3695689e59715d5e91781aa4033862879184ec7 Mon Sep 17 00:00:00 2001 From: thib92 Date: Thu, 27 May 2021 11:21:00 +0200 Subject: [PATCH 1/2] Copy desired Service ports when reconciling --- pkg/collector/reconcile/service.go | 1 + pkg/collector/reconcile/service_test.go | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/collector/reconcile/service.go b/pkg/collector/reconcile/service.go index 821d39dfd0..4f5f09813f 100644 --- a/pkg/collector/reconcile/service.go +++ b/pkg/collector/reconcile/service.go @@ -194,6 +194,7 @@ func expectedServices(ctx context.Context, params Params, expected []corev1.Serv for k, v := range desired.ObjectMeta.Labels { updated.ObjectMeta.Labels[k] = v } + updated.Spec.Ports = desired.Spec.Ports patch := client.MergeFrom(existing) diff --git a/pkg/collector/reconcile/service_test.go b/pkg/collector/reconcile/service_test.go index dc15acb491..eebce6bca4 100644 --- a/pkg/collector/reconcile/service_test.go +++ b/pkg/collector/reconcile/service_test.go @@ -160,9 +160,7 @@ func TestExpectedServices(t *testing.T) { assert.NoError(t, err) assert.True(t, exists) assert.Equal(t, instanceUID, actual.OwnerReferences[0].UID) - // issue# https://github.com/open-telemetry/opentelemetry-operator/issues/256 - // Would uncomment once above issue is resolved - //assert.Contains(t, actual.Spec.Ports, extraPorts) + assert.Contains(t, actual.Spec.Ports, extraPorts) }) } From fe52700bd9753309b3eba99149f1d1048f3be5ac Mon Sep 17 00:00:00 2001 From: thib92 Date: Thu, 27 May 2021 14:30:07 +0200 Subject: [PATCH 2/2] Fix update service test --- pkg/collector/reconcile/service_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/collector/reconcile/service_test.go b/pkg/collector/reconcile/service_test.go index eebce6bca4..461f5f69ab 100644 --- a/pkg/collector/reconcile/service_test.go +++ b/pkg/collector/reconcile/service_test.go @@ -22,6 +22,7 @@ import ( v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/intstr" "github.com/open-telemetry/opentelemetry-operator/api/v1alpha1" "github.com/open-telemetry/opentelemetry-operator/internal/config" @@ -145,9 +146,10 @@ func TestExpectedServices(t *testing.T) { createObjectIfNotExists(t, "test-collector", &serviceInstance) extraPorts := v1.ServicePort{ - Name: "port-web", - Protocol: "TCP", - Port: 8080, + Name: "port-web", + Protocol: "TCP", + Port: 8080, + TargetPort: intstr.FromInt(8080), } ports := append(params().Instance.Spec.Ports, extraPorts)