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

distinguish unset and empty values for storageClassName #2600

Closed
bryanlarsen opened this issue Jun 20, 2017 · 10 comments
Closed

distinguish unset and empty values for storageClassName #2600

bryanlarsen opened this issue Jun 20, 2017 · 10 comments
Labels
feature help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.

Comments

@bryanlarsen
Copy link

In a Kubernetes 1.6 PVC, storageClassName has different behaviour when passed an empty string versus not specified. An empty string means disable dynamic provisioning, not specified means use the default provisioner.

Charts should enable this behaviour, but I can't figure out how to make it happen using the go template syntax. go template's if treats the empty string as falsy, and everything i try to use to distinguish an empty string either works the same on an undefined value (len), or crashes (eq nil).

Perhaps this is why Hugo added the 'isset' function. Something like this would likely work if we had isset:

  {{- if (isset .Values.alertmanager.persistentVolume "storageClass") }}
  storageClassName: "{{ .Values.alertmanager.persistentVolume.storageClass }}"
  {{- end }}

Is there any way to do this? If not can we pull in Hugo's isset or some other way to do it?

@seh
Copy link
Contributor

seh commented Jun 21, 2017

While I agree that isset is a nicer solution, one workaround to consider is to honor a sentinel storage class name that's invalid. A valid name must be a DNS subdomain. Following that down into kubernetes/apimachinery, we find the governing regular expression, which is a lowercase letter or digit, followed by any number of lowercase letters, digits, or hyphens, followed by a lowercase letter or digit. In other words, hyphens are only allowed in the middle. Hence, the following are invalid storage class names:

  • -default
  • default-
  • !default

You can imagine many more. What if you chose one of them and said that that's the value an release uses to choose the default provisioner?

@bryanlarsen
Copy link
Author

That's a very reasonable solution for my own charts, but it's fairly hacky to get adopted as the right way to do things for public charts. I'll try a PR for the prometheus chart using:

{{- if .Values.alertmanager.persistentVolume.storageClass }}
{{- if (eq "-" .Values.alertmanager.persistentVolume.storageClass) }}
  storageClassName: ""
{{- else }}
  storageClassName: "{{ .Values.alertmanager.persistentVolume.storageClass }}"
{{- end }}
{{- end }}

@seh
Copy link
Contributor

seh commented Jun 21, 2017

Yes, Bryan, I wasn't trying to knock your proposed enhancement. I was just trying to help you make progress in the meantime.

@thomastaylor312
Copy link
Contributor

Thanks for the request here @bryanlarsen. I'll tag it as a feature. If you wanted to submit something for this, please let us know!

@thomastaylor312 thomastaylor312 added feature help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Jun 23, 2017
mgoodness pushed a commit to bryanlarsen/charts that referenced this issue Aug 1, 2017
Ditching the alpha storage class annotation and using the 1.6 style specification instead brings the following benefits:

- a standard way to specify the default provisioner
- a mechanism to disble the dynamic provisioner

Unfortunately, go template makes the second one hacky.   See helm/helm#2600 for more details.   So instead of using an empty string to disable the dynamic provisioner, this PR uses "-".
mgoodness pushed a commit to helm/charts that referenced this issue Aug 1, 2017
* prometheus: switch to Kubernetes 1.6 storage class specification

Ditching the alpha storage class annotation and using the 1.6 style specification instead brings the following benefits:

- a standard way to specify the default provisioner
- a mechanism to disble the dynamic provisioner

Unfortunately, go template makes the second one hacky.   See helm/helm#2600 for more details.   So instead of using an empty string to disable the dynamic provisioner, this PR uses "-".

* Bump major version
@technosophos
Copy link
Member

A PR on Sprig would be the best way to do this. I'll be rolling a new Sprig release for the upcoming Helm update.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or @fejta.
/lifecycle stale

@thomastaylor312
Copy link
Contributor

/remove-lifecycle stale

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle stale

@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

cakrit pushed a commit to netdata/helmchart that referenced this issue Nov 3, 2019
I think using the default storage class is a more sane default value for the `storageclass`.

Also, since the empty string as storage class has a special meaning we use "-" to denote the absence of storageclass (resulting to selecting the default storageclass) [1]

[1] helm/helm#2600
scottrigby pushed a commit to prometheus-community/helm-charts that referenced this issue Aug 8, 2020
* prometheus: switch to Kubernetes 1.6 storage class specification

Ditching the alpha storage class annotation and using the 1.6 style specification instead brings the following benefits:

- a standard way to specify the default provisioner
- a mechanism to disble the dynamic provisioner

Unfortunately, go template makes the second one hacky.   See helm/helm#2600 for more details.   So instead of using an empty string to disable the dynamic provisioner, this PR uses "-".

* Bump major version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
Projects
None yet
Development

No branches or pull requests

6 participants