Skip to content

Commit dd552e2

Browse files
authored
Merge pull request kubernetes#91337 from liggitt/revert-sandbox
Revert "Merge pull request kubernetes#89667 from kmala/kubelet"
2 parents bded41a + 591e004 commit dd552e2

File tree

5 files changed

+11
-81
lines changed

5 files changed

+11
-81
lines changed

pkg/kubelet/BUILD

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,20 @@ go_test(
250250
"//staging/src/k8s.io/client-go/util/testing:go_default_library",
251251
"//staging/src/k8s.io/component-base/featuregate/testing:go_default_library",
252252
"//staging/src/k8s.io/component-base/version:go_default_library",
253-
"//staging/src/k8s.io/cri-api/pkg/apis/runtime/v1alpha2:go_default_library",
254253
"//vendor/github.com/google/cadvisor/info/v1:go_default_library",
255254
"//vendor/github.com/google/cadvisor/info/v2:go_default_library",
256255
"//vendor/github.com/stretchr/testify/assert:go_default_library",
257256
"//vendor/github.com/stretchr/testify/require:go_default_library",
258257
"//vendor/k8s.io/utils/mount:go_default_library",
259-
],
258+
] + select({
259+
"@io_bazel_rules_go//go/platform:android": [
260+
"//staging/src/k8s.io/cri-api/pkg/apis/runtime/v1alpha2:go_default_library",
261+
],
262+
"@io_bazel_rules_go//go/platform:linux": [
263+
"//staging/src/k8s.io/cri-api/pkg/apis/runtime/v1alpha2:go_default_library",
264+
],
265+
"//conditions:default": [],
266+
}),
260267
)
261268

262269
filegroup(

pkg/kubelet/container/runtime.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ type PodStatus struct {
285285
// Status of containers in the pod.
286286
ContainerStatuses []*ContainerStatus
287287
// Status of the pod sandbox.
288+
// Only for kuberuntime now, other runtime may keep it nil.
288289
SandboxStatuses []*runtimeapi.PodSandboxStatus
289290
}
290291

pkg/kubelet/cri/remote/fake/fake_runtime.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (f *RemoteRuntime) StopPodSandbox(ctx context.Context, req *kubeapi.StopPod
112112
// This call is idempotent, and must not return an error if the sandbox has
113113
// already been removed.
114114
func (f *RemoteRuntime) RemovePodSandbox(ctx context.Context, req *kubeapi.RemovePodSandboxRequest) (*kubeapi.RemovePodSandboxResponse, error) {
115-
err := f.RuntimeService.RemovePodSandbox(req.PodSandboxId)
115+
err := f.RuntimeService.StopPodSandbox(req.PodSandboxId)
116116
if err != nil {
117117
return nil, err
118118
}

pkg/kubelet/kubelet_pods.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -940,16 +940,6 @@ func (kl *Kubelet) PodResourcesAreReclaimed(pod *v1.Pod, status v1.PodStatus) bo
940940
klog.V(3).Infof("Pod %q is terminated, but some containers have not been cleaned up: %s", format.Pod(pod), statusStr)
941941
return false
942942
}
943-
// pod's sandboxes should be deleted
944-
if len(runtimeStatus.SandboxStatuses) > 0 {
945-
var sandboxStr string
946-
for _, sandbox := range runtimeStatus.SandboxStatuses {
947-
sandboxStr += fmt.Sprintf("%+v ", *sandbox)
948-
}
949-
klog.V(3).Infof("Pod %q is terminated, but some pod sandboxes have not been cleaned up: %s", format.Pod(pod), sandboxStr)
950-
return false
951-
}
952-
953943
if kl.podVolumesExist(pod.UID) && !kl.keepTerminatedPodVolumes {
954944
// We shouldn't delete pods whose volumes have not been cleaned up if we are not keeping terminated pod volumes
955945
klog.V(3).Infof("Pod %q is terminated, but some volumes have not been cleaned up", format.Pod(pod))

pkg/kubelet/kubelet_pods_test.go

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import (
4242
// api.Registry.GroupOrDie(v1.GroupName).GroupVersions[0].String() is changed
4343
// to "v1"?
4444

45-
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
4645
_ "k8s.io/kubernetes/pkg/apis/core/install"
4746
"k8s.io/kubernetes/pkg/features"
4847
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
@@ -2386,70 +2385,3 @@ func TestTruncatePodHostname(t *testing.T) {
23862385
assert.Equal(t, test.output, output)
23872386
}
23882387
}
2389-
2390-
func TestPodResourcesAreReclaimed(t *testing.T) {
2391-
2392-
type args struct {
2393-
pod *v1.Pod
2394-
status v1.PodStatus
2395-
runtimeStatus kubecontainer.PodStatus
2396-
}
2397-
tests := []struct {
2398-
name string
2399-
args args
2400-
want bool
2401-
}{
2402-
{
2403-
"pod with running containers",
2404-
args{
2405-
pod: &v1.Pod{},
2406-
status: v1.PodStatus{
2407-
ContainerStatuses: []v1.ContainerStatus{
2408-
runningState("containerA"),
2409-
runningState("containerB"),
2410-
},
2411-
},
2412-
},
2413-
false,
2414-
},
2415-
{
2416-
"pod with containers in runtime cache",
2417-
args{
2418-
pod: &v1.Pod{},
2419-
status: v1.PodStatus{},
2420-
runtimeStatus: kubecontainer.PodStatus{
2421-
ContainerStatuses: []*kubecontainer.ContainerStatus{
2422-
{},
2423-
},
2424-
},
2425-
},
2426-
false,
2427-
},
2428-
{
2429-
"pod with sandbox present",
2430-
args{
2431-
pod: &v1.Pod{},
2432-
status: v1.PodStatus{},
2433-
runtimeStatus: kubecontainer.PodStatus{
2434-
SandboxStatuses: []*runtimeapi.PodSandboxStatus{
2435-
{},
2436-
},
2437-
},
2438-
},
2439-
false,
2440-
},
2441-
}
2442-
2443-
testKubelet := newTestKubelet(t, false)
2444-
defer testKubelet.Cleanup()
2445-
kl := testKubelet.kubelet
2446-
2447-
for _, tt := range tests {
2448-
t.Run(tt.name, func(t *testing.T) {
2449-
testKubelet.fakeRuntime.PodStatus = tt.args.runtimeStatus
2450-
if got := kl.PodResourcesAreReclaimed(tt.args.pod, tt.args.status); got != tt.want {
2451-
t.Errorf("PodResourcesAreReclaimed() = %v, want %v", got, tt.want)
2452-
}
2453-
})
2454-
}
2455-
}

0 commit comments

Comments
 (0)