Jets app deploys that have a Job error out with "YAML aliases are not allowed in CloudFormation templates"
Closed this issue · 1 comments
Checklist
- Upgrade Jets: Are you using the latest version of Jets? This allows Jets to fix issues fast. There's a
jets upgrade
command that makes this a simple task. There's also an Upgrading Guide: http://rubyonjets.com/docs/upgrading/ - Reproducibility: Are you reporting a bug others will be able to reproduce and not asking a question. If you're unsure or want to ask a question, do so on https://community.rubyonjets.com
- Code sample: Have you put together a code sample to reproduce the issue and make it available? Code samples help speed up fixes dramatically. If it's an easily reproducible issue, then code samples are not needed. If you're unsure, please include a code sample.
My Environment
Software | Version |
---|---|
Operating System | Ubuntu 20.04 |
Jets | 3.0.9 |
Ruby | 2.7.2 |
Expected Behaviour
Deploying a jets app that includes an active job with a cron trigger succeeds
Current Behavior
Deploying a jets app that that includes an active job with a cron trigger fails with this error during deploy:
YAML aliases are not allowed in CloudFormation templates
Step-by-step reproduction instructions
Try deploying an app with an active job that has a cron trigger string
Code Sample
Example job:
class MessengerJob < ApplicationJob
class_timeout 10.minutes
environment(DB_POOL: 32)
cron '0/1 * * * ? *' # at the start of every minute
def process_messages
# do work here
end
end
Solution Suggestion
We tried tweaking a bunch of things and still get the same error, so I suspect this is a general issue not related to our specific cron string, but I could be wrong
Bummer. What's going on is the
class_timeout 10.minutes
Creates the YAML aliases
error.
When jets builds the project and the cloudformation templates it calls YAML dump. With 10.minutes
is a ActiveSupport::Duration
class. The YAML dump serializes this info into the yaml.
$ jets build
$ grep -A 3 Timeout /tmp/jets/demo/templates/demo-dev-app-messenger_job.yml
Timeout: !ruby/object:ActiveSupport::Duration
value: 600
parts:
:minutes: 10
The serialization creates a !ruby/object:ActiveSupport::Duration
, which CloudFormation thinks is a YAML alias and hence the error.
Instead you'll can do this:
class_timeout 10.minutes.to_i
The produces:
$ jets build
$ grep Timeout /tmp/jets/demo/templates/demo-dev-app-messenger_job.yml
Timeout: 600
So try using class_timeout 10.minutes.to_i
, that should deploy successfully.
Also, looked into possibly doing a .to_i
conversion on ActiveSupport::Duration
values 🧐 But unsure if it's worth it at the moment. Closing for now. Hope that helps.