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

4619 sis workers #11663

Merged
merged 0 commits into from
Feb 2, 2023
Merged

4619 sis workers #11663

merged 0 commits into from
Feb 2, 2023

Conversation

kpethtel
Copy link
Contributor

Summary

When we added SIS login, we didn't notice that our background jobs has logic for looking up IAM users. This has been causing background workers to fail for SIS users but the issue wasn't obvious because:

  • our background jobs are very low impact. Two of them are entirely for performance improvements and the third applies to a very small number of users and probably isn't necessary for functionality.
  • one of the jobs is turned off in production. We should consider turning it back on after this is fixed.
  • one of the jobs only logs on failure and doesn't raise errors

As a result, the only error found in sentry (which led us to this bug) is this one that was only occurring in staging:
http://sentry.vfs.va.gov/organizations/vsp/issues/176633/?project=3&query=is%3Aunresolved+mobile&statsPeriod=14d

Related issue(s)

  • department-of-veterans-affairs/va-mobile-team#4619

Testing done

Specs

What areas of the site does it impact?

Mobile background jobs

Acceptance criteria

  • [ x ] I fixed|updated|added unit tests and integration tests for each feature (if applicable).
  • [ x ] No error nor warning in the console.
  • [ x ] Events are being sent to the appropriate logging solution
  • Documentation has been updated (link to documentation)
  • [ x ] No sensitive information (i.e. PII/credentials/internal URLs/etc.) is captured in logging, hardcoded, or specs
  • [ x ] Feature/bug has a monitor built into Datadog or Grafana (if applicable)
  • If app impacted requires authentication, did you login to a local build and verify all authenticated routes work as expected
  • I added a screenshot of the developed feature

Requested Feedback

Any and all.

@kpethtel kpethtel requested review from a team as code owners January 27, 2023 18:33
@github-actions
Copy link

github-actions bot commented Jan 27, 2023

1 Warning
⚠️ This PR changes 312 LoC (not counting whitespace/newlines).

In order to ensure each PR receives the proper attention it deserves, we recommend not exceeding
200. Expect some delays getting reviews.

File Summary

Files

  • modules/mobile/app/workers/mobile/v0/pre_cache_appointments_job.rb (+6/-2)

  • modules/mobile/app/workers/mobile/v0/pre_cache_claims_and_appeals_job.rb (+5/-1)

  • modules/mobile/app/workers/mobile/v0/vet360_linking_job.rb (+5/-1)

  • modules/mobile/spec/workers/pre_cache_appointments_job_spec.rb (+33/-152)

  • modules/mobile/spec/workers/pre_cache_claims_and_appeals_job_spec.rb (+36/-21)

  • modules/mobile/spec/workers/vet360_linking_spec.rb (+39/-11)

    Note: We exclude files matching the following when considering PR size:

    *.csv, *.json, *.tsv, *.txt, Gemfile.lock, app/swagger, modules/mobile/docs, spec/fixtures/, spec/support/vcr_cassettes/, modules/mobile/spec/support/vcr_cassettes/, db/seeds, modules/vaos/app/docs, modules/meb_api/app/docs, modules/appeals_api/app/swagger/
    

Big PRs are difficult to review, often become stale, and cause delays.

Generated by 🚫 Danger

@va-vfs-bot va-vfs-bot temporarily deployed to 4619-sis-workers/main/main January 27, 2023 18:34 Inactive
@@ -4,11 +4,11 @@
require_relative '../support/iam_session_helper'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The changes I made to these specs are difficult to read in the diff. I decided to remove some of the tests because I didn't think they were adding anything except complexity that made these tests needlessly difficult to refactor. They were testing feature flag and other appointment behaviors that are already tested in the appointments list request specs. I'm sure I added some of these tests myself, but at this time I'd rather keep them simple and do the more thorough testing in the integration (request) specs. It may be easier to read these specs by just looking at the file since the diff is so complex.

@@ -18,8 +18,6 @@

after(:all) { VCR.configure { |c| c.cassette_library_dir = @original_cassette_dir } }

let(:user) { FactoryBot.build(:iam_user) }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In all of these tests, I've switched to using User instead of IAMUser as the base case because 1) it's simpler to set up 2) it's the way of the future. So I've done most of the testing with User and also confirmed that it works with IAMUser.

@@ -7,15 +7,19 @@ class PreCacheAppointmentsJob

sidekiq_options(retry: false)

class MissingUserError < StandardError; end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding these error classes because I want to see it in sentry if this is happening and at least one of these jobs effectively hides the error from us. We can probably remove this if we find that it never occurs.

Copy link
Contributor

Choose a reason for hiding this comment

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

If that works, that'd be a great way to fight the noise that Sentry puts out.

Mobile::AppointmentsCacheInterface.new.fetch_appointments(user: user, fetch_cache: false)

Rails.logger.warn('mobile appointments pre-cache success', user_uuid: uuid)
Rails.logger.info('mobile appointments pre-cache success', user_uuid: uuid)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

IDK why we use info at the start of the job then warn that it succeeded.

aherzberg
aherzberg previously approved these changes Feb 2, 2023
Copy link
Contributor

@aherzberg aherzberg left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -7,15 +7,19 @@ class PreCacheAppointmentsJob

sidekiq_options(retry: false)

class MissingUserError < StandardError; end
Copy link
Contributor

Choose a reason for hiding this comment

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

If that works, that'd be a great way to fight the noise that Sentry puts out.

it 'caches the expected appointments' do
VCR.use_cassette('appointments/get_facilities', match_requests_on: %i[method uri]) do
VCR.use_cassette('appointments/get_cc_appointments_default', match_requests_on: %i[method uri]) do
VCR.use_cassette('appointments/get_appointments_default', match_requests_on: %i[method uri]) do
Copy link
Contributor

Choose a reason for hiding this comment

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

some of these specs are still using v0 appointments. In the current draft PR for ripping out v0 appointments, we're removing all v0 specs with future tickets to make v2 versions of them. so these will be removed soon. Could change them to v2 now while your working with them or do it later.

Copy link
Contributor

@aherzberg aherzberg left a comment

Choose a reason for hiding this comment

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

LGTM

@kpethtel kpethtel merged commit ae2da88 into master Feb 2, 2023
@kpethtel kpethtel deleted the 4619-sis-workers branch February 2, 2023 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants