Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

Fix bootstrap script#623

Open
davidsiaw wants to merge 1 commit intomasterfrom
fix-bootstrap
Open

Fix bootstrap script#623
davidsiaw wants to merge 1 commit intomasterfrom
fix-bootstrap

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
Contributor

@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
Contributor

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.

@Resonious Resonious requested review from Resonious and removed request for Resonious November 7, 2025 01:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants