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

Add support of setting revisionHistoryLimit #386

Merged
merged 5 commits into from
Nov 8, 2024

Conversation

MonkeyCanCode
Copy link
Contributor

Description

The current Helm chart doesn’t allow customization of the revisionHistoryLimit parameter, which is crucial for controlling the number of ReplicaSets retained for K8S deployment. This PR introduces the ability to set revisionHistoryLimit in the values file, defaulting to the standard value if not specified.

Also, I cleanup one comment in ingress.yaml which is not needed.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

When revisionHistoryLimit is not set:

xxx@DESKTOP:~/k8s/polaris/helm/polaris(add_revisionHistoryLimit)$ cat myvalues.yaml | grep revision
revisionHistoryLimit: ~
xxx@DESKTOP:~/k8s/polaris/helm/polaris(add_revisionHistoryLimit)$ helm template polaris -f myvalues.yaml . | grep revision
walk.go:74: found symbolic link in path: /home/yong/k8s/polaris/helm/polaris/LICENSE resolves to /home/yong/k8s/polaris/LICENSE. Contents of linked file included and used

When revisionHistoryLimit is set to 0:

xxx@DESKTOP:~/k8s/polaris/helm/polaris(add_revisionHistoryLimit)$ cat myvalues.yaml | grep revision
revisionHistoryLimit: 0
xxx@DESKTOP:~/k8s/polaris/helm/polaris(add_revisionHistoryLimit)$ helm template polaris -f myvalues.yaml . | grep revision
walk.go:74: found symbolic link in path: /home/yong/k8s/polaris/helm/polaris/LICENSE resolves to /home/yong/k8s/polaris/LICENSE. Contents of linked file included and used
  revisionHistoryLimit: 0

When revisionHistoryLimit is set to 1:

xxx@DESKTOP:~/k8s/polaris/helm/polaris(add_revisionHistoryLimit)$ cat myvalues.yaml | grep revision
revisionHistoryLimit: 1
xxx@DESKTOP:~/k8s/polaris/helm/polaris(add_revisionHistoryLimit)$ helm template polaris -f myvalues.yaml . | grep revision
walk.go:74: found symbolic link in path: /home/yong/k8s/polaris/helm/polaris/LICENSE resolves to /home/yong/k8s/polaris/LICENSE. Contents of linked file included and used
  revisionHistoryLimit: 1

Checklist:

Please delete options that are not relevant.

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

@@ -31,6 +31,9 @@ spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
{{- if not (has (quote .Values.revisionHistoryLimit) (list "" (quote ""))) }}
Copy link
Contributor

Choose a reason for hiding this comment

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

@MonkeyCanCode we just merged support for helm-unit. If you update your branch, maybe you could add a small unit test for this field? Especially for the logic around differentiating 0 from nil or "". Thanks 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice. Will look into this later today.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adutra this had being added. I really like this approach with validating helm (compared to how I was doing it earlier via helm template). I can add the remaining test cases in for the next PR if there is no concern on your end and no one is already working on it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Excellent tests 👍
And OK to add missing test cases little by little.

@MonkeyCanCode MonkeyCanCode mentioned this pull request Oct 29, 2024
10 tasks
@MonkeyCanCode
Copy link
Contributor Author

@adutra new PR for the remaining manifest had being created in #409. Please take a look when you get a chance and let me know if anything should be changed.

@adutra
Copy link
Contributor

adutra commented Nov 8, 2024

@MonkeyCanCode I merged #409 before this one, which was probably a mistake. And now we have a conflict on this PR. Could you resolve the conflict please? I'll merge as soon as CI passes.

@MonkeyCanCode
Copy link
Contributor Author

@MonkeyCanCode I merged #409 before this one, which was probably a mistake. And now we have a conflict on this PR. Could you resolve the conflict please? I'll merge as soon as CI passes.

Checking

@MonkeyCanCode
Copy link
Contributor Author

MonkeyCanCode commented Nov 8, 2024

@adutra PR is fixed. What u did there is correct. The problem for the conflict is due to both MR making the same change to ingress.yaml (I fixed one thing there earlier for this PR...then one week later fix the same on the PR you just merged along with additional unit cases etc.). Here is the local test status:

yong@DESKTOP:~/k8s/polaris(add_revisionHistoryLimit)$ helm unittest helm/polaris/ 2>&1 | grep -v 'symbolic link'

### Chart [ polaris ] helm/polaris/

 PASS   helm/polaris/tests/configmap_test.yaml
 PASS   helm/polaris/tests/deployment_test.yaml
 PASS   helm/polaris/tests/hpa_test.yaml
 PASS   helm/polaris/tests/ingress_test.yaml
 PASS   helm/polaris/tests/job_test.yaml
 PASS   helm/polaris/tests/service_test.yaml
 PASS   helm/polaris/tests/serviceaccount_test.yaml

Charts:      1 passed, 1 total
Test Suites: 7 passed, 7 total
Tests:       156 passed, 156 total
Snapshot:    0 passed, 0 total
Time:        408.283818ms

@adutra adutra merged commit d1631ba into apache:main Nov 8, 2024
5 checks passed
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 this pull request may close these issues.

2 participants