mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-27 05:04:52 +00:00
Merge pull request #92442 from tedyu/grace-period-with-map
Respect grace period when removing mirror pod
This commit is contained in:
@@ -73,10 +73,8 @@ type Manager interface {
|
||||
// this means deleting the mappings related to mirror pods. For non-
|
||||
// mirror pods, this means deleting from indexes for all non-mirror pods.
|
||||
DeletePod(pod *v1.Pod)
|
||||
// DeleteOrphanedMirrorPods deletes all mirror pods which do not have
|
||||
// associated static pods. This method sends deletion requests to the API
|
||||
// server, but does NOT modify the internal pod storage in basicManager.
|
||||
DeleteOrphanedMirrorPods()
|
||||
// GetOrphanedMirrorPodNames returns names of orphaned mirror pods
|
||||
GetOrphanedMirrorPodNames() []string
|
||||
// TranslatePodUID returns the actual UID of a pod. If the UID belongs to
|
||||
// a mirror pod, returns the UID of its static pod. Otherwise, returns the
|
||||
// original UID.
|
||||
@@ -307,7 +305,7 @@ func (pm *basicManager) GetUIDTranslations() (podToMirror map[kubetypes.Resolved
|
||||
return podToMirror, mirrorToPod
|
||||
}
|
||||
|
||||
func (pm *basicManager) getOrphanedMirrorPodNames() []string {
|
||||
func (pm *basicManager) GetOrphanedMirrorPodNames() []string {
|
||||
pm.lock.RLock()
|
||||
defer pm.lock.RUnlock()
|
||||
var podFullNames []string
|
||||
@@ -319,13 +317,6 @@ func (pm *basicManager) getOrphanedMirrorPodNames() []string {
|
||||
return podFullNames
|
||||
}
|
||||
|
||||
func (pm *basicManager) DeleteOrphanedMirrorPods() {
|
||||
podFullNames := pm.getOrphanedMirrorPodNames()
|
||||
for _, podFullName := range podFullNames {
|
||||
pm.MirrorClient.DeleteMirrorPod(podFullName, nil)
|
||||
}
|
||||
}
|
||||
|
||||
func (pm *basicManager) IsMirrorPodOf(mirrorPod, pod *v1.Pod) bool {
|
||||
// Check name and namespace first.
|
||||
if pod.Name != mirrorPod.Name || pod.Namespace != mirrorPod.Namespace {
|
||||
|
@@ -158,7 +158,7 @@ func TestDeletePods(t *testing.T) {
|
||||
t.Fatalf("Run DeletePod() error, expected %d pods, got %d pods; ", len(expectedPods)-1, len(actualPods))
|
||||
}
|
||||
|
||||
orphanedMirrorPodNames := podManager.getOrphanedMirrorPodNames()
|
||||
orphanedMirrorPodNames := podManager.GetOrphanedMirrorPodNames()
|
||||
expectedOrphanedMirrorPodNameNum := 1
|
||||
if len(orphanedMirrorPodNames) != expectedOrphanedMirrorPodNameNum {
|
||||
t.Fatalf("Run getOrphanedMirrorPodNames() error, expected %d orphaned mirror pods, got %d orphaned mirror pods; ", expectedOrphanedMirrorPodNameNum, len(orphanedMirrorPodNames))
|
||||
|
@@ -17,7 +17,9 @@ limitations under the License.
|
||||
// Code generated by mockery v1.0.0
|
||||
package testing
|
||||
|
||||
import kubelettypes "k8s.io/kubernetes/pkg/kubelet/types"
|
||||
import (
|
||||
kubelettypes "k8s.io/kubernetes/pkg/kubelet/types"
|
||||
)
|
||||
import mock "github.com/stretchr/testify/mock"
|
||||
|
||||
import types "k8s.io/apimachinery/pkg/types"
|
||||
@@ -61,9 +63,18 @@ func (_m *MockManager) DeleteMirrorPod(podFullName string, _ *types.UID) (bool,
|
||||
return false, r0
|
||||
}
|
||||
|
||||
// DeleteOrphanedMirrorPods provides a mock function with given fields:
|
||||
func (_m *MockManager) DeleteOrphanedMirrorPods() {
|
||||
_m.Called()
|
||||
func (_m *MockManager) GetOrphanedMirrorPodNames() []string {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 []string
|
||||
if rf, ok := ret.Get(0).(func() []string); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]string)
|
||||
}
|
||||
}
|
||||
return r0
|
||||
}
|
||||
|
||||
// DeletePod provides a mock function with given fields: _a0
|
||||
|
Reference in New Issue
Block a user