mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Merge pull request #67017 from bart0sh/PR0027-kubeadm-fix-CRI-ListKubeContainers
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. kubeadm: fix CRI ListKubeContainers API **What this PR does / why we need it**: Current implementation of this API always returns checks output of 'crictl pods -q' and filters out everything that doesn't start with k8s_. 'crictl pods -q' returns only pod ids, so everything is always filtered out. Removing filtering by name prefix should fix this. **Which issue this PR fixes** Fixes: kubernetes/kubeadm#926 **Release note**: ```release-note NONE ```
This commit is contained in:
commit
95307254e4
@ -248,12 +248,10 @@ func TestRemoveContainers(t *testing.T) {
|
|||||||
fcmd := fakeexec.FakeCmd{
|
fcmd := fakeexec.FakeCmd{
|
||||||
CombinedOutputScript: []fakeexec.FakeCombinedOutputAction{
|
CombinedOutputScript: []fakeexec.FakeCombinedOutputAction{
|
||||||
func() ([]byte, error) { return []byte("id1\nid2"), nil },
|
func() ([]byte, error) { return []byte("id1\nid2"), nil },
|
||||||
},
|
func() ([]byte, error) { return []byte(""), nil },
|
||||||
RunScript: []fakeexec.FakeRunAction{
|
func() ([]byte, error) { return []byte(""), nil },
|
||||||
func() ([]byte, []byte, error) { return nil, nil, nil },
|
func() ([]byte, error) { return []byte(""), nil },
|
||||||
func() ([]byte, []byte, error) { return nil, nil, nil },
|
func() ([]byte, error) { return []byte(""), nil },
|
||||||
func() ([]byte, []byte, error) { return nil, nil, nil },
|
|
||||||
func() ([]byte, []byte, error) { return nil, nil, nil },
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
fexec := fakeexec.FakeExec{
|
fexec := fakeexec.FakeExec{
|
||||||
|
@ -108,10 +108,8 @@ func (runtime *CRIRuntime) ListKubeContainers() ([]string, error) {
|
|||||||
}
|
}
|
||||||
pods := []string{}
|
pods := []string{}
|
||||||
for _, pod := range strings.Fields(string(out)) {
|
for _, pod := range strings.Fields(string(out)) {
|
||||||
if strings.HasPrefix(pod, "k8s_") {
|
|
||||||
pods = append(pods, pod)
|
pods = append(pods, pod)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return pods, nil
|
return pods, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ func TestIsRunning(t *testing.T) {
|
|||||||
func TestListKubeContainers(t *testing.T) {
|
func TestListKubeContainers(t *testing.T) {
|
||||||
fcmd := fakeexec.FakeCmd{
|
fcmd := fakeexec.FakeCmd{
|
||||||
CombinedOutputScript: []fakeexec.FakeCombinedOutputAction{
|
CombinedOutputScript: []fakeexec.FakeCombinedOutputAction{
|
||||||
func() ([]byte, error) { return []byte("k8s_p1\nk8s_p2\nid3"), nil },
|
func() ([]byte, error) { return []byte("k8s_p1\nk8s_p2"), nil },
|
||||||
func() ([]byte, error) { return nil, &fakeexec.FakeExitError{Status: 1} },
|
func() ([]byte, error) { return nil, &fakeexec.FakeExitError{Status: 1} },
|
||||||
func() ([]byte, error) { return []byte("k8s_p1\nk8s_p2"), nil },
|
func() ([]byte, error) { return []byte("k8s_p1\nk8s_p2"), nil },
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user