diff --git a/internal/scheduler/nodedb/nodedb.go b/internal/scheduler/nodedb/nodedb.go index e3c0c135ddf..b424e6f0039 100644 --- a/internal/scheduler/nodedb/nodedb.go +++ b/internal/scheduler/nodedb/nodedb.go @@ -37,6 +37,46 @@ const ( var empty struct{} func (nodeDb *NodeDb) create(node *schedulerobjects.Node) (*internaltypes.Node, error) { + + if len(node.AllocatedByJobId) > 0 { + panic("AllocatedByJobId") + } + if len(node.AllocatedByQueue) > 0 { + panic("AllocatedByQueue") + } + if len(node.EvictedJobRunIds) > 0 { + panic("EvictedJobRunIds") + } + + robAllocatable := schedulerobjects.NewAllocatableByPriorityAndResourceType( + types.AllowedPriorities(nodeDb.priorityClasses), + node.TotalResources, + ) + for p, rl := range node.NonArmadaAllocatedResources { + robAllocatable.MarkAllocated(p, rl) + } + + if len(robAllocatable) != len(node.AllocatableByPriorityAndResource) { + 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") + } + } + + fmt.Printf("All is good for %s\n", node.Name) + taints := node.GetTaints() if node.Unschedulable { taints = append(koTaint.DeepCopyTaintsInternStrings(taints, nodeDb.stringInterner.Intern), UnschedulableTaint())