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

Refactor deploy/activate script #2069

Merged
merged 1 commit into from
Mar 29, 2018
Merged

Refactor deploy/activate script #2069

merged 1 commit into from
Mar 29, 2018

Conversation

monfresh
Copy link
Contributor

@monfresh monfresh commented Mar 28, 2018

Why: If the deploy/activate script is a shell script, it requires
calling Bundler.setup so that the files that the script depends on
are loaded. The problem is that the Bundler.setup call was preventing
us from running parallel builds in Circle CI.

I removed the Bundler.setup call in #2060 to see if that would allow
parallel builds, which it did, but I forgot to check if this would break
build deployment, and it did.

In order to allow the script to run during deployment and also allow
parallel builds to work, I defined a shell script that will fetch the
config from S3 via a rake task. That way, Rails and gems will already
be loaded. This also separates concerns and makes it easier to test the
S3 fetching in isolation. It also keeps things consistent with the other
scripts in the deploy directory.

Hi! Before submitting your PR for review, and/or before merging it, please
go through the following checklist:

  • For DB changes, check for missing indexes, check to see if the changes
    affect other apps (such as the dashboard), make sure the DB columns in the
    various environments are properly populated, coordinate with devops, plan
    migrations in separate steps.

  • For route changes, make sure GET requests don't change state or result in
    destructive behavior. GET requests should only result in information being
    read, not written.

  • For encryption changes, make sure it is compatible with data that was
    encrypted with the old code.

  • For secrets changes, make sure to update the S3 secrets bucket with the
    new configs in all environments.

  • Do not disable Rubocop or Reek offenses unless you are absolutely sure
    they are false positives. If you're not sure how to fix the offense, please
    ask a teammate.

  • When reading data, write tests for nil values, empty strings,
    and invalid formats.

  • When calling redirect_to in a controller, use _url, not _path.

  • When adding user data to the session, use the user_session helper
    instead of the session helper so the data does not persist beyond the user's
    session.

  • When adding a new controller that requires the user to be fully
    authenticated, make sure to add before_action :confirm_two_factor_authenticated.

@mark-from-usds
Copy link
Contributor

  • bundle exec rake app:activate
    rake aborted!
    TypeError: no implicit conversion of nil into String
    /srv/idp/releases/chef/lib/saml_idp_constants.rb:9:in <module:Constants>' /srv/idp/releases/chef/lib/saml_idp_constants.rb:4:in module:Idp'
    /srv/idp/releases/chef/lib/saml_idp_constants.rb:3:in <module:Saml>' /srv/idp/releases/chef/lib/saml_idp_constants.rb:2:in <top (required)>'
    [skipping a few]
    /srv/idp/shared/bundle/ruby/2.3.0/gems/railties-5.1.5/lib/rails/application.rb:445:in block in run_tasks_blocks' /srv/idp/shared/bundle/ruby/2.3.0/gems/rake-12.3.1/exe/rake:27:in <top (required)>'
    /opt/ruby_build/builds/2.3.6/bin/bundle:22:in load' /opt/ruby_build/builds/2.3.6/bin/bundle:22:in '
    Tasks: TOP => app:activate => environment
    (See full trace by running task with --trace)
    ---- End output of ./deploy/activate ----
    Ran ./deploy/activate returned 1

@monfresh
Copy link
Contributor Author

Fudge. It's the vicious cycle of needing the config to be present before loading the app. Back to the drawing board.

@monfresh monfresh force-pushed the mb-activate-script branch from fb45120 to ad1415d Compare March 28, 2018 21:32
@monfresh
Copy link
Contributor Author

@mark-from-usds Can you try again? I forced pushed a change.

@monfresh monfresh force-pushed the mb-activate-script branch from ad1415d to 4a5945f Compare March 28, 2018 22:59
@monfresh
Copy link
Contributor Author

I just recycled the markryan env with the latest changes. Fingers crossed.

@mark-from-usds
Copy link
Contributor

mark-from-usds commented Mar 29, 2018

---- Begin output of ./deploy/activate ----
STDOUT: deploy/activate starting
HOME: 
uid=1000(ubuntu) gid=1000(ubuntu) groups=1000(ubuntu)
/opt/ruby_build/builds/2.3.6/bin/bundle
`/` is not writable.
Bundler will use `/tmp/bundler/home/unknown' as your home directory temporarily.
bundler: failed to load command: bin/activate (bin/activate)
STDERR: + id
+ which bundle
+ bundle exec bin/activate
NameError: uninitialized constant Deploy::Activate::Rails
  /srv/idp/releases/chef/lib/deploy/activate.rb:38:in `env_yaml_path'
  /srv/idp/releases/chef/lib/deploy/activate.rb:17:in `run'
  bin/activate:5:in `<top (required)>'
---- End output of ./deploy/activate ----
Ran ./deploy/activate returned 1
[2018-03-29T13:57:15+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

@monfresh
Copy link
Contributor Author

Still not working but I know what the issue is. Hopefully the third time will be the charm.

**Why**: If the `deploy/activate` script is a shell script, it requires
calling `Bundler.setup` so that the files that the script depends on
are loaded. The problem is that the `Bundler.setup` call was preventing
us from running parallel builds in Circle CI.

I removed the `Bundler.setup` call in #2060 to see if that would allow
parallel builds, which it did, but I forgot to check if this would break
build deployment, and it did.

In order to allow the script to run during deployment and also allow
parallel builds to work, I defined a shell script that will fetch the
config from S3 by calling the ruby file directly using `bundle exec`.
That way, the gems will already be loaded. This also separates concerns
and makes it easier to test the S3 fetching in isolation. It also keeps
things consistent with the other scripts in the `deploy` directory.
@monfresh monfresh force-pushed the mb-activate-script branch from 4a5945f to 0476a99 Compare March 29, 2018 15:28
@monfresh
Copy link
Contributor Author

Yay! Success! Can you approve the PR please?

@monfresh monfresh merged commit 34633c1 into master Mar 29, 2018
@monfresh monfresh deleted the mb-activate-script branch March 29, 2018 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants