@@ -1312,21 +1312,21 @@ module ContainerInstances =
13121312        g.State =  ContainerGroupStates.Stopped
13131313
13141314    let  isJobProvisioningFailed   ( g : IContainerGroup )  = 
1315-         g.State  =  ContainerGroupStates.Failed  ||  g. ProvisioningState =  ContainerGroupStates.Failed
1315+         g.ProvisioningState =  ContainerGroupStates.Failed
13161316
13171317    let  stopJob   ( containerGroup  :  IContainerGroup )  = 
13181318        async  { 
13191319            if  not  ( isJobManuallyStopped containerGroup ||  isJobProvisioningFailed containerGroup)  then 
13201320                do !  containerGroup.StopAsync() .ToAsync
13211321        } 
13221322
1323- 
13241323    /// Get a sequence of containers that terminated due to error 
13251324let  getContainersExitedWithError   ( g :  IContainerGroup )  = 
13261325        g.Containers |>  Seq.filter( fun   ( KeyValue ( _ ,  v ))  -> 
13271326            if  not  <|  isNull v.InstanceView then 
13281327                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 )) 
13301330            else  false ) 
13311331        |>  Seq.map ( fun   ( KeyValue ( _ ,  v ))  -> ) 
13321332
@@ -1635,6 +1635,7 @@ module ContainerInstances =
16351635                            // if stopped it cannot be expired 
16361636                            false 
16371637                        else  if  isJobExpired logger containerGroup then 
1638+                             logInfo " Job Expired : %s " 
16381639                            true 
16391640                        else 
16401641                            false 
@@ -1657,6 +1658,7 @@ module ContainerInstances =
16571658
16581659                        let  state ,  details  = 
16591660                            if  containerGroupFailedToProvision then 
1661+                                 logInfo " Container group failed to provision : %s " 
16601662                                JobState.Error,  
16611663                                    ( Map.empty,  containerGroup.Events |>  List.ofSeq) 
16621664                                    ||>  List.fold(  fun  details v  -> 
@@ -1666,12 +1668,15 @@ module ContainerInstances =
16661668                                            .Add( " Type" ,  v.Type) 
16671669                                    ) 
16681670                            else  if  isExpired then 
1671+                                 logInfo " Job Expired : %s " 
16691672                                JobState.TimedOut,  Map.empty
16701673                            else  if  jobManuallyStopped then 
1674+                                 logInfo " Job Manually stopped : %s " 
16711675                                JobState.ManuallyStopped,  Map.empty
16721676                            else  if  Seq.isEmpty instancesExitedWithError then 
16731677                                JobState.Completed,  Map.empty
16741678                            else 
1679+                                 logInfo " At least one instance exited with an error : %s " 
16751680                                //There is at least one container that terminated with an error 
16761681                                JobState.Error,  
16771682                                    ( Map.empty,  instancesExitedWithError |>  List.ofSeq) 
@@ -1692,7 +1697,7 @@ module ContainerInstances =
16921697                        for  v in  instancesExitedWithError do 
16931698                            let!  failedContainerLogs  =  containerGroup.GetLogContentAsync( v.Name) .ToAsync
16941699
1695-                             logInfo " [%s %s %A %A %A %s \n Events: %A " 
1700+                             logInfo " Instance Exited with Error:  [%s %s %A %A %A %s \n Events: %A " 
16961701                                        containerGroup.Name v.Name 
16971702                                        v.InstanceView.CurrentState.State
16981703                                        v.InstanceView.CurrentState.DetailStatus 
0 commit comments