mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-11 13:02:14 +00:00
kubelet: Convert IsMirrorOf to a function
Shrinks the PodManager interface by one method, no abstraction is necessary here.
This commit is contained in:
parent
02960a8253
commit
f8086f2dac
@ -1823,7 +1823,7 @@ func (kl *Kubelet) SyncPod(ctx context.Context, updateType kubetypes.SyncPodType
|
|||||||
if kubetypes.IsStaticPod(pod) {
|
if kubetypes.IsStaticPod(pod) {
|
||||||
deleted := false
|
deleted := false
|
||||||
if mirrorPod != nil {
|
if mirrorPod != nil {
|
||||||
if mirrorPod.DeletionTimestamp != nil || !kl.podManager.IsMirrorPodOf(mirrorPod, pod) {
|
if mirrorPod.DeletionTimestamp != nil || !kubepod.IsMirrorPodOf(mirrorPod, pod) {
|
||||||
// The mirror pod is semantically different from the static pod. Remove
|
// The mirror pod is semantically different from the static pod. Remove
|
||||||
// it. The mirror pod will get recreated later.
|
// it. The mirror pod will get recreated later.
|
||||||
klog.InfoS("Trying to delete pod", "pod", klog.KObj(pod), "podUID", mirrorPod.ObjectMeta.UID)
|
klog.InfoS("Trying to delete pod", "pod", klog.KObj(pod), "podUID", mirrorPod.ObjectMeta.UID)
|
||||||
|
@ -86,9 +86,6 @@ type Manager interface {
|
|||||||
// GetUIDTranslations returns the mappings of static pod UIDs to mirror pod
|
// GetUIDTranslations returns the mappings of static pod UIDs to mirror pod
|
||||||
// UIDs and mirror pod UIDs to static pod UIDs.
|
// UIDs and mirror pod UIDs to static pod UIDs.
|
||||||
GetUIDTranslations() (podToMirror map[kubetypes.ResolvedPodUID]kubetypes.MirrorPodUID, mirrorToPod map[kubetypes.MirrorPodUID]kubetypes.ResolvedPodUID)
|
GetUIDTranslations() (podToMirror map[kubetypes.ResolvedPodUID]kubetypes.MirrorPodUID, mirrorToPod map[kubetypes.MirrorPodUID]kubetypes.ResolvedPodUID)
|
||||||
// IsMirrorPodOf returns true if mirrorPod is a correct representation of
|
|
||||||
// pod; false otherwise.
|
|
||||||
IsMirrorPodOf(mirrorPod, pod *v1.Pod) bool
|
|
||||||
|
|
||||||
MirrorClient
|
MirrorClient
|
||||||
}
|
}
|
||||||
@ -292,7 +289,8 @@ func (pm *basicManager) GetOrphanedMirrorPodNames() []string {
|
|||||||
return podFullNames
|
return podFullNames
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pm *basicManager) IsMirrorPodOf(mirrorPod, pod *v1.Pod) bool {
|
// IsMirrorPodOf returns true if pod and mirrorPod are associated with each other.
|
||||||
|
func IsMirrorPodOf(mirrorPod, pod *v1.Pod) bool {
|
||||||
// Check name and namespace first.
|
// Check name and namespace first.
|
||||||
if pod.Name != mirrorPod.Name || pod.Namespace != mirrorPod.Namespace {
|
if pod.Name != mirrorPod.Name || pod.Namespace != mirrorPod.Namespace {
|
||||||
return false
|
return false
|
||||||
|
@ -238,20 +238,6 @@ func (mr *MockManagerMockRecorder) GetUIDTranslations() *gomock.Call {
|
|||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUIDTranslations", reflect.TypeOf((*MockManager)(nil).GetUIDTranslations))
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUIDTranslations", reflect.TypeOf((*MockManager)(nil).GetUIDTranslations))
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsMirrorPodOf mocks base method.
|
|
||||||
func (m *MockManager) IsMirrorPodOf(arg0, arg1 *v1.Pod) bool {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "IsMirrorPodOf", arg0, arg1)
|
|
||||||
ret0, _ := ret[0].(bool)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsMirrorPodOf indicates an expected call of IsMirrorPodOf.
|
|
||||||
func (mr *MockManagerMockRecorder) IsMirrorPodOf(arg0, arg1 interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsMirrorPodOf", reflect.TypeOf((*MockManager)(nil).IsMirrorPodOf), arg0, arg1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetPods mocks base method.
|
// SetPods mocks base method.
|
||||||
func (m *MockManager) SetPods(arg0 []*v1.Pod) {
|
func (m *MockManager) SetPods(arg0 []*v1.Pod) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
|
Loading…
Reference in New Issue
Block a user