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

[Operator] Optional tag for collector #1196

Conversation

jdiegosierra
Copy link
Contributor

Resolves #1189

@jdiegosierra jdiegosierra requested a review from Allex1 as a code owner May 21, 2024 15:38
@jdiegosierra jdiegosierra requested a review from a team May 21, 2024 15:38
Comment on lines 52 to 53
{{- else if .Values.manager.collectorImage.repository }}
- --collector-image={{ .Values.manager.collectorImage.repository }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this and the above logic into a helper template so we don't have to do the same condition twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean, something like this?

{{- define "opentelemetry-operator.collectorImage" -}}
  {{- if and .Values.manager.collectorImage.repository .Values.manager.collectorImage.tag }}
    - --collector-image={{ .Values.manager.collectorImage.repository }}:{{ .Values.manager.collectorImage.tag }}
  {{- else if .Values.manager.collectorImage.repository }}
    - --collector-image={{ .Values.manager.collectorImage.repository }}
  {{- end -}}
{{- end }}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can do something like:

{{ - $tag = "" }}
{{ if .Values.manager.collectorImage.tag }}
{{ - $tag = ":" + .Values.manager.collectorImage.tag }}
{{- end }}
- --collector-image={{ .Values.manager.collectorImage.repository }}{{ $tag }}

Copy link
Contributor Author

@jdiegosierra jdiegosierra May 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, despite you are forcing the users to add a collector repository. I would add an if condition here so in case you remove the requirement in the future, it can avoid a bug if you forget to add the if condition here later.
Check it out:

{{- if .Values.manager.collectorImage.repository -}}
{{- $tag := "" -}}
{{- if .Values.manager.collectorImage.tag -}}
{{- $tag = print ":" .Values.manager.collectorImage.tag -}}
{{- end }}
- --collector-image={{ .Values.manager.collectorImage.repository }}{{ $tag }}
{{- end }}

@@ -49,6 +49,8 @@ spec:
{{- end }}
{{- if and .Values.manager.collectorImage.repository .Values.manager.collectorImage.tag }}
- --collector-image={{ .Values.manager.collectorImage.repository }}:{{ .Values.manager.collectorImage.tag }}
{{- else if .Values.manager.collectorImage.repository }}
- --collector-image={{ .Values.manager.collectorImage.repository }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdiegosierra in the situation that we don't pass in a tag, are you sure the tag that ends up being uses is the default collector version from the operator and not the latest version of the set image repository?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried with the latest version, so let me check it with a different one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TylerHelmuth It works as expected:
appVersion: 0.100.1

manager:
  image:
    repository: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
    tag: "0.99.0"
  collectorImage:
    repository: ""
    tag: ""
k describe pod opentelemetry-operator-79cbd68444-wdpl9 | grep Image: 
    Image:         ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.99.0
k describe pod simplest-collector-54bb659675-99d7g | grep Image:
    Image:         ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:0.99.0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about when you set and image repository and not a tag?

Copy link
Contributor Author

@jdiegosierra jdiegosierra May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that scenario, the operator assumes the collector image is the latest one. If we want to have both components with the same version in that specific scenario, I guess we can pick the tag from the operator.

# Source: opentelemetry-operator/templates/deployment.yaml
  - --collector-image=otel/opentelemetry-collector
image: "ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.99.0"
Image ID: docker.io/otel/opentelemetry-collector@sha256:fe7714849adfd251129be75e39c5c4fa7031d87146645afa5d391ab957845c18

https://hub.docker.com/layers/otel/opentelemetry-collector/0.101.0/images/sha256-9ad0a1312912ac2f52c17f50e2bd3dbfc74d990a60fa6aa02bc62c377a3eac8c?context=explore

Copy link
Contributor Author

@jdiegosierra jdiegosierra May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, that situation can not happen right now because it is mandatory to have both fields set:

{{- if and .Values.manager.collectorImage.repository .Values.manager.collectorImage.tag }}
- --collector-image={{ .Values.manager.collectorImage.repository }}:{{ .Values.manager.collectorImage.tag }}

@jdiegosierra
Copy link
Contributor Author

BTW, what do you think about changing this alert with a "warning"?

{{- if not .Values.manager.collectorImage.repository }}
{{ fail "[ERROR] 'manager.collectorImage.repository' must be set. See https://github.com/open-telemetry/opentelemetry-helm-charts/blob/main/charts/opentelemetry-operator/UPGRADING.md for instructions." }}
{{ end }}

If the user doesn't set a tag, the image will not take effect, and setting only the repository field as mandatory might create confusion:
{{- if and .Values.manager.collectorImage.repository .Values.manager.collectorImage.tag }}
- --collector-image={{ .Values.manager.collectorImage.repository }}:{{ .Values.manager.collectorImage.tag }}
{{- end }}
{{- if and .Values.manager.opampBridgeImage.repository .Values.manager.opampBridgeImage.tag }}

@jdiegosierra jdiegosierra requested a review from TylerHelmuth May 31, 2024 11:06
Copy link

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Jun 15, 2024
Copy link

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Operator] Delete collector image version from the values.yaml
4 participants