-
Notifications
You must be signed in to change notification settings - Fork 129
/
node.go
50 lines (44 loc) · 1.39 KB
/
node.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package schedulerobjects
import (
"fmt"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
armadamaps "github.com/armadaproject/armada/internal/common/maps"
)
func (node *Node) DeepCopy() *Node {
if node == nil {
return nil
}
return &Node{
Id: node.Id,
Name: node.Name,
Executor: node.Executor,
LastSeen: node.LastSeen,
NodeType: node.NodeType.DeepCopy(),
Taints: slices.Clone(node.Taints),
Labels: maps.Clone(node.Labels),
TotalResources: node.TotalResources.DeepCopy(),
AllocatableByPriorityAndResource: AllocatableByPriorityAndResourceType(
node.AllocatableByPriorityAndResource,
).DeepCopy(),
StateByJobRunId: maps.Clone(node.StateByJobRunId),
AllocatedByJobId: armadamaps.DeepCopy(node.AllocatedByJobId),
AllocatedByQueue: armadamaps.DeepCopy(node.AllocatedByQueue),
EvictedJobRunIds: maps.Clone(node.EvictedJobRunIds),
NonArmadaAllocatedResources: armadamaps.DeepCopy(node.NonArmadaAllocatedResources),
Unschedulable: node.Unschedulable,
}
}
func (node *Node) CompactString() string {
if node == nil {
return "<nil>"
}
return fmt.Sprintf("Node{Id; %s}", node.Id)
}
func (node *Node) AvailableArmadaResource() ResourceList {
tr := node.TotalResources.DeepCopy()
for _, rl := range node.NonArmadaAllocatedResources {
tr.Sub(rl)
}
return tr
}