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

PaaS, CI, and production-friendly config; affects [jira] #2626

Merged
merged 25 commits into from
Jan 6, 2019
Merged

Conversation

paulmelnikow
Copy link
Member

@paulmelnikow paulmelnikow commented Jan 4, 2019

This implements the configuration mechanism I described in #2621. The heavy lifting is delegated to node-config with a minor assist from dotenv.

One open is how we deal with Docker. In the old version, the secrets are baked into the image. Now that they can be read from the environment at runtime, it probably would be better to do that. Alternatively we could pull them from the build-time environment into the image. Or both! @calebcartwright perhaps you have thoughts about how we could deal with that.

Some tasks pre-merge:

  • Set GH_TOKEN in staging and CI (it was GITHUB_TOKEN)
  • Sort out docker
  • Update production deploy task, adding .env setting NODE_CONFIG_ENV

Some housekeeping post-merge:

  • Prepare the production config file and do the first deploy
  • Start a changelog for self hosting
  • Inject secrets via the server
  • Inject config into trace

Close #1806 #2621

@paulmelnikow paulmelnikow added operations Hosting, monitoring, and reliability for the production badge servers self-hosting Discussion, problems, features, and documentation related to self-hosting Shields core Server, BaseService, GitHub auth, Shared helpers documentation Developer and end-user documentation blocker PRs and epics which block other work labels Jan 4, 2019
@shields-ci
Copy link

shields-ci commented Jan 4, 2019

Warnings
⚠️ This PR modified the server but none of its tests.
That's okay so long as it's refactoring existing code.
Messages
📖 ✨ Thanks for your contribution to Shields, @paulmelnikow!
📖

Thanks for contributing to our documentation. We ❤️ our documentarians!

Generated by 🚫 dangerJS against 589cc78

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2626 January 4, 2019 01:01 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2626 January 4, 2019 01:12 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2626 January 4, 2019 01:18 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2626 January 4, 2019 01:18 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2626 January 4, 2019 01:41 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2626 January 4, 2019 16:40 Inactive
@paulmelnikow paulmelnikow mentioned this pull request Jan 4, 2019
8 tasks
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2626 January 4, 2019 16:51 Inactive
Copy link
Member

@chris48s chris48s left a comment

Choose a reason for hiding this comment

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

nice work on this

@@ -123,7 +123,7 @@ Redis installation.
Server secrets
--------------

You can add your own server secrets in `private/secret.json`.
You can add your own server secrets in environment variables or `config/local.yml`.
Copy link
Member

Choose a reason for hiding this comment

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

One comment I'd have here is that if you're a self-hosting user and you've got all your secrets set up in private/secret.json, upgrading to this revision or later is going to break your install 🔧

I don't really have a clear idea how self-hosting users are managing their installs, but is there a way we can communicate this change well to a self-hosting user? As you've already flagged, one tool available is documentation, although maintaining a changelog when we don't really do releases/tags is a challenge. Maybe we should be doing releases too 🤔 . Perhaps we could also do something like in the bootstrap process could we check for the existence of private/secret.json and if it exists throw an exception with a message saying "you need to move your config to env vars/yaml"?

Also, if everyone has to re-write their config file anyway, maybe we should just drop this

if (serverSecrets.jira_user || serverSecrets.jira_username) {
/*
for legacy reasons we still allow
jira_username, jira_password
but prefer
jira_user, jira_pass
*/
options.auth = {
user: serverSecrets.jira_user || serverSecrets.jira_username,
pass: serverSecrets.jira_pass || serverSecrets.jira_password,
}
}
in this PR as there isn't really any backwards-compatibility to preserve at this point.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't really have a clear idea how self-hosting users are managing their installs, but is there a way we can communicate this change well to a self-hosting user? As you've already flagged, one tool available is documentation, although maintaining a changelog when we don't really do releases/tags is a challenge. Maybe we should be doing releases too 🤔 . Perhaps we could also do something like in the bootstrap process could we check for the existence of private/secret.json and if it exists throw an exception with a message saying "you need to move your config to env vars/yaml"?

Yea, I'm a big fan of failing loudly. That's what's happening here: https://github.com/badges/shields/pull/2626/files#diff-e2e5bd472244fbfb4a40d38300d42534R6

This PR should make it possible for PaaS users to use the shields repo as-is, without forking or checking in any files. If we can solve that for Docker users, even better. Maybe we can publish an official docker image. Regardless, tagging releases probably would be a good idea.

Besides failing loudly and linking to a changelog, I'm not sure we have any other way to communicate this. The changelog will provide this answer going forward, though: it gives a single place to look when you're updating your self-hosted install.

I'd like to provide a second path for self-hosting someday, which is for advanced users who want to do something custom. We could ship an npm package with the server logic. Then the user can create their own project and use shields-server as a dependency. They can add their own services, and maybe even pick and choose which shields services should be enabled. This server package would be an ordinary library, and could follow semver. (Obviously this is not going to be tackled here.)

Copy link
Member

Choose a reason for hiding this comment

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

Yea, I'm a big fan of failing loudly. That's what's happening here: https://github.com/badges/shields/pull/2626/files#diff-e2e5bd472244fbfb4a40d38300d42534R6

oh right yes sorry - you've already done that exact thing and I missed it 🤦‍♂️

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2626 January 4, 2019 22:23 Inactive
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2626 January 5, 2019 07:56 Inactive
calebcartwright
calebcartwright previously approved these changes Jan 5, 2019
Copy link
Member

@calebcartwright calebcartwright left a comment

Choose a reason for hiding this comment

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

There's some changes in here to parts of the ecosystem that I'm admittedly not familiar with (like deployments), but it LGTM and I don't have any additional feedback!

@paulmelnikow
Copy link
Member Author

@chris48s Do you want to have another look at this?

@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2626 January 5, 2019 21:57 Inactive
@chris48s
Copy link
Member

chris48s commented Jan 6, 2019

Looks great. The only outstanding point from me is lets remove the block that references jira_username and jira_password. I think privateConfigSchema is filtering them out anyway now

@paulmelnikow paulmelnikow changed the title PaaS, CI, and production-friendly config; test on [wheelmap] PaaS, CI, and production-friendly config; affects [jira] Jan 6, 2019
@paulmelnikow paulmelnikow temporarily deployed to shields-staging-pr-2626 January 6, 2019 13:25 Inactive
@paulmelnikow
Copy link
Member Author

This pull request introduces 1 alert when merging aa3c0fd into 566b58a - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

Comment posted by LGTM.com

Copy link
Member

@chris48s chris48s left a comment

Choose a reason for hiding this comment

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

👍

@paulmelnikow paulmelnikow merged commit fa53094 into master Jan 6, 2019
@shields-deployment
Copy link

This pull request was merged to master branch. This change is now waiting for deployment, which will usually happen within a few days. Stay tuned by joining our #ops channel on Discord!

After deployment, changes are copied to gh-pages branch:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker PRs and epics which block other work core Server, BaseService, GitHub auth, Shared helpers documentation Developer and end-user documentation operations Hosting, monitoring, and reliability for the production badge servers self-hosting Discussion, problems, features, and documentation related to self-hosting Shields
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants