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

Copy desired Service ports when reconciling #299

Merged
merged 2 commits into from
May 27, 2021
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
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