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

[10-10EZ] Update LogEmailDiffJob to not use redis key #19398

Merged
merged 18 commits into from
Nov 20, 2024

Conversation

coope93
Copy link
Contributor

@coope93 coope93 commented Nov 12, 2024

Summary

  • This work is behind a feature toggle (flipper): YES
  • Refactored the HCA::LogEmailDiffJob to not use a redis key that is never deleted to log if an email address is different between the VA Profile email and the 10-10EZ submission email address. Using a new table to store the user uuid and the in progress form id instead of expecting a redis key to always exist.
  • 10-10 Health Apps
  • Flipper toggle named hca_log_email_diff_in_progress_form.

Related issue(s)

Testing done

  • New code is covered by unit tests
  • Kept the same functionality and logic, just updated where we are using the redis key
  • Turn it on in staging to validate it manually

What areas of the site does it impact?

(Describe what parts of the site are impacted andifcode touched other areas)

Acceptance criteria

  • I fixed|updated|added unit tests and integration tests for each feature (if applicable).
  • No error nor warning in the console.
  • Events are being sent to the appropriate logging solution
  • Documentation has been updated (link to documentation)
  • No sensitive information (i.e. PII/credentials/internal URLs/etc.) is captured in logging, hardcoded, or specs
  • Feature/bug has a monitor built into Datadog (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

(OPTIONAL)What should the reviewers know in addition to the above. Is there anything specific you wish the reviewer to assist with. Do you have any concerns with this PR, why?

Copy link

Error: A file (or its parent directories) was deleted but its reference still exists in CODEOWNERS. Please update the .github/CODEOWNERS file and delete the entry for the Offending file:

Copy link

Error: A file (or its parent directories) does not have a CODEOWNERS entry. Please update the .github/CODEOWNERS file and add the entry for the Offending file:

Copy link

Error: A file (or its parent directories) was deleted but its reference still exists in CODEOWNERS. Please update the .github/CODEOWNERS file and delete the entry for the Offending file:

Copy link

Error: A file (or its parent directories) does not have a CODEOWNERS entry. Please update the .github/CODEOWNERS file and add the entry for the Offending file:

@va-vfs-bot va-vfs-bot temporarily deployed to 94285-refactor-log-email-diff-job/main/main November 12, 2024 22:38 Inactive
@@ -28,5 +36,29 @@ def perform(in_progress_form_id, user_uuid)
)
$redis.set(redis_key, 't')
end

def log_different_email(in_progress_form_id, user_uuid)
return if InProgressEmailMatchLog.exists?(user_uuid:, in_progress_form_id:)
Copy link
Contributor

Choose a reason for hiding this comment

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

would race conditions be a concern in this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so, because of the unique constraint in this PR. If two concurrent jobs both returned true for exists?, one would fail when trying the create since one of them would successfully create the record and the index would throw the exception (which would just kill the job). I think that should handle it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not totally sure the job would be killed since you're using create and not create! but yes, the unique constraint should prevent dupes.

Copy link
Contributor Author

@coope93 coope93 Nov 13, 2024

Choose a reason for hiding this comment

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

Yeah, you're right. Poor wording on my part. The create will fail, and since it's at the end of the job and there are no retries for this job, it wouldn't cause any other issues. But I think we should be okay as far as race conditions, though. I appreciate the call out on it! 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know that we gain anything by the create!? Although I guess if it throws an exception I think we'd have some automatic logging that would catch it, so if we did find we were running into issues with this that could be a way to identify it 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah no biggie, it was good exercise to think through these things though

"api.1010ez.in_progress_form_email.#{tag_text}"
)

InProgressEmailMatchLog.create(user_uuid:, in_progress_form_id:)
Copy link
Contributor

Choose a reason for hiding this comment

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

So this would create a record if the emails are the same and if they are different. The method is called log_different_email but it looks like it creates a record even if it's the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that could probably be clearer. The names for this one are tricky to me. Would log_email_difference make more sense? Open to suggestions on the name 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I don't like to knock names if I don't have a better suggestion but log_email_difference does seem closer to what's happening here

dellerbie
dellerbie previously approved these changes Nov 13, 2024
Copy link
Contributor

@dellerbie dellerbie left a comment

Choose a reason for hiding this comment

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

lgtm , just confirm if you want to use InProgressEmailMatchLog.create! over InProgressEmailMatchLog.create

Copy link

Error: A file (or its parent directories) was deleted but its reference still exists in CODEOWNERS. Please update the .github/CODEOWNERS file and delete the entry for the Offending file:

Copy link

Error: A file (or its parent directories) does not have a CODEOWNERS entry. Please update the .github/CODEOWNERS file and add the entry for the Offending file:

Copy link

Error: A file (or its parent directories) does not have a CODEOWNERS entry. Please update the .github/CODEOWNERS file and add the entry for the Offending file:

def log_email_difference(in_progress_form_id, user_uuid)
return if FormEmailMatchesProfileLog.exists?(user_uuid:, in_progress_form_id:)

in_progress_form = InProgressForm.find_by(id: in_progress_form_id)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kept the same logic as the redis version here. If we do any refactors I plan to do those later just to keep the changes here scope to the database vs redis usage and not the logic in this method.

Copy link
Contributor

@Mitch-A6 Mitch-A6 left a comment

Choose a reason for hiding this comment

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

LGTM. Interesting pattern with the specs - makes it nicely readable!

@RachalCassity RachalCassity self-assigned this Nov 20, 2024
Copy link

Backend-review-group approval confirmed.

@coope93 coope93 merged commit 950ae18 into master Nov 20, 2024
56 of 58 checks passed
@coope93 coope93 deleted the 94285-refactor-log-email-diff-job branch November 20, 2024 19:06
@coope93 coope93 changed the title [10-10CG] Update LogEmailDiffJob to not use redis key [10-10EZ] Update LogEmailDiffJob to not use redis key Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Please Review This PR had changes requested by reviewer AND IS NOW COMPLETE Ready For Review require-backend-approval test-passing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants