From b4f7a2f1725a2bae0ff2e31a94a9eec96c892c66 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Tue, 2 Aug 2022 14:30:03 +0200 Subject: [PATCH] Revert "server: properly handle duplicate requests" This reverts commit 9c5eb67c3f11b450a1de56704ce31bd592356869. Signed-off-by: Sascha Grunert --- internal/lib/container_server.go | 10 ---------- server/container_create.go | 9 --------- server/sandbox_run_linux.go | 9 --------- test/timeout.bats | 18 ------------------ 4 files changed, 46 deletions(-) diff --git a/internal/lib/container_server.go b/internal/lib/container_server.go index 278a709c437..de25cad7075 100644 --- a/internal/lib/container_server.go +++ b/internal/lib/container_server.go @@ -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) { @@ -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() { diff --git a/server/container_create.go b/server/container_create.go index 90aac7a4081..0cba69cca96 100644 --- a/server/container_create.go +++ b/server/container_create.go @@ -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 diff --git a/server/sandbox_run_linux.go b/server/sandbox_run_linux.go index d1ec6b2d6f5..247ab30f678 100644 --- a/server/sandbox_run_linux.go +++ b/server/sandbox_run_linux.go @@ -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 diff --git a/test/timeout.bats b/test/timeout.bats index fbcdbdeb51b..1ab7a26199a 100644 --- a/test/timeout.bats +++ b/test/timeout.bats @@ -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) @@ -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 ]] -}