-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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 the ARM cmdlet to show the progress bar for long running operation #2941
Changes from all commits
e27ca50
ea99bb5
e8d13a2
69728ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -283,7 +283,7 @@ private ResourceManagerRestRestClient GetResourcesClient() | |
/// <param name="result">The operation result</param> | ||
private void UpdateProgress(TrackingOperationResult result) | ||
{ | ||
this.ProgressTrackerObject.UpdateProgress(result); | ||
this.ProgressTrackerObject.UpdateProgress(result, this.IsResourceCreateOrUpdate); | ||
} | ||
|
||
/// <summary> | ||
|
@@ -332,26 +332,43 @@ internal ProgressTracker(string activityName, Func<ResourceManagerRestRestClient | |
this.ProgressRecord = new ProgressRecord(activityId: 0, activity: activityName, statusDescription: "Starting - 0.00% completed."); | ||
} | ||
|
||
internal void SetProgressPercentageAndWriteProgress(double percentage) | ||
{ | ||
this.SetProgressRecordPercentComplete(percentage); | ||
this.WriteProgressAction(this.ProgressRecord); | ||
} | ||
|
||
/// <summary> | ||
/// Logs the fact that the operation has progressed. | ||
/// </summary> | ||
/// <param name="result">The operation result</param> | ||
internal void UpdateProgress(TrackingOperationResult result) | ||
/// <param name="isResourceCreateOrUpdate">Is Create or Update operation, other option include Move etc.</param> | ||
internal void UpdateProgress(TrackingOperationResult result, bool isResourceCreateOrUpdate) | ||
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 would change isResourceCreateOrUpdate to something more generic, like isLongRunning. This is because we need the progress for not just create or update, but for other operations like resource move 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. Currently we have two categories for progress bar - if its Create/Update or everything else, hence IMHO this is sufficient |
||
{ | ||
var currentState = this.GetOperationState(result.OperationResult); | ||
|
||
if (result.Failed || currentState == null || !this.LastState.EqualsInsensitively(currentState)) | ||
if (isResourceCreateOrUpdate) | ||
{ | ||
this.SetProgressRecordPercentComplete(100.0); | ||
this.WriteProgressAction(this.ProgressRecord); | ||
} | ||
var currentState = this.GetOperationState(result.OperationResult); | ||
|
||
if (currentState == null) | ||
if (result.Failed || currentState == null || !this.LastState.EqualsInsensitively(currentState)) | ||
{ | ||
this.SetProgressPercentageAndWriteProgress(100.0); | ||
} | ||
|
||
if (currentState == null) | ||
{ | ||
return; | ||
} | ||
|
||
this.LastState = currentState; | ||
} | ||
else | ||
{ | ||
return; | ||
if(result.Failed) | ||
{ | ||
this.SetProgressPercentageAndWriteProgress(100.0); | ||
} | ||
} | ||
|
||
this.LastState = currentState; | ||
this.SetProgressRecordPercentComplete(result.OperationResult.PercentComplete); | ||
this.WriteProgressAction(this.ProgressRecord); | ||
} | ||
|
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 include ///summary