Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tzneal committed Mar 25, 2022
1 parent ca2fc1e commit b827465
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions pkg/apis/provisioning/v1alpha5/requirements.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,13 @@ type Requirements struct {
// Hash implements the hash function
func (r Requirements) Hash() (uint64, error) {
// We explicitly hash both the list and set version of the requirements.
key := struct {
return hashstructure.Hash(struct {
Requirements []v1.NodeSelectorRequirement
RequirementsSets map[string]sets.Set
}{
r.Requirements,
r.requirements,
}
return hashstructure.Hash(key, hashstructure.FormatV2, &hashstructure.HashOptions{SlicesAsSets: true})
}, hashstructure.FormatV2, &hashstructure.HashOptions{SlicesAsSets: true})
}

// NewRequirements constructs requirements from NodeSelectorRequirements
Expand Down
12 changes: 6 additions & 6 deletions pkg/controllers/provisioning/scheduling/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type Node struct {
func NewNode(constraints *v1alpha5.Constraints, daemons []*v1.Pod, instanceTypeOptions []cloudprovider.InstanceType, pods ...*v1.Pod) *Node {
n := &Node{
Labels: constraints.Labels,
Taints: constraints.Taints.DeepCopy(),
Taints: constraints.Taints,
Requirements: *constraints.Requirements.DeepCopy(),
Provider: constraints.Provider,
KubeletConfiguration: constraints.KubeletConfiguration,
Expand Down Expand Up @@ -161,18 +161,18 @@ func (n Node) hasCompatibleResources(resourceList v1.ResourceList, it cloudprovi

func (n *Node) recalculateDaemonResources() {
n.daemonResources = nil
for _, ds := range n.daemons {
podRequirements := v1alpha5.NewPodRequirements(ds)
// we specifically do not check if the DaemonSet pod will fit on the node here, we want large DS pods to cause
for _, daemon := range n.daemons {
podRequirements := v1alpha5.NewPodRequirements(daemon)
// we intentionally do not check if the DaemonSet pod will fit on the node here, we want large DS pods to cause
// us to choose larger instance types
if err := n.Requirements.Compatible(podRequirements); err != nil {
continue
}
if err := n.Taints.Tolerates(ds); err != nil {
if err := n.Taints.Tolerates(daemon); err != nil {
continue
}

daemonsetResources := resources.RequestsForPods(ds)
daemonsetResources := resources.RequestsForPods(daemon)
daemonsetResources[v1.ResourcePods] = resource.MustParse("1")
n.daemonResources = resources.Merge(n.daemonResources, daemonsetResources)
}
Expand Down

0 comments on commit b827465

Please sign in to comment.