Skip to content

Commit

Permalink
Cache taints for existing nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis committed Nov 18, 2024
1 parent 6a036cb commit 1e61cb7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/controllers/provisioning/scheduling/existingnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
type ExistingNode struct {
*state.StateNode
cachedAvailable v1.ResourceList // Cache so we don't have to re-subtract resources on the StateNode every time
cachedTaints []v1.Taint // Cache so we don't hae to re-construct the taints each time we attempt to schedule a pod

Pods []*v1.Pod
topology *Topology
Expand All @@ -54,6 +55,7 @@ func NewExistingNode(n *state.StateNode, topology *Topology, daemonResources v1.
node := &ExistingNode{
StateNode: n,
cachedAvailable: n.Available(),
cachedTaints: n.Taints(),
topology: topology,
requests: remainingDaemonResources,
requirements: scheduling.NewLabelRequirements(n.Labels()),
Expand All @@ -65,7 +67,7 @@ func NewExistingNode(n *state.StateNode, topology *Topology, daemonResources v1.

func (n *ExistingNode) Add(ctx context.Context, kubeClient client.Client, pod *v1.Pod, podRequests v1.ResourceList) error {
// Check Taints
if err := scheduling.Taints(n.Taints()).Tolerates(pod); err != nil {
if err := scheduling.Taints(n.cachedTaints).Tolerates(pod); err != nil {
return err
}
// determine the volumes that will be mounted if the pod schedules
Expand Down
4 changes: 4 additions & 0 deletions pkg/scheduling/requirements.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ func HasPreferredNodeAffinity(p *corev1.Pod) bool {
}

func (r Requirements) NodeSelectorRequirements() []v1.NodeSelectorRequirementWithMinValues {
ret := []v1.NodeSelectorRequirementWithMinValues{}

Check failure on line 121 in pkg/scheduling/requirements.go

View workflow job for this annotation

GitHub Actions / Analyze Go

declared and not used: ret

Check failure on line 121 in pkg/scheduling/requirements.go

View workflow job for this annotation

GitHub Actions / presubmit (1.25.x)

declared and not used: ret

Check failure on line 121 in pkg/scheduling/requirements.go

View workflow job for this annotation

GitHub Actions / presubmit (1.26.x)

declared and not used: ret

Check failure on line 121 in pkg/scheduling/requirements.go

View workflow job for this annotation

GitHub Actions / presubmit (1.27.x)

declared and not used: ret

Check failure on line 121 in pkg/scheduling/requirements.go

View workflow job for this annotation

GitHub Actions / presubmit (1.28.x)

declared and not used: ret

Check failure on line 121 in pkg/scheduling/requirements.go

View workflow job for this annotation

GitHub Actions / presubmit (1.29.x)

declared and not used: ret

Check failure on line 121 in pkg/scheduling/requirements.go

View workflow job for this annotation

GitHub Actions / presubmit (1.30.x)

declared and not used: ret

Check failure on line 121 in pkg/scheduling/requirements.go

View workflow job for this annotation

GitHub Actions / presubmit (1.31.x)

declared and not used: ret
for _, requirement := range r {
return requirement.NodeSelectorRequirement()

Check failure on line 123 in pkg/scheduling/requirements.go

View workflow job for this annotation

GitHub Actions / Analyze Go

cannot use requirement.NodeSelectorRequirement() (value of type "sigs.k8s.io/karpenter/pkg/apis/v1".NodeSelectorRequirementWithMinValues) as []"sigs.k8s.io/karpenter/pkg/apis/v1".NodeSelectorRequirementWithMinValues value in return statement

Check failure on line 123 in pkg/scheduling/requirements.go

View workflow job for this annotation

GitHub Actions / presubmit (1.25.x)

cannot use requirement.NodeSelectorRequirement() (value of type "sigs.k8s.io/karpenter/pkg/apis/v1".NodeSelectorRequirementWithMinValues) as []"sigs.k8s.io/karpenter/pkg/apis/v1".NodeSelectorRequirementWithMinValues value in return statement

Check failure on line 123 in pkg/scheduling/requirements.go

View workflow job for this annotation

GitHub Actions / presubmit (1.26.x)

cannot use requirement.NodeSelectorRequirement() (value of type "sigs.k8s.io/karpenter/pkg/apis/v1".NodeSelectorRequirementWithMinValues) as []"sigs.k8s.io/karpenter/pkg/apis/v1".NodeSelectorRequirementWithMinValues value in return statement

Check failure on line 123 in pkg/scheduling/requirements.go

View workflow job for this annotation

GitHub Actions / presubmit (1.27.x)

cannot use requirement.NodeSelectorRequirement() (value of type "sigs.k8s.io/karpenter/pkg/apis/v1".NodeSelectorRequirementWithMinValues) as []"sigs.k8s.io/karpenter/pkg/apis/v1".NodeSelectorRequirementWithMinValues value in return statement

Check failure on line 123 in pkg/scheduling/requirements.go

View workflow job for this annotation

GitHub Actions / presubmit (1.28.x)

cannot use requirement.NodeSelectorRequirement() (value of type "sigs.k8s.io/karpenter/pkg/apis/v1".NodeSelectorRequirementWithMinValues) as []"sigs.k8s.io/karpenter/pkg/apis/v1".NodeSelectorRequirementWithMinValues value in return statement

Check failure on line 123 in pkg/scheduling/requirements.go

View workflow job for this annotation

GitHub Actions / presubmit (1.29.x)

cannot use requirement.NodeSelectorRequirement() (value of type "sigs.k8s.io/karpenter/pkg/apis/v1".NodeSelectorRequirementWithMinValues) as []"sigs.k8s.io/karpenter/pkg/apis/v1".NodeSelectorRequirementWithMinValues value in return statement

Check failure on line 123 in pkg/scheduling/requirements.go

View workflow job for this annotation

GitHub Actions / presubmit (1.30.x)

cannot use requirement.NodeSelectorRequirement() (value of type "sigs.k8s.io/karpenter/pkg/apis/v1".NodeSelectorRequirementWithMinValues) as []"sigs.k8s.io/karpenter/pkg/apis/v1".NodeSelectorRequirementWithMinValues value in return statement

Check failure on line 123 in pkg/scheduling/requirements.go

View workflow job for this annotation

GitHub Actions / presubmit (1.31.x)

cannot use requirement.NodeSelectorRequirement() (value of type "sigs.k8s.io/karpenter/pkg/apis/v1".NodeSelectorRequirementWithMinValues) as []"sigs.k8s.io/karpenter/pkg/apis/v1".NodeSelectorRequirementWithMinValues value in return statement
}
return lo.Map(lo.Values(r), func(req *Requirement, _ int) v1.NodeSelectorRequirementWithMinValues {
return req.NodeSelectorRequirement()
})
Expand Down

0 comments on commit 1e61cb7

Please sign in to comment.