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

0.13: [Bug]: Octal configuration values interpreted as decimal in Bonsai #4929

Closed
stefreak opened this issue Aug 8, 2023 · 5 comments · Fixed by #5183
Closed

0.13: [Bug]: Octal configuration values interpreted as decimal in Bonsai #4929

stefreak opened this issue Aug 8, 2023 · 5 comments · Fixed by #5183

Comments

@stefreak
Copy link
Member

stefreak commented Aug 8, 2023

Garden Bonsai (0.13) Bug

Current Behavior

YAML 1.1-style octal values (e.g. 0777) are interpreted as decimal in Bonsai configuration.

Expected behavior

Garden should either mention changes in octal value parsing in the Bonsai migration guide, or interpret both 0777 and 0o777 as octal values.

Reproducible example

In the main branch, apply this patch:

diff --git a/examples/build-dependencies/frontend/garden.yml b/examples/build-dependencies/frontend/garden.yml
index 5a8d6aa3f..ffdb086f0 100644
--- a/examples/build-dependencies/frontend/garden.yml
+++ b/examples/build-dependencies/frontend/garden.yml
@@ -35,6 +35,7 @@ spec:
         target: /app/config/
         exclude: [ garden.yml ]
         mode: one-way-replica
+        defaultFileMode: 0666
   ports:
     - name: http
       containerPort: 8080

then, cd examples/build-dependencies/frontend and run garden validate:

steffen@MacBook-Pro-3 frontend % garden validate
Validate ✔️

Garden v0.13 (Bonsai) is a major release with significant changes. Please help us improve it by reporting any issues/bugs here:
https://go.garden.io/report-bonsai
→ Run garden util hide-warning 0.13-bonsai to disable this warning.
ℹ garden               → Running in Garden environment local.default
ℹ providers            → Getting status...
✔ providers            → Cached (took 1.3 sec)
ℹ providers            → Run with --force-refresh to force a refresh of provider statuses.
ℹ graph                → Resolving actions and modules...
✔ graph                → Done (took 0.3 sec)
✖ deploy.frontend      → Failed processing resolve Deploy type=container name=frontend (took 0.17 sec). Here is the output:

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Error validating spec for Deploy type=container name=frontend (frontend): Mode permission bits out of range. Please specify a number between 0 and 0o777 in octal representation. The number needs to be prefixed with '0o' in YAML, e.g. 0o777.. Available keys: command, args, env, cpu, memory, volumes, privileged, addCapabilities, dropCapabilities, tty, deploymentStrategy, annotations, daemon, sync, localMode, image, ingresses, healthCheck, hotReload, timeout, limits, ports, replicas)
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────


Failed to resolve Deploy type=container name=frontend: Error: resolve Deploy type=container name=frontend failed: Error: Error validating spec for Deploy type=container name=frontend (frontend): Mode permission bits out of range. Please specify a number between 0 and 0o777 in octal representation. The number needs to be prefixed with '0o' in YAML, e.g. 0o777.. Available keys: command, args, env, cpu, memory, volumes, privileged, addCapabilities, dropCapabilities, tty, deploymentStrategy, annotations, daemon, sync, localMode, image, ingresses, healthCheck, hotReload, timeout, limits, ports, replicas)

See .garden/error.log for detailed error message

Workaround

Use YAML 1.2-style octal notation (e.g. 0o777)

Suggested solution(s)

I'm not sure; Did we update our YAML library in the mean time and it now uses the updated 1.2 spec? Can we instruct it to continue to interpret the outdated notation as octal numbers?

Additional context

This issue surfaced with the stricter validation in #4824

Your environment

  • OS: macOS
  • How I'm running Kubernetes: irrelevant

garden version

@stefreak
Copy link
Member Author

stefreak commented Aug 8, 2023

We are using the YAML 1.1-style notation in our docs: https://docs.garden.io/guides/code-synchronization#permissions-and-ownership

@stefreak
Copy link
Member Author

stefreak commented Aug 8, 2023

Thank you @porterchris for bringing this to our attention.

@jghowe
Copy link

jghowe commented Aug 11, 2023

Hi, this is issue is effectively blocking us from using 0.13 in a backward compatible way. Without any changes when using 0.13 I get these errors.

exercise-service: Error validating Module 'exercise-service' (.garden/sources/project/exercise-service--78b874c8d5): Mode permission bits out of range. Please specify a number between 0 and 0o777 in octal representation. The number needs to be prefixed with '0o' in YAML, e.g. 0o777.. Available keys: build, buildArgs, extraFlags, image, include, hotReload, dockerfile, services, tests, tasks)

Updating the values to the format 0o777 makes everything work in 0.13 but then when I tried to deploy the same project with 0.12 I get this error.

exercise-service: Error validating Module 'exercise-service' (.garden/sources/project/exercise-service--78b874c8d5): key 
.services[0][devMode][sync][0][defaultFileMode] must be a number

@stefreak
Copy link
Member Author

stefreak commented Oct 4, 2023

@jghowe @porterchris Since 0.13.16 we support YAML document markers for YAML 1.1 compatiblilty:

Add these two lines to the beginning of the garden.yml file:

%YAML 1.1
---

With this marker, 0.13 will correctly parse 0777 as octal numbers.

In Garden 0.12 and prior versions of 0.13 this marker has no effect; 0.12 only supports YAML 1.1.

With this marker, you can gradually move to 0.13 by supporting both 0.12 and 0.13 with the same configuration file.

Once you are fully done with the migration and everyone uses 0.13, you can remove the marker and use the YAML1.2-style octal numbers (0o777)

This ticket will be closed once we updated the Bonsai migration guide with this information.

@stefreak
Copy link
Member Author

stefreak commented Oct 4, 2023

YAML marker support was introduced in #4889 when we switched from using js-yaml to the yaml library for parsing YAML.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants