Skip to content

[LG-1488] Move account reset notice into job_configurations.#3062

Merged
brodygov merged 3 commits intomasterfrom
brody/account-reset-job
Jul 2, 2019
Merged

[LG-1488] Move account reset notice into job_configurations.#3062
brodygov merged 3 commits intomasterfrom
brody/account-reset-job

Conversation

@brodygov
Copy link
Contributor

@brodygov brodygov commented Jul 1, 2019

As part of LG-1488 / LG-1113, move the account reset email notification job out of
the recurring job controllers and into the built-in app job
configurations.

Also add timestamps to the default development.log/production.log
output. Previously this log had no timestamps, which made it extremely
difficult to follow time-sensitive logs.

Why: We are moving away from triggering recurring jobs via lambdas
to instead run long-running background jobs using the
idp-jobs/job_configurations.rb framework, which allows each idp server
to pull jobs and run them as needed, without any external moving parts.

This makes adding a new recurring job entirely self-contained within the
identity-idp repo, so no interaction with AWS or lambdas or terraform or
any other repos is needed.

How:

  • Remove lib/lambdas/account_reset_lambda.rb.
  • Add a new job configuration for the account reset email job to
    config/initializers/job_configurations.rb, running every 5 minutes.
  • Change the deprecated account reset controller to return HTTP 410, to
    indicate that the endpoint should not be used.
  • Add tests of all the job_configurations.rb and fix tests for the
    changes.
  • Add two new log formatter classes, and set them as the Rails.config.log_formatter.

@brodygov brodygov requested review from achapm and jmhooper July 2, 2019 15:39
@brodygov brodygov changed the title Move account reset notice into job_configurations. [LG-1488] Move account reset notice into job_configurations. Jul 2, 2019
@brodygov brodygov force-pushed the brody/account-reset-job branch from 5a25553 to 8e799a9 Compare July 2, 2019 19:38
brodygov added 3 commits July 2, 2019 15:38
As part of LG-1113, move the account reset email notification job out of
the recurring job controllers and into the built-in app job
configurations.

**Why**: We are moving away from triggering recurring jobs via lambdas
to instead run long-running background jobs using the
idp-jobs/job_configurations.rb framework, which allows each idp server
to pull jobs and run them as needed, without any external moving parts.

This makes adding a new recurring job entirely self-contained within the
identity-idp repo, so no interaction with AWS or lambdas or terraform or
any other repos is needed.

**How**:
- Remove lib/lambdas/account_reset_lambda.rb.
- Add a new job configuration for the account reset email job to
  `config/initializers/job_configurations.rb`, running every 5 minutes.
- Change the deprecated account reset controller to return HTTP 410, to
  indicate that the endpoint should not be used.
- Add tests of all the job_configurations.rb and fix tests for the
  changes.
**Why**: We currently output logs to a file. We have no idea when these
events happen unless we add a timestamp.

**How**: Create a custom log formatter class that overrides the default
activesupport formatter. Check if the input appears to be JSON based on
leading/trailing `{}`, and output without any timestamp if so. That
preserves log parsing compatibility with the existing analytics ETL
pipelines.
@brodygov
Copy link
Contributor Author

brodygov commented Jul 2, 2019

I tested this in my personal environment. Account reset notifications started flowing as expected.

The jobs are showing up beautifully in New Relic.
Screen Shot 2019-07-02 at 3 40 20 PM

Health checks also appear to work as expected.

$ curl -sS https://idp.brody.identitysandbox.gov/api/health | jq
{
  "statuses": {
    "database": {
      "healthy": true,
      "result": [
        1
      ]
    },
    "account_reset": {
      "healthy": true,
      "result": null
    },
    "job_runner": {
      "healthy": true,
      "result": {
        "Send GPO letter": true,
        "Account reset notice": true
      }
    }
  },
  "healthy": true,
  "all_checks_healthy": true
}

Copy link
Contributor

@achapm achapm left a comment

Choose a reason for hiding this comment

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

assuming that we are OK to launch this without analytics, 👍 LGTM

@brodygov brodygov merged commit 1e761b9 into master Jul 2, 2019
@brodygov brodygov deleted the brody/account-reset-job branch July 2, 2019 20:59
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.

2 participants