Skip to content

Commit 9e77618

Browse files
authored
removing creation time check from LRO (Azure#50769)
1 parent 30d62dc commit 9e77618

File tree

6 files changed

+4
-76
lines changed

6 files changed

+4
-76
lines changed

sdk/batch/Azure.Compute.Batch/src/Custom/LongRunningOperations/DeleteJobOperation.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ public class DeleteJobOperation : Operation<bool>
2828
/// Gets the success of the operation.
2929
/// </summary>
3030
private bool? _value;
31-
private DateTimeOffset _creationTime;
3231
private Response _rawResponse;
3332
private string _jobId;
34-
private bool firstGet = true;
3533

3634
/// <summary>
3735
/// Initializes a new <see cref="DeleteJobOperation"/> instance
@@ -172,19 +170,7 @@ private async Task<Response> UpdateStatusAsync(bool async, CancellationToken can
172170
{
173171
_rawResponse = deleteResponse.GetRawResponse();
174172

175-
// we are going to save the first get responses creation time assuming
176-
// this first get returns the current object
177-
if (firstGet)
178-
{
179-
_creationTime = (DateTimeOffset)deleteResponse.Value.CreationTime;
180-
firstGet = false;
181-
} // need to handle the case where we get back the response from a new object.
182-
else if (deleteResponse.Value.CreationTime != _creationTime)
183-
{
184-
_value = true;
185-
_hasCompleted = true;
186-
}
187-
else if (deleteResponse.Value.State != BatchJobState.Deleting)
173+
if (deleteResponse.Value.State != BatchJobState.Deleting)
188174
{
189175
_value = true;
190176
_hasCompleted = true;

sdk/batch/Azure.Compute.Batch/src/Custom/LongRunningOperations/DeleteJobScheduleOperation.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ public class DeleteJobScheduleOperation : Operation<bool>
2828
/// Gets the success of the operation.
2929
/// </summary>
3030
private bool? _value;
31-
private DateTimeOffset _creationTime;
3231
private Response _rawResponse;
3332
private string _jobScheduleId;
34-
private bool firstGet = true;
3533

3634
/// <summary>
3735
/// Initializes a new <see cref="DeleteJobScheduleOperation"/> instance
@@ -173,19 +171,7 @@ private async Task<Response> UpdateStatusAsync(bool async, CancellationToken can
173171
{
174172
_rawResponse = deleteResponse.GetRawResponse();
175173

176-
// we are going to save the first get responses creation time assuming
177-
// this first get returns the current object
178-
if (firstGet)
179-
{
180-
_creationTime = (DateTimeOffset)deleteResponse.Value.CreationTime;
181-
firstGet = false;
182-
} // need to handle the case where we get back the response from a new object.
183-
else if (deleteResponse.Value.CreationTime != _creationTime)
184-
{
185-
_value = true;
186-
_hasCompleted = true;
187-
}
188-
else if (deleteResponse.Value.State != BatchJobScheduleState.Deleting)
174+
if (deleteResponse.Value.State != BatchJobScheduleState.Deleting)
189175
{
190176
_value = true;
191177
_hasCompleted = true;

sdk/batch/Azure.Compute.Batch/src/Custom/LongRunningOperations/DeletePoolOperation.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ public class DeletePoolOperation : Operation<bool>
2828
/// Gets the success of the operation.
2929
/// </summary>
3030
private bool? _value;
31-
private DateTimeOffset _creationTime;
3231
private Response _rawResponse;
3332
private string _poolId;
34-
private bool firstGet = true;
3533

3634
/// <summary>
3735
/// Initializes a new <see cref="DeletePoolOperation"/> instance
@@ -173,19 +171,7 @@ private async Task<Response> UpdateStatusAsync(bool async, CancellationToken can
173171
{
174172
_rawResponse = deleteResponse.GetRawResponse();
175173

176-
// we are going to save the first get responses creation time assuming
177-
// this first get returns the current object
178-
if (firstGet)
179-
{
180-
_creationTime = (DateTimeOffset)deleteResponse.Value.CreationTime;
181-
firstGet = false;
182-
} // need to handle the case where we get back the response from a new object.
183-
else if (deleteResponse.Value.CreationTime != _creationTime)
184-
{
185-
_value = true;
186-
_hasCompleted = true;
187-
}
188-
else if (deleteResponse.Value.State != BatchPoolState.Deleting)
174+
if (deleteResponse.Value.State != BatchPoolState.Deleting)
189175
{
190176
_value = true;
191177
_hasCompleted = true;

sdk/batch/Azure.Compute.Batch/src/Custom/LongRunningOperations/TerminateJobOperation.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ public class TerminateJobOperation : Operation<bool>
3030
private bool? _value;
3131
private Response _rawResponse;
3232
private string _jobId;
33-
private DateTimeOffset _creationTime;
34-
private bool firstGet = true;
3533

3634
/// <summary>
3735
/// Initializes a new <see cref="TerminateJobOperation"/> instance
@@ -174,19 +172,6 @@ private async Task<Response> UpdateStatusAsync(bool async, CancellationToken can
174172
{
175173
_rawResponse = response.GetRawResponse();
176174

177-
// we are going to save the first get responses creation time assuming
178-
// this first get returns the current object
179-
if (firstGet)
180-
{
181-
_creationTime = (DateTimeOffset)response.Value.CreationTime;
182-
firstGet = false;
183-
} // need to handle the case where we get back the response from a new object.
184-
else if (response.Value.CreationTime != _creationTime)
185-
{
186-
_value = true;
187-
_hasCompleted = true;
188-
}
189-
190175
if ( response.Value.State != BatchJobState.Terminating)
191176
{
192177
_value = true;

sdk/batch/Azure.Compute.Batch/src/Custom/LongRunningOperations/TerminateJobScheduleOperation.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ public class TerminateJobScheduleOperation : Operation<bool>
2929
/// </summary>
3030
private bool? _value;
3131
private Response _rawResponse;
32-
private DateTimeOffset _creationTime;
3332
private string _jobScheduleId;
34-
private bool firstGet = true;
3533

3634
/// <summary>
3735
/// Initializes a new <see cref="TerminateJobScheduleOperation"/> instance
@@ -174,19 +172,6 @@ private async Task<Response> UpdateStatusAsync(bool async, CancellationToken can
174172
{
175173
_rawResponse = response.GetRawResponse();
176174

177-
// we are going to save the first get responses creation time assuming
178-
// this first get returns the current object
179-
if (firstGet)
180-
{
181-
_creationTime = (DateTimeOffset)response.Value.CreationTime;
182-
firstGet = false;
183-
} // need to handle the case where we get back the response from a new object.
184-
else if (response.Value.CreationTime != _creationTime)
185-
{
186-
_value = true;
187-
_hasCompleted = true;
188-
}
189-
190175
if (response.Value.State != BatchJobScheduleState.Terminating)
191176
{
192177
_value = true;

sdk/batch/Azure.Compute.Batch/tests/UnitTests/LongRunningOperationsUnitTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ public async Task TerminateJobScheduleOperation_NewJobSchedule()
527527
int CallsToGet = 0;
528528

529529
BatchJobSchedule batchJobScheduleTerminating = new BatchJobSchedule(JobId, null, null, null, null, DateTimeOffset.UtcNow, BatchJobScheduleState.Terminating, null, null, null, null, null, null, null, null, null);
530-
BatchJobSchedule batchJobScheduleActive = new BatchJobSchedule(JobId, null, null, null, null, DateTimeOffset.UtcNow.AddHours(1), BatchJobScheduleState.Terminating, null, null, null, null, null, null, null, null, null);
530+
BatchJobSchedule batchJobScheduleActive = new BatchJobSchedule(JobId, null, null, null, null, DateTimeOffset.UtcNow.AddHours(1), BatchJobScheduleState.Active, null, null, null, null, null, null, null, null, null);
531531

532532
Mock<BatchClient> clientMock = new Mock<BatchClient>();
533533
clientMock.Setup(c => c.GetJobScheduleAsync(

0 commit comments

Comments
 (0)