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

fix(template): establish backwards bug-compatibility for kubernetes manifest files #6713

Merged
merged 3 commits into from
Dec 12, 2024

Conversation

stefreak
Copy link
Member

@stefreak stefreak commented Dec 12, 2024

What this PR does / why we need it:

Template strings in Kubernetes manifest files are partially resolved for legacy reasons. The partial resolve behaviour has been changed to improve sanity in #6685 but for kubernetes manifest files, we need to have a version of the old behaviour.

The expected legacy behaviour looks like this:

  • If template strings reference variables that do not exist there is no error
  • If a template string contains multiple template expressions, each expression can be partially resolved.
  • Template expressions are evaluated before parsing yaml, which means that valid yaml with template expressions can be resolved to invalid yaml (e.g. if variable values contain special characters)

This legacy behaviour can lead to quite some surprises and UX problems, for example #5266

I would suggest that we remove this functionality in 0.14 in favor of the patchResources feature

Which issue(s) this PR fixes:

Fixes #6711

Special notes for your reviewer:

…anifest files

Template strings in Kubernetes manifest files are partially resolved for legacy reasons. The partial resolve behaviour has been changed to improve sanity in #6685 but for kubernetes manifest files, we need to have a version of the old behaviour.

The expected legacy behaviour looks like this:
- If template strings reference variables that do not exist there is no error
- If a template string contains multiple template expressions, each expression can be partially resolved.
- Template expressions are evaluated before parsing yaml, which means that valid yaml with template expressions can be resolved to invalid yaml (e.g. if variable values contain special characters)

This legacy behaviour can lead to quite some surprises and UX problems, for example #5266

I would suggest that we remove this functionality in 0.14.
this commit fixes the "cannot find dockerfile" error that plagued us on
macos
@@ -253,14 +253,14 @@ export async function makeTempDir({
}: { git?: boolean; initialCommit?: boolean } = {}): Promise<TempDirectory> {
const tmpDir = await tmp.dir({ unsafeCleanup: true })
// Fully resolve path so that we don't get path mismatches in tests
const tmpPath = await realpath(tmpDir.path)
tmpDir.path = await realpath(tmpDir.path)
Copy link
Member Author

Choose a reason for hiding this comment

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

This change was needed to make it possible to run the integ tests locally on macos.

Copy link
Collaborator

@vvagaytsev vvagaytsev left a comment

Choose a reason for hiding this comment

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

Great job! 🚀

@thsig
Copy link
Collaborator

thsig commented Dec 12, 2024

I agree that we should remove this functionality in 0.14, or at least deprecate it and log warnings when it's used.

There are also problems in versioning kubernetes actions that use template strings in manifest files: If a variable is used in a manifest file but doesn't appear in the action config, changing that variable won't change the action version (since it's computed based on the unresolved manifest file).

@stefreak stefreak added this pull request to the merge queue Dec 12, 2024
Merged via the queue into main with commit 424b392 Dec 12, 2024
40 checks passed
@stefreak stefreak deleted the legacy-allow-partial branch December 12, 2024 12:53
@stefreak
Copy link
Member Author

If we want to deprecate this, we need to deprecate this in 0.13 and remove it in 0.14. That way users can be sure that their configuration will work with 0.14 if they eliminate the deprecation warnings.

@stefreak
Copy link
Member Author

Would be good to have an easy to use alternative, e.g. an includeYaml statement or a templateFile statement

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.

[Bug]: Templating logic change in garden 0.13.46 breaks deploys
3 participants