Skip to content

Commit 0ee77a5

Browse files
hengyoushMandssS
authored andcommitted
fix user input complete container id issue
Signed-off-by: hengyoush <hengyoush1@163.com>
1 parent 11087a8 commit 0ee77a5

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

exec/container/controller.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"github.com/chaosblade-io/chaosblade-exec-cri/exec/container"
2727
"github.com/chaosblade-io/chaosblade-spec-go/util"
2828
"github.com/sirupsen/logrus"
29-
"k8s.io/api/core/v1"
29+
v1 "k8s.io/api/core/v1"
3030

3131
"github.com/chaosblade-io/chaosblade-spec-go/spec"
3232

@@ -161,7 +161,7 @@ func getMatchedContainerMetaList(pods []v1.Pod, containerIdsValue, containerName
161161
if expectedContainerId == "" {
162162
continue
163163
}
164-
if strings.HasPrefix(containerId, expectedContainerId) {
164+
if strings.HasPrefix(expectedContainerId, containerId) {
165165
if containerStatusErr != nil {
166166
return containerObjectMetaList, spec.ResponseFailWithFlags(spec.ParameterInvalid,
167167
model.ContainerIdsFlag.Name, expectedContainerId,

exec/model/executor_copy.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ package model
1919
import (
2020
"context"
2121
"fmt"
22+
"path"
23+
"sync"
24+
2225
"github.com/chaosblade-io/chaosblade-exec-cri/exec/container"
2326
"github.com/chaosblade-io/chaosblade-operator/channel"
2427
"github.com/chaosblade-io/chaosblade-operator/pkg/apis/chaosblade/v1alpha1"
@@ -30,8 +33,6 @@ import (
3033
v1 "k8s.io/api/core/v1"
3134
apierrors "k8s.io/apimachinery/pkg/api/errors"
3235
"k8s.io/apimachinery/pkg/types"
33-
"path"
34-
"sync"
3536
)
3637

3738
type ExperimentIdentifierInPod struct {

0 commit comments

Comments
 (0)