예제 #1
0
 def _generate_pod(name, labels, phase=PodPhases.succeeded):
     terminated_container_state = client.V1ContainerStateTerminated(
         finished_at=datetime.now(timezone.utc), exit_code=0
     )
     container_state = client.V1ContainerState(terminated=terminated_container_state)
     container_status = client.V1ContainerStatus(
         state=container_state,
         image="must/provide:image",
         image_id="must-provide-image-id",
         name="must-provide-name",
         ready=True,
         restart_count=0,
     )
     status = client.V1PodStatus(phase=phase, container_statuses=[container_status])
     metadata = client.V1ObjectMeta(
         name=name, labels=labels, namespace=get_k8s().resolve_namespace()
     )
     pod = client.V1Pod(metadata=metadata, status=status)
     return pod
예제 #2
0
파일: base.py 프로젝트: AlonMaor14/mlrun
 def _generate_pod(namespace, pod):
     terminated_container_state = client.V1ContainerStateTerminated(
         finished_at=datetime.now(timezone.utc), exit_code=0)
     container_state = client.V1ContainerState(
         terminated=terminated_container_state)
     container_status = client.V1ContainerStatus(
         state=container_state,
         image=self.image_name,
         image_id="must-provide-image-id",
         name=self.name,
         ready=True,
         restart_count=0,
     )
     status = client.V1PodStatus(phase=PodPhases.succeeded,
                                 container_statuses=[container_status])
     response_pod = deepcopy(pod)
     response_pod.status = status
     response_pod.metadata.name = "test-pod"
     response_pod.metadata.namespace = namespace
     return response_pod
예제 #3
0
 def list_namespaced_pod(self, namespace, label_selector):
     print(namespace)
     if label_selector not in MockCoreV1ApiForTTL.pod_map.keys():
         return client.V1PodList(items=[])
     else:
         pods = client.V1PodList(
             items=MockCoreV1ApiForTTL.pod_map[label_selector].copy())
         if pods.items:
             pods.items[0].status.container_statuses = [
                 client.V1ContainerStatus(
                     state=client.V1ContainerStateTerminated(exit_code=0),
                     image='aaa',
                     image_id='aaa',
                     name='name',
                     container_id='id',
                     ready=True,
                     restart_count=0)
             ]
         print("Sending {} pods".format(len(pods.items)))
         return pods