Skip to content

Commit

Permalink
Copy desired Service ports when reconciling (#299)
Browse files Browse the repository at this point in the history
* Copy desired Service ports when reconciling

* Fix update service test
  • Loading branch information
thib92 authored May 27, 2021
1 parent 2ba1557 commit d97d94a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions pkg/collector/reconcile/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 6 additions & 6 deletions pkg/collector/reconcile/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -160,9 +162,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)

})
}
Expand Down

0 comments on commit d97d94a

Please sign in to comment.