mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 10:20:51 +00:00
Merge pull request #91337 from liggitt/revert-sandbox
Revert "Merge pull request #89667 from kmala/kubelet"
This commit is contained in:
commit
dd552e2059
@ -250,13 +250,20 @@ go_test(
|
|||||||
"//staging/src/k8s.io/client-go/util/testing:go_default_library",
|
"//staging/src/k8s.io/client-go/util/testing:go_default_library",
|
||||||
"//staging/src/k8s.io/component-base/featuregate/testing:go_default_library",
|
"//staging/src/k8s.io/component-base/featuregate/testing:go_default_library",
|
||||||
"//staging/src/k8s.io/component-base/version:go_default_library",
|
"//staging/src/k8s.io/component-base/version:go_default_library",
|
||||||
"//staging/src/k8s.io/cri-api/pkg/apis/runtime/v1alpha2:go_default_library",
|
|
||||||
"//vendor/github.com/google/cadvisor/info/v1:go_default_library",
|
"//vendor/github.com/google/cadvisor/info/v1:go_default_library",
|
||||||
"//vendor/github.com/google/cadvisor/info/v2:go_default_library",
|
"//vendor/github.com/google/cadvisor/info/v2:go_default_library",
|
||||||
"//vendor/github.com/stretchr/testify/assert:go_default_library",
|
"//vendor/github.com/stretchr/testify/assert:go_default_library",
|
||||||
"//vendor/github.com/stretchr/testify/require:go_default_library",
|
"//vendor/github.com/stretchr/testify/require:go_default_library",
|
||||||
"//vendor/k8s.io/utils/mount:go_default_library",
|
"//vendor/k8s.io/utils/mount:go_default_library",
|
||||||
],
|
] + select({
|
||||||
|
"@io_bazel_rules_go//go/platform:android": [
|
||||||
|
"//staging/src/k8s.io/cri-api/pkg/apis/runtime/v1alpha2:go_default_library",
|
||||||
|
],
|
||||||
|
"@io_bazel_rules_go//go/platform:linux": [
|
||||||
|
"//staging/src/k8s.io/cri-api/pkg/apis/runtime/v1alpha2:go_default_library",
|
||||||
|
],
|
||||||
|
"//conditions:default": [],
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
filegroup(
|
filegroup(
|
||||||
|
@ -285,6 +285,7 @@ type PodStatus struct {
|
|||||||
// Status of containers in the pod.
|
// Status of containers in the pod.
|
||||||
ContainerStatuses []*ContainerStatus
|
ContainerStatuses []*ContainerStatus
|
||||||
// Status of the pod sandbox.
|
// Status of the pod sandbox.
|
||||||
|
// Only for kuberuntime now, other runtime may keep it nil.
|
||||||
SandboxStatuses []*runtimeapi.PodSandboxStatus
|
SandboxStatuses []*runtimeapi.PodSandboxStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ func (f *RemoteRuntime) StopPodSandbox(ctx context.Context, req *kubeapi.StopPod
|
|||||||
// This call is idempotent, and must not return an error if the sandbox has
|
// This call is idempotent, and must not return an error if the sandbox has
|
||||||
// already been removed.
|
// already been removed.
|
||||||
func (f *RemoteRuntime) RemovePodSandbox(ctx context.Context, req *kubeapi.RemovePodSandboxRequest) (*kubeapi.RemovePodSandboxResponse, error) {
|
func (f *RemoteRuntime) RemovePodSandbox(ctx context.Context, req *kubeapi.RemovePodSandboxRequest) (*kubeapi.RemovePodSandboxResponse, error) {
|
||||||
err := f.RuntimeService.RemovePodSandbox(req.PodSandboxId)
|
err := f.RuntimeService.StopPodSandbox(req.PodSandboxId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -940,16 +940,6 @@ func (kl *Kubelet) PodResourcesAreReclaimed(pod *v1.Pod, status v1.PodStatus) bo
|
|||||||
klog.V(3).Infof("Pod %q is terminated, but some containers have not been cleaned up: %s", format.Pod(pod), statusStr)
|
klog.V(3).Infof("Pod %q is terminated, but some containers have not been cleaned up: %s", format.Pod(pod), statusStr)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// pod's sandboxes should be deleted
|
|
||||||
if len(runtimeStatus.SandboxStatuses) > 0 {
|
|
||||||
var sandboxStr string
|
|
||||||
for _, sandbox := range runtimeStatus.SandboxStatuses {
|
|
||||||
sandboxStr += fmt.Sprintf("%+v ", *sandbox)
|
|
||||||
}
|
|
||||||
klog.V(3).Infof("Pod %q is terminated, but some pod sandboxes have not been cleaned up: %s", format.Pod(pod), sandboxStr)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if kl.podVolumesExist(pod.UID) && !kl.keepTerminatedPodVolumes {
|
if kl.podVolumesExist(pod.UID) && !kl.keepTerminatedPodVolumes {
|
||||||
// We shouldn't delete pods whose volumes have not been cleaned up if we are not keeping terminated pod volumes
|
// We shouldn't delete pods whose volumes have not been cleaned up if we are not keeping terminated pod volumes
|
||||||
klog.V(3).Infof("Pod %q is terminated, but some volumes have not been cleaned up", format.Pod(pod))
|
klog.V(3).Infof("Pod %q is terminated, but some volumes have not been cleaned up", format.Pod(pod))
|
||||||
|
@ -42,7 +42,6 @@ import (
|
|||||||
// api.Registry.GroupOrDie(v1.GroupName).GroupVersions[0].String() is changed
|
// api.Registry.GroupOrDie(v1.GroupName).GroupVersions[0].String() is changed
|
||||||
// to "v1"?
|
// to "v1"?
|
||||||
|
|
||||||
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
|
||||||
_ "k8s.io/kubernetes/pkg/apis/core/install"
|
_ "k8s.io/kubernetes/pkg/apis/core/install"
|
||||||
"k8s.io/kubernetes/pkg/features"
|
"k8s.io/kubernetes/pkg/features"
|
||||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||||
@ -2386,70 +2385,3 @@ func TestTruncatePodHostname(t *testing.T) {
|
|||||||
assert.Equal(t, test.output, output)
|
assert.Equal(t, test.output, output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPodResourcesAreReclaimed(t *testing.T) {
|
|
||||||
|
|
||||||
type args struct {
|
|
||||||
pod *v1.Pod
|
|
||||||
status v1.PodStatus
|
|
||||||
runtimeStatus kubecontainer.PodStatus
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
args args
|
|
||||||
want bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
"pod with running containers",
|
|
||||||
args{
|
|
||||||
pod: &v1.Pod{},
|
|
||||||
status: v1.PodStatus{
|
|
||||||
ContainerStatuses: []v1.ContainerStatus{
|
|
||||||
runningState("containerA"),
|
|
||||||
runningState("containerB"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"pod with containers in runtime cache",
|
|
||||||
args{
|
|
||||||
pod: &v1.Pod{},
|
|
||||||
status: v1.PodStatus{},
|
|
||||||
runtimeStatus: kubecontainer.PodStatus{
|
|
||||||
ContainerStatuses: []*kubecontainer.ContainerStatus{
|
|
||||||
{},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"pod with sandbox present",
|
|
||||||
args{
|
|
||||||
pod: &v1.Pod{},
|
|
||||||
status: v1.PodStatus{},
|
|
||||||
runtimeStatus: kubecontainer.PodStatus{
|
|
||||||
SandboxStatuses: []*runtimeapi.PodSandboxStatus{
|
|
||||||
{},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
testKubelet := newTestKubelet(t, false)
|
|
||||||
defer testKubelet.Cleanup()
|
|
||||||
kl := testKubelet.kubelet
|
|
||||||
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
testKubelet.fakeRuntime.PodStatus = tt.args.runtimeStatus
|
|
||||||
if got := kl.PodResourcesAreReclaimed(tt.args.pod, tt.args.status); got != tt.want {
|
|
||||||
t.Errorf("PodResourcesAreReclaimed() = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user