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

expectedServices function not copying desired spec #256

Closed
bhiravabhatla opened this issue Apr 28, 2021 · 8 comments · Fixed by #299
Closed

expectedServices function not copying desired spec #256

bhiravabhatla opened this issue Apr 28, 2021 · 8 comments · Fixed by #299

Comments

@bhiravabhatla
Copy link
Contributor

bhiravabhatla commented Apr 28, 2021

updated := existing.DeepCopy()
if updated.Annotations == nil {
updated.Annotations = map[string]string{}
}
if updated.Labels == nil {
updated.Labels = map[string]string{}
}
updated.ObjectMeta.OwnerReferences = desired.ObjectMeta.OwnerReferences
for k, v := range desired.ObjectMeta.Annotations {
updated.ObjectMeta.Annotations[k] = v
}
for k, v := range desired.ObjectMeta.Labels {
updated.ObjectMeta.Labels[k] = v
}
patch := client.MergeFrom(&params.Instance)

I guess, we should be copying desired.Spec to updated.Spec if I am not wrong. -

  updated.Spec = desired.Spec

If we dont do that service spec wont be updated if some one adds a new receiver in config or explicit port in Spec.Ports of collector.

@jpkrohling
Copy link
Member

From what I remember, we can't simply copy the Spec, as the clusterIP has to either be empty or None. The service controller will then change the value to a real IP if it's empty, and an update of this resource will fail if we specify the IP ourselves. So, I prefer to cherry-pick the properties that we want to override.

@bhiravabhatla
Copy link
Contributor Author

bhiravabhatla commented Apr 28, 2021

Yep. I forgot about Cluster IP. we cant copy the whole spec. But I think we should copy spec.Ports atleast - or else we would miss out on any new ports added

@jpkrohling
Copy link
Member

Could you clarify on "ports added"? Do you mean that users might add ports to a service?

@bhiravabhatla
Copy link
Contributor Author

I meant some one can add a new receiver in opentelemetry collector CR config or a new port in CR spec.ports

@jpkrohling
Copy link
Member

Right, the new desired ports should override the current list of ports.

@bhiravabhatla
Copy link
Contributor Author

Yep :).

@thib92
Copy link
Contributor

thib92 commented May 27, 2021

Should we only copy the ports? Otherwise, which fields of the Service spec would we wish to copy?

@jpkrohling
Copy link
Member

jpkrohling commented May 27, 2021

Here are the reference docs for the Service object. I think copying the ports should be sufficient, but review it as well and see if you have another suggestion.

https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#service-v1-core

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants