Exemplo n.º 1
0
// filterPodsMatchingReplicaSets filters the given pod list and only return the ones targeted by the input replicasets
func filterPodsMatchingReplicaSets(replicaSets []*extensions.ReplicaSet, podList *api.PodList, minReadySeconds int32) ([]api.Pod, error) {
	allRSPods := []api.Pod{}
	for _, rs := range replicaSets {
		matchingFunc, err := rsutil.MatchingPodsFunc(rs)
		if err != nil {
			return nil, err
		}
		if matchingFunc == nil {
			continue
		}
		rsPods := podutil.Filter(podList, matchingFunc)
		avaPodsCount := countAvailablePods(rsPods, minReadySeconds)
		if avaPodsCount > rs.Spec.Replicas {
			msg := fmt.Sprintf("Found %s/%s with %d available pods, more than its spec replicas %d", rs.Namespace, rs.Name, avaPodsCount, rs.Spec.Replicas)
			glog.Errorf("ERROR: %s", msg)
			return nil, fmt.Errorf(msg)
		}
		allRSPods = append(allRSPods, podutil.Filter(podList, matchingFunc)...)
	}
	return allRSPods, nil
}
Exemplo n.º 2
0
// filterPodsMatchingReplicaSets filters the given pod list and only return the ones targeted by the input replicasets
func filterPodsMatchingReplicaSets(replicaSets []*extensions.ReplicaSet, podList *api.PodList) ([]api.Pod, error) {
	rsPods := []api.Pod{}
	for _, rs := range replicaSets {
		matchingFunc, err := rsutil.MatchingPodsFunc(rs)
		if err != nil {
			return nil, err
		}
		if matchingFunc == nil {
			continue
		}
		rsPods = append(rsPods, podutil.Filter(podList, matchingFunc)...)
	}
	return rsPods, nil
}