Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions internal/lib/container_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,6 @@ func (c *ContainerServer) ReserveContainerName(id, name string) (string, error)
return name, nil
}

// ContainerIDForName gets the container ID given the container name from the ID Index
func (c *ContainerServer) ContainerIDForName(name string) (string, error) {
return c.ctrNameIndex.Get(name)
}

// ReleaseContainerName releases a container name from the index so that it can
// be used by other containers
func (c *ContainerServer) ReleaseContainerName(name string) {
Expand All @@ -526,11 +521,6 @@ func (c *ContainerServer) ReleasePodName(name string) {
c.podNameIndex.Release(name)
}

// PodIDForName gets the pod ID given the pod name from the ID Index
func (c *ContainerServer) PodIDForName(name string) (string, error) {
return c.podNameIndex.Get(name)
}

// recoverLogError recovers a runtime panic and logs the returned error if
// existing
func recoverLogError() {
Expand Down
9 changes: 0 additions & 9 deletions server/container_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,6 @@ func (s *Server) CreateContainer(ctx context.Context, req *types.CreateContainer
}()

if _, err = s.ReserveContainerName(ctr.ID(), ctr.Name()); err != nil {
reservedID, getErr := s.ContainerIDForName(ctr.Name())
if getErr != nil {
return nil, fmt.Errorf("failed to get ID of container with reserved name (%s), after failing to reserve name with %v: %w", ctr.Name(), getErr, getErr)
}
// if we're able to find the container, and it's created, this is actually a duplicate request
// from a client that does not behave like the kubelet (like crictl)
if reservedCtr := s.GetContainer(reservedID); reservedCtr != nil && reservedCtr.Created() {
return nil, err
}
cachedID, resourceErr := s.getResourceOrWait(ctx, ctr.Name(), "container")
if resourceErr == nil {
return &types.CreateContainerResponse{ContainerId: cachedID}, nil
Expand Down
9 changes: 0 additions & 9 deletions server/sandbox_run_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,15 +363,6 @@ func (s *Server) runPodSandbox(ctx context.Context, req *types.RunPodSandboxRequ
}()

if _, err := s.ReservePodName(sbox.ID(), sbox.Name()); err != nil {
reservedID, getErr := s.PodIDForName(sbox.Name())
if getErr != nil {
return nil, fmt.Errorf("failed to get ID of pod with reserved name (%s), after failing to reserve name with %v: %w", sbox.Name(), getErr, getErr)
}
// if we're able to find the sandbox, and it's created, this is actually a duplicate request
// from a client that does not behave like the kubelet (like crictl)
if reservedSbox := s.GetSandbox(reservedID); reservedSbox != nil && reservedSbox.Created() {
return nil, err
}
cachedID, resourceErr := s.getResourceOrWait(ctx, sbox.Name(), "sandbox")
if resourceErr == nil {
return &types.RunPodSandboxResponse{PodSandboxId: cachedID}, nil
Expand Down
18 changes: 0 additions & 18 deletions test/timeout.bats
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,6 @@ function wait_clean() {
crictl runp "$TESTDATA"/sandbox_config.json
}

@test "should not wait for actual duplicate pod request" {
start_crio
crictl runp "$TESTDATA"/sandbox_config.json
SECONDS=0
! crictl runp "$TESTDATA"/sandbox_config.json
[[ "$SECONDS" -lt 240 ]]
}

@test "should clean up container after timeout if not re-requested" {
start_crio
pod_id=$(crictl runp "$TESTDATA"/sandbox_config.json)
Expand Down Expand Up @@ -229,13 +221,3 @@ function wait_clean() {
! crictl exec --sync "$created_ctr_id" ls
! crictl inspect "$created_ctr_id"
}

@test "should not wait for actual duplicate container request" {
start_crio
pod_id=$(crictl runp "$TESTDATA"/sandbox_config.json)

crictl create "$pod_id" "$TESTDATA"/container_config.json "$TESTDATA"/sandbox_config.json
SECONDS=0
! crictl create "$pod_id" "$TESTDATA"/container_config.json "$TESTDATA"/sandbox_config.json
[[ "$SECONDS" -lt 240 ]]
}