Skip to content

Commit 282e87b

Browse files
committed
Add check to fail when job being stopped is not a running cancellable one
1 parent aee4f17 commit 282e87b

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/DeviceJobs/StopAzureStorSimpleJob.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ public override void ExecuteCmdlet()
6262
return;
6363
}
6464

65+
// Make sure the job is running and cancellable, else fail.
66+
if (!(deviceJobDetails.IsJobCancellable && deviceJobDetails.Status == "Running"))
67+
{
68+
WriteVerbose(string.Format(Resources.JobNotRunningOrCancellable, InstanceId));
69+
WriteObject(null);
70+
return;
71+
}
72+
6573
// issue call to cancel the job.
6674
WriteVerbose(string.Format(Resources.StoppingDeviceJob,InstanceId));
6775
var taskStatusInfo = StorSimpleClient.StopDeviceJob(deviceJobDetails.Device.InstanceId, InstanceId);

src/ServiceManagement/StorSimple/Commands.StorSimple/Properties/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ServiceManagement/StorSimple/Commands.StorSimple/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,4 +504,7 @@
504504
<data name="DeviceFailoverSourceAndTargetDeviceSameError" xml:space="preserve">
505505
<value>Source and Target device in a failover operation can not be the same.</value>
506506
</data>
507+
<data name="JobNotRunningOrCancellable" xml:space="preserve">
508+
<value>Cannot stop job with id {0}. It is not a running cancellable job.</value>
509+
</data>
507510
</root>

0 commit comments

Comments
 (0)