mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 22:17:14 +00:00
Fixed potential OutOfSync of nodeInfo.
This commit is contained in:
parent
302aab9ba2
commit
9b1e5ec507
@ -82,6 +82,19 @@ func (r *Resource) ResourceList() v1.ResourceList {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Resource) Clone() *Resource {
|
||||||
|
res := &Resource{
|
||||||
|
MilliCPU: r.MilliCPU,
|
||||||
|
Memory: r.Memory,
|
||||||
|
NvidiaGPU: r.NvidiaGPU,
|
||||||
|
}
|
||||||
|
res.OpaqueIntResources = make(map[v1.ResourceName]int64)
|
||||||
|
for k, v := range r.OpaqueIntResources {
|
||||||
|
res.OpaqueIntResources[k] = v
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Resource) AddOpaque(name v1.ResourceName, quantity int64) {
|
func (r *Resource) AddOpaque(name v1.ResourceName, quantity int64) {
|
||||||
// Lazily allocate opaque integer resource map.
|
// Lazily allocate opaque integer resource map.
|
||||||
if r.OpaqueIntResources == nil {
|
if r.OpaqueIntResources == nil {
|
||||||
@ -186,9 +199,9 @@ func (n *NodeInfo) AllocatableResource() Resource {
|
|||||||
func (n *NodeInfo) Clone() *NodeInfo {
|
func (n *NodeInfo) Clone() *NodeInfo {
|
||||||
clone := &NodeInfo{
|
clone := &NodeInfo{
|
||||||
node: n.node,
|
node: n.node,
|
||||||
requestedResource: &(*n.requestedResource),
|
requestedResource: n.requestedResource.Clone(),
|
||||||
nonzeroRequest: &(*n.nonzeroRequest),
|
nonzeroRequest: n.nonzeroRequest.Clone(),
|
||||||
allocatableResource: &(*n.allocatableResource),
|
allocatableResource: n.allocatableResource.Clone(),
|
||||||
allowedPodNumber: n.allowedPodNumber,
|
allowedPodNumber: n.allowedPodNumber,
|
||||||
taintsErr: n.taintsErr,
|
taintsErr: n.taintsErr,
|
||||||
memoryPressureCondition: n.memoryPressureCondition,
|
memoryPressureCondition: n.memoryPressureCondition,
|
||||||
|
Loading…
Reference in New Issue
Block a user