Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check for taints to determine if pod can run #29793

Merged
merged 1 commit into from
Oct 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 24 additions & 2 deletions pkg/controllers/management/clusterstats/statsaggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ import (
"k8s.io/apimachinery/pkg/labels"
)

const (
nodeRoleControlPlane = "node-role.kubernetes.io/controlplane"
nodeRoleControlPlaneHyphen = "node-role.kubernetes.io/control-plane"
nodeRoleETCD = "node-role.kubernetes.io/etcd"
nodeRoleMaster = "node-role.kubernetes.io/master"
)

type StatsAggregator struct {
NodesLister v3.NodeLister
Clusters v3.ClusterInterface
Expand Down Expand Up @@ -68,9 +75,13 @@ func (s *StatsAggregator) aggregate(cluster *v3.Cluster, clusterName string) err
if !m.Spec.Worker && !m.Spec.ControlPlane && !m.Spec.Etcd {
return errors.Errorf("node role cannot be determined because node %s has not finished syncing. retrying...", m.Status.NodeName)
}
if m.Spec.Worker && !m.Spec.InternalNodeSpec.Unschedulable {
machines = append(machines, m)
if isTaintedNoExecuteNoSchedule(m) && !m.Spec.Worker {
continue
}
if m.Spec.InternalNodeSpec.Unschedulable {
continue
}
machines = append(machines, m)
}

origStatus := cluster.Status.DeepCopy()
Expand Down Expand Up @@ -225,3 +236,14 @@ func (s *StatsAggregator) machineChanged(key string, machine *v3.Node) (runtime.
}
return nil, nil
}

func isTaintedNoExecuteNoSchedule(m *v3.Node) bool {
for _, taint := range m.Spec.InternalNodeSpec.Taints {
isETCDOrControlPlane := taint.Key == nodeRoleControlPlane || taint.Key == nodeRoleETCD ||
taint.Key == nodeRoleControlPlaneHyphen || taint.Key == nodeRoleMaster
if isETCDOrControlPlane && (taint.Effect == "NoSchedule" || taint.Effect == "NoExecute") {
return true
}
}
return false
}