Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

[stable/jenkins] Make chart compatible with Helm 3 #20624

Closed
wants to merge 1 commit into from

Conversation

helfper
Copy link

@helfper helfper commented Feb 9, 2020

Signed-off-by: Helder Pereira helfper@gmail.com

What this PR does / why we need it:

Trying to install Jenkins chart with route enabled using Helm 3 fails because of openshift/origin#24060:

$ helm install jenkins . --set master.route.enabled=true
Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: [ValidationError(Route.spec): missing required field "host" in com.github.openshift.api.route.v1.RouteSpec, ValidationError(Route): missing required field "status" in com.github.openshift.api.route.v1.Route]

This PR adds the missing fields required by the Route v1 spec. Additionally, it also fixes the confusing binding from a value called master.route.path to the Route's host field.

Checklist

  • DCO signed
  • Chart Version bumped
  • Variables are documented in the README.md
  • Title of the PR starts with chart name (e.g. [stable/mychartname])

@helm-bot helm-bot added the Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). label Feb 9, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: helfper
To complete the pull request process, please assign viglesiasce
You can assign the PR to them by writing /assign @viglesiasce in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@helm-bot helm-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Feb 9, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @helfper. Thanks for your PR.

I'm waiting for a helm member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 9, 2020
Comment on lines 33 to 34
status:
ingress: []
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should not include a status in the generated manifests.

Copy link
Author

Choose a reason for hiding this comment

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

Adding status is needed to solve the problem that this PR is trying to address, that is being able to create this route using Helm 3. You can see that in the error I pasted and in the issue linked in the PR description.

Copy link
Collaborator

Choose a reason for hiding this comment

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

My feeling is that we would fix it at the wrong location. For me it's rather an upstream issue that those fields are marked as required. Introducing a fix here would also mean to remove it later.

Copy link
Author

Choose a reason for hiding this comment

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

While I completely agree that the status should have been made optional in the spec. As it stands, I'd argue that this chart is wrong by creating a resource that doesn't follow its specification.

@@ -18,7 +18,8 @@ metadata:
{{- end }}
name: {{ template "jenkins.fullname" . }}
spec:
host: {{ .Values.master.route.path }}
host: "{{ .Values.master.route.host }}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need a different value host can't we re-use the already existing hostName?

Copy link
Author

Choose a reason for hiding this comment

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

I feel it would be rather confusing to use master.ingress.hostName as the route's host, when we are not using anything else from master.ingress.* in the route definition. Unless it was changed to master.hostName.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agree that it's not ideal. The issue I see is that the hostname is also used to determine the Jenkins URL which is configured in the config map. Here is the template code:

{{/*
Returns the Jenkins URL
*/}}
{{- define "jenkins.url" -}}
{{- if .Values.master.jenkinsUrl }}
  {{- .Values.master.jenkinsUrl }}
{{- else }}
  {{- if .Values.master.ingress.hostName }}
    {{- if .Values.master.ingress.tls }}
      {{- default "https" .Values.master.jenkinsUrlProtocol }}://{{ .Values.master.ingress.hostName }}{{ default "" .Values.master.jenkinsUriPrefix }}
    {{- else }}
      {{- default "http" .Values.master.jenkinsUrlProtocol }}://{{ .Values.master.ingress.hostName }}{{ default "" .Values.master.jenkinsUriPrefix }}
    {{- end }}
  {{- else }}
      {{- default "http" .Values.master.jenkinsUrlProtocol }}://{{ template "jenkins.fullname" . }}:{{.Values.master.servicePort}}{{ default "" .Values.master.jenkinsUriPrefix }}
  {{- end}}
{{- end}}
{{- end -}}

https://github.com/helm/charts/blob/master/stable/jenkins/templates/_helpers.tpl#L51-L68

So it won't be as easy as introducing a new flag...

Copy link
Author

Choose a reason for hiding this comment

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

  1. It's seems the same due diligence was not done during the code review when this route was added initially. I don't think that, by any measure, this PR makes that situation worse than it is currently. Notice that the route's host can already be modified by setting master.route.path, which is not taken into account whatsoever in the jenkins.url definition.

  2. Even ignoring the route for a second, that logic for jenkins.url doesn't seem right. If I don't set the master.jenkinsUrl value and set master.ingress.enabled to false, the jenkins.url template might still use the value master.ingress.hostName.

  3. The logic for jenkins.url can easily be changed to take into account the route values:

{{- define "jenkins.url" -}}
{{- if .Values.master.jenkinsUrl }}
  {{- .Values.master.jenkinsUrl }}
{{- else if and .Values.master.ingress.enabled .Values.master.ingress.hostName }}
  {{- if .Values.master.ingress.tls }}
    {{- default "https" .Values.master.jenkinsUrlProtocol }}://{{ .Values.master.ingress.hostName }}{{ default "" .Values.master.jenkinsUriPrefix }}
  {{- else }}
    {{- default "http" .Values.master.jenkinsUrlProtocol }}://{{ .Values.master.ingress.hostName }}{{ default "" .Values.master.jenkinsUriPrefix }}
  {{- end }}
{{- else if and .Values.master.route.enabled .Values.master.route.host }}
  {{- default "http" .Values.master.jenkinsUrlProtocol }}://{{ .Values.master.route.host }}{{ default "" .Values.master.jenkinsUriPrefix }}
{{- else }}
  {{- default "http" .Values.master.jenkinsUrlProtocol }}://{{ template "jenkins.fullname" . }}:{{.Values.master.servicePort}}{{ default "" .Values.master.jenkinsUriPrefix }}
{{- end}}
{{- end -}}

@stale
Copy link

stale bot commented Mar 26, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

@stale stale bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 26, 2020
Signed-off-by: Helder Pereira <helfper@gmail.com>
@helm-bot helm-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 7, 2020
@stale stale bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 7, 2020
@stale
Copy link

stale bot commented May 7, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

@stale stale bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 7, 2020
@stale
Copy link

stale bot commented May 22, 2020

This issue is being automatically closed due to inactivity.

@stale stale bot closed this May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants