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 bootstrap script #623

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix bootstrap script #623

wants to merge 1 commit into from

Conversation

davidsiaw
Copy link
Contributor

@davidsiaw davidsiaw commented Oct 9, 2020

A small change to Rails 5.2 meant that running rake tasks now checks for the presence of SECRET_KEY_BASE all the time. This probably wasn't the case when the script was first written.

This PR fixes the bootstrap script so it runs properly. Before, the script just dies with a cryptic message

/app/lib/tasks/bootstrap.rake:96:in `block (2 levels) in <top (required)>': Provisioning failed. (RuntimeError)

Further investigation (reading the logs sent to cloudwatch logs) revealed it was lacking the secret key base. (Also pretty cryptic)

ArgumentError: Missing `secret_key_base` for 'production' environment, set this string with `rails credentials:edit`

The way our bootstrap script works may be obsolete. In the future we will need to generate the credentials.yml.enc file and store it on S3 to be downloaded by containers before running rails and set the RAILS_MASTER_KEY env var on all instances.

@degicat
Copy link

degicat commented Oct 9, 2020

@Resonious please review this

@degicat degicat requested a review from Resonious October 9, 2020 09:37
Copy link
Member

@Resonious Resonious left a comment

Choose a reason for hiding this comment

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

@davidsiaw Change makes sense but I think there's a small error. Let me know if I'm just seeing things wrong 😆

Comment on lines -145 to +148
{key: "SECRET_KEY_BASE", value: SecureRandom.hex(64), secret: true},
{key: "SECRET_KEY_BASE", value: secret_key_base, secret: true},
Copy link
Member

Choose a reason for hiding this comment

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

I may be crazy, but it looks to me like this secret_key_base local variable is defined in the task bcn:bootstrap, and right here it is being used by the task bcn:bootstrap:remote. Those are different Ruby scopes so I suspect this line here will error out.

We can probably just keep the inline call to SecureRandom.hex(64) here, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah. That is odd. I wonder why this worked... It may have been because the variable was re-evaluated. You're right. It can just be the same key base here too.

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.

3 participants