write checkpoint only when allocated devices updated.
This commit is contained in:
		@@ -833,6 +833,7 @@ func (m *ManagerImpl) allocateContainerResources(pod *v1.Pod, container *v1.Cont
 | 
				
			|||||||
	podUID := string(pod.UID)
 | 
						podUID := string(pod.UID)
 | 
				
			||||||
	contName := container.Name
 | 
						contName := container.Name
 | 
				
			||||||
	allocatedDevicesUpdated := false
 | 
						allocatedDevicesUpdated := false
 | 
				
			||||||
 | 
						needsUpdateCheckpoint := false
 | 
				
			||||||
	// Extended resources are not allowed to be overcommitted.
 | 
						// Extended resources are not allowed to be overcommitted.
 | 
				
			||||||
	// Since device plugin advertises extended resources,
 | 
						// Since device plugin advertises extended resources,
 | 
				
			||||||
	// therefore Requests must be equal to Limits and iterating
 | 
						// therefore Requests must be equal to Limits and iterating
 | 
				
			||||||
@@ -858,6 +859,8 @@ func (m *ManagerImpl) allocateContainerResources(pod *v1.Pod, container *v1.Cont
 | 
				
			|||||||
			continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							needsUpdateCheckpoint = true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		startRPCTime := time.Now()
 | 
							startRPCTime := time.Now()
 | 
				
			||||||
		// Manager.Allocate involves RPC calls to device plugin, which
 | 
							// Manager.Allocate involves RPC calls to device plugin, which
 | 
				
			||||||
		// could be heavy-weight. Therefore we want to perform this operation outside
 | 
							// could be heavy-weight. Therefore we want to perform this operation outside
 | 
				
			||||||
@@ -906,8 +909,11 @@ func (m *ManagerImpl) allocateContainerResources(pod *v1.Pod, container *v1.Cont
 | 
				
			|||||||
		m.mutex.Unlock()
 | 
							m.mutex.Unlock()
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Checkpoints device to container allocation information.
 | 
						if needsUpdateCheckpoint {
 | 
				
			||||||
	return m.writeCheckpoint()
 | 
							return m.writeCheckpoint()
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetDeviceRunContainerOptions checks whether we have cached containerDevices
 | 
					// GetDeviceRunContainerOptions checks whether we have cached containerDevices
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user