mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 23:37:01 +00:00
kubeadm: fix CRI ListKubeContainers API
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. Fixes: kubernetes/kubeadm#926
This commit is contained in:
parent
db9545e69e
commit
d64f489fa1
@ -249,12 +249,10 @@ func TestRemoveContainers(t *testing.T) {
|
||||
fcmd := fakeexec.FakeCmd{
|
||||
CombinedOutputScript: []fakeexec.FakeCombinedOutputAction{
|
||||
func() ([]byte, error) { return []byte("id1\nid2"), nil },
|
||||
},
|
||||
RunScript: []fakeexec.FakeRunAction{
|
||||
func() ([]byte, []byte, error) { return nil, nil, nil },
|
||||
func() ([]byte, []byte, error) { return nil, nil, nil },
|
||||
func() ([]byte, []byte, error) { return nil, nil, nil },
|
||||
func() ([]byte, []byte, error) { return nil, nil, nil },
|
||||
func() ([]byte, error) { return []byte(""), nil },
|
||||
func() ([]byte, error) { return []byte(""), nil },
|
||||
func() ([]byte, error) { return []byte(""), nil },
|
||||
func() ([]byte, error) { return []byte(""), nil },
|
||||
},
|
||||
}
|
||||
fexec := fakeexec.FakeExec{
|
||||
|
@ -108,9 +108,7 @@ func (runtime *CRIRuntime) ListKubeContainers() ([]string, error) {
|
||||
}
|
||||
pods := []string{}
|
||||
for _, pod := range strings.Fields(string(out)) {
|
||||
if strings.HasPrefix(pod, "k8s_") {
|
||||
pods = append(pods, pod)
|
||||
}
|
||||
pods = append(pods, pod)
|
||||
}
|
||||
return pods, nil
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ func TestIsRunning(t *testing.T) {
|
||||
func TestListKubeContainers(t *testing.T) {
|
||||
fcmd := fakeexec.FakeCmd{
|
||||
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 []byte("k8s_p1\nk8s_p2"), nil },
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user