def get_pods_to_schedule(self, pods): """ given a list of KubePod objects, return a map of (selectors hash -> pods) to be scheduled """ pending_unassigned_pods = [ p for p in pods if p.status == KubePodStatus.PENDING and (not p.node_name) ] # we only consider a pod to be schedulable if it's pending and # unassigned and feasible pods_to_schedule = {} now = datetime.datetime.now(pytz.utc) for pod in pending_unassigned_pods: age = (now - pod.creation_time).total_seconds() self.stats.histogram('autoscaler.scaling_loop.pending_pod_age', age) if capacity.is_possible(pod): pods_to_schedule.setdefault( utils.selectors_to_hash(pod.selectors), []).append(pod) else: recommended_capacity = capacity.max_capacity_for_selectors( pod.selectors, pod.resources) logger.warn( "Pending pod %s cannot fit %s. " "Please check that requested resource amount is " "consistent with node selectors (recommended max: %s). " "Scheduling skipped." % (pod.name, pod.selectors, recommended_capacity)) self.notifier.notify_invalid_pod_capacity( pod, recommended_capacity) return pods_to_schedule
def get_pods_to_schedule(self, pods): """ given a list of KubePod objects, return a map of (selectors hash -> pods) to be scheduled """ pending_unassigned_pods = [ p for p in pods if p.is_pending_unassigned_and_scaleworthy(self.scale_label) ] # we only consider a pod to be schedulable if it's pending and # unassigned and feasible pods_to_schedule = {} for pod in pending_unassigned_pods: if capacity.is_possible(pod): pods_to_schedule.setdefault( utils.selectors_to_hash(pod.selectors), []).append(pod) else: recommended_capacity = capacity.max_capacity_for_selectors( pod.selectors) logger.warn( "Pending pod %s cannot fit %s. " "Please check that requested resource amount is " "consistent with node selectors (recommended max: %s). " "Scheduling skipped." % (pod.name, pod.selectors, recommended_capacity)) self.notifier.notify_invalid_pod_capacity( pod, recommended_capacity) return pods_to_schedule