-
Notifications
You must be signed in to change notification settings - Fork 518
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
Fix Cancel Import Request #4702
Conversation
test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Import/ImportTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Health.Fhir.Core/Features/Operations/Import/CancelImportRequestHandler.cs
Show resolved
Hide resolved
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.
/azp run
@@ -66,14 +66,26 @@ public async Task GivenAFhirMediator_WhenCancelingExistingBulkImportJobThatHasAl | |||
Assert.Equal(HttpStatusCode.Conflict, operationFailedException.ResponseStatusCode); | |||
} | |||
|
|||
[Theory] | |||
[InlineData(JobStatus.Cancelled)] | |||
public async Task GivenAFhirMediator_WhenCancelingExistingBulkImportJobThatHasAlreadyBeenCanceled_ThenAcceptedStatusCodeShouldBeReturned(JobStatus taskStatus) |
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.
This is new behavior, because if a tastk has been already canceled, then we will return accepted because we will continue trying to cancel.
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.
A change in behavior may require giving customers 1 month notice before deploying to prod. We should check w./ PM team
{ | ||
throw new ResourceNotFoundException(string.Format(Core.Resources.ImportJobNotFound, request.JobId)); | ||
} | ||
|
||
if (jobInfo.Status == JobManagement.JobStatus.Completed || jobInfo.Status == JobManagement.JobStatus.Cancelled || jobInfo.Status == JobManagement.JobStatus.Failed) |
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.
Please check that now we are not returning CONFLICT if the job has been already cancelled.
Now, if the job has been already cancelled, we will retry cancel, so we will return ACCEPTED, as Sergey suggested.
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.
just need to check w/ PM on behavior change
...oft.Health.Fhir.Core.UnitTests/Features/Operations/Import/CancelImportRequestHandlerTests.cs
Fixed
Show fixed
Hide fixed
I don't think jobs == null condition needs to be checked. |
I think it would be easier to use Linq instead of foreach. |
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.
approved with some suggestions
@@ -66,14 +66,26 @@ public async Task GivenAFhirMediator_WhenCancelingExistingBulkImportJobThatHasAl | |||
Assert.Equal(HttpStatusCode.Conflict, operationFailedException.ResponseStatusCode); | |||
} | |||
|
|||
[Theory] | |||
[InlineData(JobStatus.Cancelled)] | |||
public async Task GivenAFhirMediator_WhenCancelingExistingBulkImportJobThatHasAlreadyBeenCanceled_ThenAcceptedStatusCodeShouldBeReturned(JobStatus taskStatus) |
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.
A change in behavior may require giving customers 1 month notice before deploying to prod. We should check w./ PM team
{ | ||
throw new ResourceNotFoundException(string.Format(Core.Resources.ImportJobNotFound, request.JobId)); | ||
} | ||
|
||
if (jobInfo.Status == JobManagement.JobStatus.Completed || jobInfo.Status == JobManagement.JobStatus.Cancelled || jobInfo.Status == JobManagement.JobStatus.Failed) |
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.
just need to check w/ PM on behavior change
Uri checkLocation = await ImportTestHelper.CreateImportTaskAsync(_client, request); | ||
|
||
// Wait for import job to complete | ||
await Task.Delay(TimeSpan.FromSeconds(10)); |
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 worry this could create a flake test in the future.
Could we check the status of the import before moving forward in the test?
We could even loop and wait again if it's not complete (up to 5 times or so).
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.
Great idea!
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.
/azp run
Uri checkLocation = await ImportTestHelper.CreateImportTaskAsync(_client, request); | ||
|
||
// Wait for import job to complete | ||
await Task.Delay(TimeSpan.FromSeconds(10)); |
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.
Great idea!
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
b3b105e
to
e07748b
Compare
Description
Currently, the Orchestrator job completes before the processing jobs are completed, it will incorrectly not allow cancel of an import because it thinks the job is done. This is incorrect as the Orchestrator is done but not the child Processing Jobs,.
This PR is fixing this issue, now we check all jobs to check the status of all jobs.
Related issues
Addresses issue #124093
Testing
Added a test to make sure it first returns Accepted status to cancel request, which means the import job has been cancelled, and then make sure we received Conflict status if we have already cancelled the job.
The existing test was making sure that the cancel operation works if all jobs have already completed (with just one patient) it was happening.
FHIR Team Checklist
Semver Change (docs)
Patch|Skip|Feature|Breaking (reason)