Skip to content

Commit

Permalink
Merge pull request kubernetes#813 from krzysied/cluster_loader_daemon…
Browse files Browse the repository at this point in the history
…set_hotfix

ClusterLoader - Using unschedulable spec
  • Loading branch information
k8s-ci-robot committed Sep 25, 2019
2 parents 6a8f8d6 + ab15356 commit f8c279d
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"k8s.io/client-go/dynamic"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/perf-tests/clusterloader2/pkg/framework/client"
"k8s.io/perf-tests/clusterloader2/pkg/util"
)

// ListRuntimeObjectsForKind returns objects of given kind that satisfy given namespace, labelSelector and fieldSelector.
Expand Down Expand Up @@ -292,7 +291,7 @@ func GetReplicasFromRuntimeObject(c clientset.Interface, obj runtime.Object) (in
return 0, nil
case *appsv1.DaemonSet:
// TODO(#790): In addition to nodeSelector the affinity should be also taken into account
return GetNumSchedulableNodesMatchingSelector(c, typed.Spec.Template.Spec.NodeSelector)
return getNumSchedulableNodesMatchingSelector(c, typed.Spec.Template.Spec.NodeSelector)
case *batch.Job:
if typed.Spec.Parallelism != nil {
return *typed.Spec.Parallelism, nil
Expand All @@ -303,8 +302,8 @@ func GetReplicasFromRuntimeObject(c clientset.Interface, obj runtime.Object) (in
}
}

// GetNumSchedulableNodesMatchingSelector returns the number of schedulable nodes matching the provided selector.
func GetNumSchedulableNodesMatchingSelector(c clientset.Interface, nodeSelector map[string]string) (int32, error) {
// getNumSchedulableNodesMatchingSelector returns the number of schedulable nodes matching the provided selector.
func getNumSchedulableNodesMatchingSelector(c clientset.Interface, nodeSelector map[string]string) (int32, error) {
selector, err := metav1.LabelSelectorAsSelector(metav1.SetAsLabelSelector(nodeSelector))
if err != nil {
return 0, err
Expand All @@ -316,7 +315,7 @@ func GetNumSchedulableNodesMatchingSelector(c clientset.Interface, nodeSelector
}
var numSchedulableNodes int32
for _, node := range list {
if util.IsNodeSchedulableAndUntainted(&node) {
if !node.Spec.Unschedulable {
numSchedulableNodes++
}
}
Expand All @@ -340,7 +339,7 @@ func tryAcquireReplicasFromUnstructuredSpec(c clientset.Interface, spec map[stri
return 0, err
}
// TODO(#790): In addition to nodeSelector the affinity should be also taken into account
return GetNumSchedulableNodesMatchingSelector(c, nodeSelector)
return getNumSchedulableNodesMatchingSelector(c, nodeSelector)
case "Job":
replicas, found, err := unstructured.NestedInt64(spec, "parallelism")
if err != nil {
Expand Down

0 comments on commit f8c279d

Please sign in to comment.