Skip to content

Commit

Permalink
Update nodedb.go
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdavidsmith authored Jul 9, 2024
1 parent 889cda8 commit 807265d
Showing 1 changed file with 21 additions and 27 deletions.
48 changes: 21 additions & 27 deletions internal/scheduler/nodedb/nodedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,48 +37,42 @@ const (
var empty struct{}

func (nodeDb *NodeDb) create(node *schedulerobjects.Node) (*internaltypes.Node, error) {
if len(node.AllocatedByJobId) > 0 {
panic("AllocatedByJobId")

Check failure on line 40 in internal/scheduler/nodedb/nodedb.go

View workflow job for this annotation

GitHub Actions / lint / Lint Go

File is not `gofumpt`-ed (gofumpt)
if len(node.AllocatedByJobId) > 0 {
panic("AllocatedByJobId")
}
if len(node.AllocatedByQueue) > 0 {
panic("AllocatedByQueue")
panic("AllocatedByQueue")
}
if len(node.EvictedJobRunIds) > 0 {
panic("EvictedJobRunIds")
}

allowedPriorities := []int32{}
for _, p := range nodeDb.nodeDbPriorities {
if p != evictedPriority {
allowedPriorities = append(allowedPriorities, p)
}
panic("EvictedJobRunIds")
}

robAllocatable := schedulerobjects.NewAllocatableByPriorityAndResourceType(
allowedPriorities,
node.TotalResources,
types.AllowedPriorities(nodeDb.priorityClasses),
node.TotalResources,
)
for p, rl := range node.NonArmadaAllocatedResources {
robAllocatable.MarkAllocated(p, rl)
robAllocatable.MarkAllocated(p, rl)
}

if len(robAllocatable) != len(node.AllocatableByPriorityAndResource) {
fmt.Printf("existing %v, rob %v", node.AllocatableByPriorityAndResource, robAllocatable)
panic("AllocatableByPriorityAndResource lengths")
fmt.Printf("existing %v, rob %v", node.AllocatableByPriorityAndResource, robAllocatable)
panic("AllocatableByPriorityAndResource lengths")
}

for p, a := range node.AllocatableByPriorityAndResource {
robA, exists := robAllocatable[p]
if !exists {
fmt.Printf("existing %v, rob %v", node.AllocatableByPriorityAndResource, robAllocatable)
panic("AllocatableByPriorityAndResource missing")
}
cpy := a.DeepCopy()
cpy.Sub(robA)
if !cpy.IsZero() {
fmt.Printf("existing %v, rob %v", node.AllocatableByPriorityAndResource, robAllocatable)
panic("AllocatableByPriorityAndResource ne")
}
robA, exists := robAllocatable[p]
if !exists {
fmt.Printf("existing %v, rob %v", node.AllocatableByPriorityAndResource, robAllocatable)
panic("AllocatableByPriorityAndResource missing")
}
cpy := a.DeepCopy()
cpy.Sub(robA)
if !cpy.IsZero() {
fmt.Printf("existing %v, rob %v", node.AllocatableByPriorityAndResource, robAllocatable)
panic("AllocatableByPriorityAndResource ne")
}
}

fmt.Printf("All is good for %s\n", node.Name)
Expand Down

0 comments on commit 807265d

Please sign in to comment.