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

Helm chart: Add enableServiceLinks #7129

Merged
merged 6 commits into from
Jan 18, 2023

Conversation

TAYTS
Copy link
Contributor

@TAYTS TAYTS commented Sep 10, 2022

What this PR does / why we need it:
This is to allow disable enableServiceLinks so that the service environments are not injected into the pods where in my scenario Loki is deployed in the same namespace as the Knative services resulted the Loki pod unable to start up due to too many service environment being injected.

Reference issue for pod unable to startup due to too many services: kubernetes/kubernetes#84539 (comment)

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Checklist

  • Documentation added
  • Tests updated
  • Is this an important fix or new feature? Add an entry in the CHANGELOG.md.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/upgrading/_index.md

@TAYTS TAYTS requested a review from a team as a code owner September 10, 2022 13:07
@CLAassistant
Copy link

CLAassistant commented Sep 10, 2022

CLA assistant check
All committers have signed the CLA.

@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@jeschkies
Copy link
Contributor

Could you raise the Helm Chart version so it's released?

@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@TAYTS
Copy link
Contributor Author

TAYTS commented Sep 14, 2022

@jeschkies I have updated the Helm chart version, please help to review again, thank you

Copy link
Collaborator

@trevorwhitney trevorwhitney left a comment

Choose a reason for hiding this comment

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

Can you describe the problem a bit more? Is there some technical limit on the number of service environment variables that can be injected into a POD? What was the technical issue this created for you?

@@ -32,6 +32,13 @@ spec:
{{- include "loki.gatewaySelectorLabels" . | nindent 8 }}
spec:
serviceAccountName: {{ include "loki.serviceAccountName" . -}}
{{- if semverCompare ">=1.13-0" .Capabilities.KubeVersion.GitVersion }}
{{- if or (.Values.loki.enableServiceLinks) (eq (.Values.loki.enableServiceLinks | toString) "<nil>") }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

why doe we need the toString compared to "<nil>"? shouldn't helm treat a nil value as falsey? Also, would you consider moving this to a single if statement, potentially even extracting a template function if it's messy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The toString is to set the enableServiceLinks to true (default value) when enableServiceLinks is not provided in the values.yaml.

We will need to have 2 if because in k8s version < v1.13.0, there is no enableServiceLinks and I have moved this chunk into template to make it dry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We were deploying the loki-stack in the same namespace as knative and as the service grow, we were not able to start the pod due to too many services environment variables being injected. We are moving loki-stack to different namespace at the moment to fix the issue, but thought this feature could help those that has constraint with the namespace(ie. only allow to deploy to certain namespace).

You can refer to the link I have attached about the pod unable to startup due to too many service environments injected into the pods.
Here is the link for an interesting experiment did for the knative: knative/serving#8498

@pull-request-size pull-request-size bot added size/S and removed size/M labels Sep 24, 2022
@TAYTS TAYTS force-pushed the feat/add-enable-service-links branch from d33f3ee to e8eccf2 Compare September 24, 2022 06:58
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0.1%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@TAYTS
Copy link
Contributor Author

TAYTS commented Oct 16, 2022

@trevorwhitney Is it possible to help review this MR? Thank you so much

Copy link
Collaborator

@trevorwhitney trevorwhitney left a comment

Choose a reason for hiding this comment

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

After reading a bit more into those Knative issue you linked (thank you) I'm open to this change. I have one small tweak to your template function I'd like to see, then LGTM!

production/helm/loki/templates/_helpers.tpl Outdated Show resolved Hide resolved
Comment on lines 366 to 662
{{- if or (.Values.loki.enableServiceLinks) (eq (.Values.loki.enableServiceLinks | toString) "<nil>") -}}
enableServiceLinks: true
{{- else -}}
enableServiceLinks: false
{{- end -}}
Copy link
Collaborator

@trevorwhitney trevorwhitney Oct 18, 2022

Choose a reason for hiding this comment

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

I still don't love the to string and comparison to the string "<nil>", as I feel like that's too tightly coupled to go template implementation details. How would you feel about switching the logic to avoid that?

Suggested change
{{- if or (.Values.loki.enableServiceLinks) (eq (.Values.loki.enableServiceLinks | toString) "<nil>") -}}
enableServiceLinks: true
{{- else -}}
enableServiceLinks: false
{{- end -}}
{{- if not .Values.loki.enableServiceLinks -}}
enableServiceLinks: false
{{- else -}}
enableServiceLinks: true
{{- end -}}

Copy link
Collaborator

Choose a reason for hiding this comment

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

this result in a true if it's explicitly true or omitted

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This won't work because if the value is omitted, it is treated as false

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 made the change to {{- if or (.Values.loki.enableServiceLinks) (ne .Values.loki.enableServiceLinks false) -}} so instead of using toString will check if it is false, this way will decouple with go templating implementation, hope this is ok for you

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not following. My understanding was we want enableServiceLinks to be true if it's either explicitly set to true or if it's omitted. The above should work since we set the default to true, so if omitted it should use the default value. I checked out your branch, and made only the change above, and these are my results.

helm template . --set loki.enableServiceLinks=false --show-only templates/gateway/deployment-gateway.yaml:

---
# Source: loki/templates/gateway/deployment-gateway.yaml
...
    spec:
      serviceAccountName: loki
      enableServiceLinks: false
...

helm template . --set loki.enableServiceLinks=true --show-only templates/gateway/deployment-gateway.yaml:

---
# Source: loki/templates/gateway/deployment-gateway.yaml
...
    spec:
      serviceAccountName: loki
      enableServiceLinks: true
...

helm template . --show-only templates/gateway/deployment-gateway.yaml

---
# Source: loki/templates/gateway/deployment-gateway.yaml
...
    spec:
      serviceAccountName: loki
      enableServiceLinks: true
...

Sorry for the confusion, but is this not the correct behavior?

Copy link
Contributor Author

@TAYTS TAYTS Oct 25, 2022

Choose a reason for hiding this comment

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

This second condition is to cover the case where the enableServiceLinks is missing in values.yaml or it is set to empty string

Copy link
Collaborator

Choose a reason for hiding this comment

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

If it's missing in values.yaml I don't understand why it wouldn't get the default value?

@TAYTS TAYTS force-pushed the feat/add-enable-service-links branch from adcf94f to e3a1ef5 Compare October 22, 2022 22:35
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0.1%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@TAYTS TAYTS force-pushed the feat/add-enable-service-links branch from e3a1ef5 to b0bd555 Compare October 25, 2022 20:36
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

1 similar comment
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

Copy link
Contributor

@jeschkies jeschkies left a comment

Choose a reason for hiding this comment

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

Thanks. Could you generate the documentation reference?

@github-actions github-actions bot added the type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories label Jan 17, 2023
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@jeschkies
Copy link
Contributor

@TAYTS could you merge the current main branch? It will fix the build error.

@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

1 similar comment
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@trevorwhitney trevorwhitney merged commit 94ee5a2 into grafana:main Jan 18, 2023
mraboosk pushed a commit to mraboosk/loki that referenced this pull request Oct 7, 2024
**What this PR does / why we need it**:
This is to allow disable `enableServiceLinks` so that the service
environments are not injected into the pods where in my scenario Loki is
deployed in the same namespace as the Knative services resulted the Loki
pod unable to start up due to too many service environment being
injected.

Reference issue for pod unable to startup due to too many services:
kubernetes/kubernetes#84539 (comment)

Co-authored-by: Trevor Whitney <trevorjwhitney@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/helm size/M type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants