Add Get interfaces for container's checkpointed ResourcesAllocated and Resize values, remove error logging for valid standalone kubelet scenario
This commit is contained in:
@@ -68,6 +68,16 @@ func (m *fakeManager) State() state.Reader {
|
||||
return m.state
|
||||
}
|
||||
|
||||
func (m *fakeManager) GetContainerResourceAllocation(podUID string, containerName string) (v1.ResourceList, bool) {
|
||||
klog.InfoS("GetContainerResourceAllocation()")
|
||||
return m.state.GetContainerResourceAllocation(podUID, containerName)
|
||||
}
|
||||
|
||||
func (m *fakeManager) GetPodResizeStatus(podUID string) (v1.PodResizeStatus, bool) {
|
||||
klog.InfoS("GetPodResizeStatus()")
|
||||
return "", false
|
||||
}
|
||||
|
||||
func (m *fakeManager) SetPodAllocation(pod *v1.Pod) error {
|
||||
klog.InfoS("SetPodAllocation()")
|
||||
for _, container := range pod.Spec.Containers {
|
||||
|
@@ -140,6 +140,12 @@ type Manager interface {
|
||||
// State returns a read-only interface to the internal status manager state.
|
||||
State() state.Reader
|
||||
|
||||
// GetContainerResourceAllocation returns checkpointed ResourcesAllocated value for the container
|
||||
GetContainerResourceAllocation(podUID string, containerName string) (v1.ResourceList, bool)
|
||||
|
||||
// GetPodResizeStatus returns checkpointed PodStatus.Resize value
|
||||
GetPodResizeStatus(podUID string) (v1.PodResizeStatus, bool)
|
||||
|
||||
// SetPodAllocation checkpoints the resources allocated to a pod's containers.
|
||||
SetPodAllocation(pod *v1.Pod) error
|
||||
|
||||
@@ -234,6 +240,28 @@ func (m *manager) State() state.Reader {
|
||||
return m.state
|
||||
}
|
||||
|
||||
// GetContainerResourceAllocation returns the last checkpointed ResourcesAllocated values
|
||||
// If checkpoint manager has not been initialized, it returns nil, false
|
||||
func (m *manager) GetContainerResourceAllocation(podUID string, containerName string) (v1.ResourceList, bool) {
|
||||
m.podStatusesLock.RLock()
|
||||
defer m.podStatusesLock.RUnlock()
|
||||
if m.state != nil {
|
||||
return m.state.GetContainerResourceAllocation(podUID, containerName)
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// GetPodResizeStatus returns the last checkpointed ResizeStaus value
|
||||
// If checkpoint manager has not been initialized, it returns nil, false
|
||||
func (m *manager) GetPodResizeStatus(podUID string) (v1.PodResizeStatus, bool) {
|
||||
m.podStatusesLock.RLock()
|
||||
defer m.podStatusesLock.RUnlock()
|
||||
if m.state != nil {
|
||||
return m.state.GetPodResizeStatus(podUID)
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
// SetPodAllocation checkpoints the resources allocated to a pod's containers
|
||||
func (m *manager) SetPodAllocation(pod *v1.Pod) error {
|
||||
if m.state == nil {
|
||||
@@ -680,11 +708,9 @@ func (m *manager) deletePodStatus(uid types.UID) {
|
||||
delete(m.podStatuses, uid)
|
||||
m.podStartupLatencyHelper.DeletePodStartupState(uid)
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) {
|
||||
if m.state == nil {
|
||||
klog.ErrorS(nil, "pod allocation checkpoint manager is not initialized")
|
||||
return
|
||||
if m.state != nil {
|
||||
m.state.Delete(string(uid), "")
|
||||
}
|
||||
m.state.Delete(string(uid), "")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -697,11 +723,9 @@ func (m *manager) RemoveOrphanedStatuses(podUIDs map[types.UID]bool) {
|
||||
klog.V(5).InfoS("Removing pod from status map.", "podUID", key)
|
||||
delete(m.podStatuses, key)
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) {
|
||||
if m.state == nil {
|
||||
klog.ErrorS(nil, "pod allocation checkpoint manager is not initialized")
|
||||
continue
|
||||
if m.state != nil {
|
||||
m.state.Delete(string(key), "")
|
||||
}
|
||||
m.state.Delete(string(key), "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -189,6 +189,36 @@ func (m *MockManager) EXPECT() *MockManagerMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// GetContainerResourceAllocation mocks base method.
|
||||
func (m *MockManager) GetContainerResourceAllocation(podUID, containerName string) (v1.ResourceList, bool) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetContainerResourceAllocation", podUID, containerName)
|
||||
ret0, _ := ret[0].(v1.ResourceList)
|
||||
ret1, _ := ret[1].(bool)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetContainerResourceAllocation indicates an expected call of GetContainerResourceAllocation.
|
||||
func (mr *MockManagerMockRecorder) GetContainerResourceAllocation(podUID, containerName interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetContainerResourceAllocation", reflect.TypeOf((*MockManager)(nil).GetContainerResourceAllocation), podUID, containerName)
|
||||
}
|
||||
|
||||
// GetPodResizeStatus mocks base method.
|
||||
func (m *MockManager) GetPodResizeStatus(podUID string) (v1.PodResizeStatus, bool) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetPodResizeStatus", podUID)
|
||||
ret0, _ := ret[0].(v1.PodResizeStatus)
|
||||
ret1, _ := ret[1].(bool)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetPodResizeStatus indicates an expected call of GetPodResizeStatus.
|
||||
func (mr *MockManagerMockRecorder) GetPodResizeStatus(podUID interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPodResizeStatus", reflect.TypeOf((*MockManager)(nil).GetPodResizeStatus), podUID)
|
||||
}
|
||||
|
||||
// GetPodStatus mocks base method.
|
||||
func (m *MockManager) GetPodStatus(uid types.UID) (v1.PodStatus, bool) {
|
||||
m.ctrl.T.Helper()
|
||||
|
Reference in New Issue
Block a user