Ejemplo n.º 1
0
 def _get_agent_metadata(self, node_ip: str) -> AgentMetadata:
     node = self._nodes_by_ip.get(node_ip)
     if not node:
         return AgentMetadata(state=AgentState.ORPHANED)
     return AgentMetadata(
         agent_id=node.metadata.name,
         allocated_resources=allocated_node_resources(
             self._pods_by_ip[node_ip]),
         batch_task_count=self._count_batch_tasks(node_ip),
         state=(AgentState.RUNNING
                if self._pods_by_ip[node_ip] else AgentState.IDLE),
         task_count=len(self._pods_by_ip[node_ip]),
         total_resources=total_node_resources(node),
     )
    def _get_pod_unschedulable_reason(
            self, pod: KubernetesPod) -> PodUnschedulableReason:
        pod_resource_request = total_pod_resources(pod)
        for node_ip, pods_on_node in self._pods_by_ip.items():
            node = self._nodes_by_ip.get(node_ip)
            if node:
                available_node_resources = (
                    total_node_resources(
                        node, self._excluded_pods_by_ip.get(node_ip, [])) -
                    allocated_node_resources(pods_on_node))
                if pod_resource_request < available_node_resources:
                    return PodUnschedulableReason.Unknown

        return PodUnschedulableReason.InsufficientResources
Ejemplo n.º 3
0
 def get_resource_allocation(self, resource_name: str) -> float:
     return sum(
         getattr(allocated_node_resources(self._pods_by_ip[node_ip]),
                 resource_name)
         for node_ip, node in self._nodes_by_ip.items())
 def get_resource_allocation(self, resource_name: str) -> float:
     return sum(
         getattr(allocated_node_resources(pod), resource_name)
         for pod in self._pods_by_ip.values())
 def get_resource_pending(self, resource_name: str) -> float:
     return getattr(
         allocated_node_resources(
             [p for p, __ in self.get_unschedulable_pods()]), resource_name)
 def get_resource_excluded(self, resource_name: str) -> float:
     return sum(
         getattr(
             allocated_node_resources(
                 self._excluded_pods_by_ip.get(node_ip, [])), resource_name)
         for node_ip in self._nodes_by_ip.keys())