@@ -1312,21 +1312,21 @@ module ContainerInstances =
1312
1312
g.State = ContainerGroupStates.Stopped
1313
1313
1314
1314
let isJobProvisioningFailed ( g : IContainerGroup ) =
1315
- g.State = ContainerGroupStates.Failed || g. ProvisioningState = ContainerGroupStates.Failed
1315
+ g.ProvisioningState = ContainerGroupStates.Failed
1316
1316
1317
1317
let stopJob ( containerGroup : IContainerGroup ) =
1318
1318
async {
1319
1319
if not ( isJobManuallyStopped containerGroup || isJobProvisioningFailed containerGroup) then
1320
1320
do ! containerGroup.StopAsync() .ToAsync
1321
1321
}
1322
1322
1323
-
1324
1323
/// Get a sequence of containers that terminated due to error
1325
1324
let getContainersExitedWithError ( g : IContainerGroup ) =
1326
1325
g.Containers |> Seq.filter( fun ( KeyValue ( _ , v )) ->
1327
1326
if not <| isNull v.InstanceView then
1328
1327
let currentState = v.InstanceView.CurrentState
1329
- currentState.DetailStatus = ContainerInstancesStates.Error
1328
+ currentState.DetailStatus = ContainerInstancesStates.Error ||
1329
+ ( currentState.State = ContainerInstancesStates.Terminated && currentState.ExitCode <> Nullable< int>( 0 ))
1330
1330
else false )
1331
1331
|> Seq.map ( fun ( KeyValue ( _ , v )) -> v)
1332
1332
@@ -1635,6 +1635,7 @@ module ContainerInstances =
1635
1635
// if stopped it cannot be expired
1636
1636
false
1637
1637
else if isJobExpired logger containerGroup then
1638
+ logInfo " Job Expired : %s " containerGroupName
1638
1639
true
1639
1640
else
1640
1641
false
@@ -1657,6 +1658,7 @@ module ContainerInstances =
1657
1658
1658
1659
let state , details =
1659
1660
if containerGroupFailedToProvision then
1661
+ logInfo " Container group failed to provision : %s " containerGroupName
1660
1662
JobState.Error,
1661
1663
( Map.empty, containerGroup.Events |> List.ofSeq)
1662
1664
||> List.fold( fun details v ->
@@ -1666,12 +1668,15 @@ module ContainerInstances =
1666
1668
.Add( " Type" , v.Type)
1667
1669
)
1668
1670
else if isExpired then
1671
+ logInfo " Job Expired : %s " containerGroupName
1669
1672
JobState.TimedOut, Map.empty
1670
1673
else if jobManuallyStopped then
1674
+ logInfo " Job Manually stopped : %s " containerGroupName
1671
1675
JobState.ManuallyStopped, Map.empty
1672
1676
else if Seq.isEmpty instancesExitedWithError then
1673
1677
JobState.Completed, Map.empty
1674
1678
else
1679
+ logInfo " At least one instance exited with an error : %s " containerGroupName
1675
1680
//There is at least one container that terminated with an error
1676
1681
JobState.Error,
1677
1682
( Map.empty, instancesExitedWithError |> List.ofSeq)
@@ -1692,7 +1697,7 @@ module ContainerInstances =
1692
1697
for v in instancesExitedWithError do
1693
1698
let! failedContainerLogs = containerGroup.GetLogContentAsync( v.Name) .ToAsync
1694
1699
1695
- logInfo " [%s ][%s ][State:%A ][DetailStatus: %A ][ExitCode: %A ] failed logs: %s \n Events: %A "
1700
+ logInfo " Instance Exited with Error: [%s ][%s ][State:%A ][DetailStatus: %A ][ExitCode: %A ] failed logs: %s \n Events: %A "
1696
1701
containerGroup.Name v.Name
1697
1702
v.InstanceView.CurrentState.State
1698
1703
v.InstanceView.CurrentState.DetailStatus
0 commit comments