Esempio n. 1
0
 public static V1Pod CreatePodInPhaseWithContainerStatus(string podPhase, V1ContainerState containerState)
 => new V1Pod
 {
     Metadata = new V1ObjectMeta
     {
         Name   = "module-a-abc123",
         Labels = new Dictionary <string, string>
         {
             [KubernetesConstants.K8sEdgeModuleLabel] = "module-a"
         },
         Annotations = new Dictionary <string, string>
         {
             [KubernetesConstants.K8sEdgeOriginalModuleId] = "Module-A"
         }
     },
     Status = new V1PodStatus
     {
         Phase             = podPhase,
         ContainerStatuses = new List <V1ContainerStatus>()
         {
             new V1ContainerStatus
             {
                 Name  = "module-a",
                 State = containerState,
             }
         }
     }
 };
Esempio n. 2
0
        /// <summary>
        /// Get the state of the given worker pod. Can throw but will never return null.
        /// </summary>
        /// <param name="podName">Name of the pod.</param>
        private V1ContainerState GetPodState(string podName)
        {
            V1Pod            pod       = GetWorkerPod(podName);
            string           container = GetContainerName(podName);
            V1ContainerState state     = pod.Status.ContainerStatuses.FirstOrDefault(c => c.Name == container)?.State;

            if (state == null)
            {
                throw new Exception($"Unable to read state of pod {podName} - pod has no container state for the {container} container");
            }
            return(state);
        }