-
Notifications
You must be signed in to change notification settings - Fork 17
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
Intake | Bug | Use saved withdrawn issue IDs when processing asynchronously #14116
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5f8804c
Use saved withdrawn issue IDs when available
leikkisa efedbcf
Merge branch 'master' into sally/13483-async-withdrawal-bug
leikkisa fc363d1
Add model test
leikkisa 1ea7322
Merge branch 'sally/13483-async-withdrawal-bug' of github.com:departm…
leikkisa 34b99f2
Merge branch 'master' into sally/13483-async-withdrawal-bug
leikkisa c6e9fad
Merge branch 'master' into sally/13483-async-withdrawal-bug
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -566,7 +566,7 @@ def allow_update_contention | |
expect(rating_end_product_establishment.reload.synced_status).to eq(nil) | ||
end | ||
|
||
context "when an issue is withdrawn" do | ||
context "when an issue is withdrawn and there are active tasks" do | ||
let(:request_issues_data) do | ||
[{ request_issue_id: existing_legacy_opt_in_request_issue.id, withdrawal_date: Time.zone.now }] | ||
end | ||
|
@@ -595,28 +595,45 @@ def allow_update_contention | |
end | ||
end | ||
end | ||
end | ||
|
||
context "when create_contentions raises VBMS service error" do | ||
let(:request_issues_data) { request_issues_data_with_new_issue } | ||
context "when remove_contention raises VBMS service error and is re-tried" do | ||
let(:request_issues_data) do | ||
[{ request_issue_id: existing_legacy_opt_in_request_issue.id, withdrawal_date: Time.zone.now }] | ||
end | ||
|
||
it "saves error message and logs error" do | ||
capture_raven_log | ||
raise_error_on_create_contentions | ||
it "saves error message, logs error and removes contention on re-attempt" do | ||
capture_raven_log | ||
raise_error_on_remove_contention | ||
|
||
subject | ||
subject | ||
|
||
expect(request_issues_update.error).to eq(vbms_error.inspect) | ||
expect(@raven_called).to eq(true) | ||
expect(request_issues_update.error).to eq(vbms_error.inspect) | ||
expect(@raven_called).to eq(true) | ||
|
||
withdrawn_issue = request_issues_update.withdrawn_issues.first | ||
|
||
expect(withdrawn_issue).to_not be_nil | ||
expect(withdrawn_issue).to have_attributes( | ||
closed_status: "withdrawn", | ||
closed_at: Time.zone.now, | ||
contention_removed_at: nil | ||
) | ||
|
||
allow_remove_contention | ||
DecisionReviewProcessJob.perform_now(request_issues_update) | ||
|
||
expect(request_issues_update.processed_at).to eq Time.zone.now | ||
expect(withdrawn_issue.reload.contention_removed_at).to eq Time.zone.now | ||
end | ||
end | ||
end | ||
|
||
context "when remove_contention raises VBMS service error" do | ||
let(:request_issues_data) { [{ request_issue_id: existing_request_issue.id }] } | ||
context "when create_contentions raises VBMS service error" do | ||
let(:request_issues_data) { request_issues_data_with_new_issue } | ||
|
||
it "saves error message and logs error" do | ||
capture_raven_log | ||
raise_error_on_remove_contention | ||
raise_error_on_create_contentions | ||
Comment on lines
+631
to
+636
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is GitHub weirdness - this create_contentions test already existed, and there was a similar one for remove_contention that I moved to the withdrawn issues context. |
||
|
||
subject | ||
|
||
|
@@ -681,6 +698,10 @@ def allow_create_contentions | |
def raise_error_on_remove_contention | ||
allow(Fakes::VBMSService).to receive(:remove_contention!).and_raise(vbms_error) | ||
end | ||
|
||
def allow_remove_contention | ||
allow(Fakes::VBMSService).to receive(:remove_contention!).and_call_original | ||
end | ||
end | ||
end | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm satisfied that this PR fixes the bug of RIUs misbehaving when performed asynchronously, but would like to see this code hardened a bit more and made less bug-prone for future engineers who might venture here. Hopefully I can accurately describe my concerns here, although I'm not sure how to address them yet.
The main problem is that
request_issues_data
is being passed here from the RIU, but RIU's@request_issues_data
is an ephemeral attribute set by controllers during HTTP requests, and presumably nil during asynchronous jobs.I see that delegation to RIU's
withdrawn_request_issue_ids
is now being used to determine when not to rely oncalculate_withdrawn_issues
➡️withdrawn_issue_data
➡️request_issues_data
, but passing in an unreliablerequest_issues_data
in the first place feels like the root problem. Consequently, this whole group of methods will be unreliable at job time, yet nothing in the code makes that obvious.Assuming my understanding is correct (lemme know if not!) I'll spend a little more effort thinking about a way to address this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And now, I'm actually wondering if this PR actually handles all edge cases of the bug. If you look at the
call
method, which is the point of entry when actually performing the withdrawal, it refers to not onlywithdrawn_issues
but alsowithdrawn_issue_data
to get a withdrawal date.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @nanotone , the
withdraw!
part isn't failing because it's happening in the Caseflow code. It's kind of hard to see in this PR but the part that's getting retried is inRequestIssuesUpdate.establish!
whereremoved_or_withdrawn_issues
are having their contentions removed in order to consider the RequestIssuesUpdate processed.The RequestIssuesUpdate delegates the withdrawn issues to
RequestIssueWithdrawal
, and when it's attempting that asynchronously later, it's not fetching the withdrawn request issues.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nanotone I started working on the refactor that we discussed, but ran into something that would makes it bigger than I had realized. The refactor would also impact RequestIssueCorrections which is a more complex workflow. So to proceed, I'd need to refactor that one too.
How would you feel if I added a separate refactor ticket instead? I think it would benefit from more eyes on the overall architecture and how the controller is being used.
In the short term... I could update RequestIssueWithdrawal to be closer to RequestIssueCorrection (pass in the withdrawn issue IDs instead of the request issues update).
One potential option for the longer term - we could consider using workflows for all of them, but having those set up to operate strictly on the params, and move things that depend on the issue IDs back over to RequestIssuesUpdate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making a separate ticket sounds good! Don't let the perfect be the enemy of the good, etc etc.
I didn't realize that RIW and RIC were intended to be parallel workflows, with very similar methods. It does seem like this refactor will need a bit more thought.