Skip to content

Commit

Permalink
Merge pull request #95602 from chenyw1990/master
Browse files Browse the repository at this point in the history
write checkpoint only when allocated devices updated.
  • Loading branch information
k8s-ci-robot committed Oct 23, 2020
2 parents ededd08 + 009d46f commit a420993
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/kubelet/cm/devicemanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ func (m *ManagerImpl) allocateContainerResources(pod *v1.Pod, container *v1.Cont
podUID := string(pod.UID)
contName := container.Name
allocatedDevicesUpdated := false
needsUpdateCheckpoint := false
// Extended resources are not allowed to be overcommitted.
// Since device plugin advertises extended resources,
// therefore Requests must be equal to Limits and iterating
Expand All @@ -858,6 +859,8 @@ func (m *ManagerImpl) allocateContainerResources(pod *v1.Pod, container *v1.Cont
continue
}

needsUpdateCheckpoint = true

startRPCTime := time.Now()
// Manager.Allocate involves RPC calls to device plugin, which
// could be heavy-weight. Therefore we want to perform this operation outside
Expand Down Expand Up @@ -906,8 +909,11 @@ func (m *ManagerImpl) allocateContainerResources(pod *v1.Pod, container *v1.Cont
m.mutex.Unlock()
}

// Checkpoints device to container allocation information.
return m.writeCheckpoint()
if needsUpdateCheckpoint {
return m.writeCheckpoint()
}

return nil
}

// GetDeviceRunContainerOptions checks whether we have cached containerDevices
Expand Down

0 comments on commit a420993

Please sign in to comment.