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

Always call tpl outside of with blocks to preserve backwards compatibility #554

Merged
merged 1 commit into from
Jun 6, 2024

Conversation

petewall
Copy link
Collaborator

@petewall petewall commented Jun 4, 2024

Even though this functionality was fixed in 3.14, some systems (like ArgoCD) might not be able to upgrade so quickly or easily.

Notes for reviewers: . is the current context, which gets modified by with or with range, $ is always the top context. It's just good practice to use $, which is why this one didn't need to change: charts/k8s-monitoring/templates/extra-manifests.yaml

@petewall petewall self-assigned this Jun 4, 2024
@petewall petewall linked an issue Jun 4, 2024 that may be closed by this pull request
@petewall
Copy link
Collaborator Author

petewall commented Jun 4, 2024

Installed Helm 3.10:

% ./helm version
version.BuildInfo{Version:"v3.10.3", GitCommit:"835b7334cfe2e5e27870ab3ed4135f136eecc704", GitTreeState:"clean", GoVersion:"go1.18.9"}

Using the published chart:

% ./helm template k8smon grafana/k8s-monitoring -f charts/k8s-monitoring/ci/ci-2-values.yaml          
Error: template: k8s-monitoring/templates/hooks/validate-configuration.yaml:126:8: executing "k8s-monitoring/templates/hooks/validate-configuration.yaml" at <include "alloyEventsConfig" .>: error calling include: template: k8s-monitoring/templates/_configs.tpl:105:6: executing "alloyEventsConfig" at <include "alloy.config.logs.cluster_events" .>: error calling include: template: k8s-monitoring/templates/alloy_config/_cluster_events.alloy.txt:17:3: executing "alloy.config.logs.cluster_events" at <tpl .extraStageBlocks .>: error calling tpl: cannot retrieve Template.Basepath from values inside tpl function: stage.static_labels {
  values = {
    color = "red",
  }
}
: "BasePath" is not a value

Use --debug flag to render out invalid YAML

Using the changes in the PR:

% ./helm template k8smon -n monitoring charts/k8s-monitoring -f charts/k8s-monitoring/ci/ci-2-values.yaml
---
# Source: k8s-monitoring/charts/alloy-events/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
...

@petewall petewall force-pushed the fix/dont-call-tpl-inside-of-with-or-range-blocks branch from 88d0c1e to 3c56f91 Compare June 4, 2024 18:01
@petewall petewall requested review from skl, a team, nevermind89x and jewbetcha and removed request for a team June 4, 2024 18:02
Copy link
Member

@skl skl left a comment

Choose a reason for hiding this comment

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

Awesome PR description and testing comment! 🚀 💯

@petewall petewall merged commit d9efcb6 into main Jun 6, 2024
16 checks passed
@petewall petewall deleted the fix/dont-call-tpl-inside-of-with-or-range-blocks branch June 6, 2024 13:29
bentonam added a commit that referenced this pull request Jun 8, 2024
* Added Support for Alloy Module Imports

Resolves #537

* Added extraConfig Import Example

* Added Loki Metrics to Allow List (#535)

* Added Loki Metrics to Allow List

* Regenerated Output

* Regenerated Docs

* Update Grafana Alloy (#546)

Signed-off-by: Pete Wall <[email protected]>

* Always call tpl outside of with blocks to preserve backwards compatibility (#554)

Signed-off-by: Pete Wall <[email protected]>

* Added schema

* Renamed modules.alias to modules.name

* Added Support for Journal Logs (#545)

* Added Support for Journal Logs

Resolves #544

* Fixed formatting

* Added Loki Metrics to Allow List (#535)

* Added Loki Metrics to Allow List

* Regenerated Output

* Regenerated Docs

* Added Support for Journal Logs

Resolves #544

* Added CI Test

* Fixed Formatting

* Updated Test Queries

* Regenerated Documentation

* Removed Journal from Test

Kind nodes do not have systemd

* Update Grafana Alloy (#546)

Signed-off-by: Pete Wall <[email protected]>

* Added Support for Journal Logs

Resolves #544

* Revert "Updated Test Queries"

This reverts commit 8de520c.

* Regenerated

---------

Signed-off-by: Pete Wall <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Added Support for Alloy Module Imports

Resolves #537

* Added extraConfig Import Example

* Added schema

* Renamed modules.alias to modules.name

* Generated Outputs

---------

Signed-off-by: Pete Wall <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Pete Wall <[email protected]>
bentonam added a commit that referenced this pull request Jun 8, 2024
* Added Support for Alloy Module Imports

Resolves #537

* Added extraConfig Import Example

* Added Loki Metrics to Allow List (#535)

* Added Loki Metrics to Allow List

* Regenerated Output

* Regenerated Docs

* Update Grafana Alloy (#546)

Signed-off-by: Pete Wall <[email protected]>

* Always call tpl outside of with blocks to preserve backwards compatibility (#554)

Signed-off-by: Pete Wall <[email protected]>

* Added schema

* Renamed modules.alias to modules.name

* Added Support for Journal Logs (#545)

* Added Support for Journal Logs

Resolves #544

* Fixed formatting

* Added Loki Metrics to Allow List (#535)

* Added Loki Metrics to Allow List

* Regenerated Output

* Regenerated Docs

* Added Support for Journal Logs

Resolves #544

* Added CI Test

* Fixed Formatting

* Updated Test Queries

* Regenerated Documentation

* Removed Journal from Test

Kind nodes do not have systemd

* Update Grafana Alloy (#546)

Signed-off-by: Pete Wall <[email protected]>

* Added Support for Journal Logs

Resolves #544

* Revert "Updated Test Queries"

This reverts commit 8de520c.

* Regenerated

---------

Signed-off-by: Pete Wall <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Added Support for Alloy Module Imports

Resolves #537

* Added extraConfig Import Example

* Added schema

* Renamed modules.alias to modules.name

* Generated Outputs

---------

Signed-off-by: Pete Wall <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Pete Wall <[email protected]>
bentonam added a commit that referenced this pull request Jun 11, 2024
* Fixed alloy run Lint Issue

* Added support for externalLabelsDynamic

* Renamed externalLabelsDynamic to externalLabelsFrom

* Update Grafana Alloy (#549)

Signed-off-by: Pete Wall <[email protected]>

* Update Kube State Metrics (#551)

Signed-off-by: Pete Wall <[email protected]>

* Update Prometheus Operator CRDs (#548)

Signed-off-by: Pete Wall <[email protected]>
Co-authored-by: petewall <[email protected]>

* Bump version to 1.0.13

Signed-off-by: Pete Wall <[email protected]>

* Alloy Metric Module Imports (#543)

* Added Support for Alloy Module Imports

Resolves #537

* Added extraConfig Import Example

* Added Loki Metrics to Allow List (#535)

* Added Loki Metrics to Allow List

* Regenerated Output

* Regenerated Docs

* Update Grafana Alloy (#546)

Signed-off-by: Pete Wall <[email protected]>

* Always call tpl outside of with blocks to preserve backwards compatibility (#554)

Signed-off-by: Pete Wall <[email protected]>

* Added schema

* Renamed modules.alias to modules.name

* Added Support for Journal Logs (#545)

* Added Support for Journal Logs

Resolves #544

* Fixed formatting

* Added Loki Metrics to Allow List (#535)

* Added Loki Metrics to Allow List

* Regenerated Output

* Regenerated Docs

* Added Support for Journal Logs

Resolves #544

* Added CI Test

* Fixed Formatting

* Updated Test Queries

* Regenerated Documentation

* Removed Journal from Test

Kind nodes do not have systemd

* Update Grafana Alloy (#546)

Signed-off-by: Pete Wall <[email protected]>

* Added Support for Journal Logs

Resolves #544

* Revert "Updated Test Queries"

This reverts commit 8de520c.

* Regenerated

---------

Signed-off-by: Pete Wall <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Added Support for Alloy Module Imports

Resolves #537

* Added extraConfig Import Example

* Added schema

* Renamed modules.alias to modules.name

* Generated Outputs

---------

Signed-off-by: Pete Wall <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Pete Wall <[email protected]>

* Regenerated Output

* Updated README.md values.yaml reference

* Regenerated Output

* Added externalLabelsFrom CI Test

* Corrected Operator

---------

Signed-off-by: Pete Wall <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: petewall <[email protected]>
Co-authored-by: Pete Wall <[email protected]>
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.

Don't call tpl inside of with or range blocks
2 participants