Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary / Problem
During test cleanup, stopping or killing containers (such as
tr-ct-dhcp-2ortr-ui) when they have already exited or stopped caused Docker to raise HTTP 409 Conflict (Container ... is not running). This resulted in erroneous error logging ("Container stop error") during standard cleanup.Linked Buganizer issue: b/496885581 ("[TR] Error during test cleanup: Attempting to kill non-running container tr-ct-dhcp-2").
Root Cause
docker_module.pyandnetwork_validator.pydid not checkcontainer.status == 'running'before callingcontainer.stop()orcontainer.kill(), or did not handledocker.errors.APIErrorgracefully when status code 409/304 was returned.testrun.py,_stop_uiunconditionally calledcontainer.kill()without verifying whether the container was running, and caught onlydocker.errors.NotFoundinstead of also handlingdocker.errors.APIError.Changes Made
framework/python/src/core/docker/docker_module.py:import docker.errors.stop(self, kill=False):if container.status == 'running':before stopping/killing.Container <container_name> is not running (status: <status>).docker.errors.NotFoundand log at DEBUG.docker.errors.APIError as error: iferror.status_code in (304, 409) or 'not running' in str(error).lower(), log at DEBUG:Container <container_name> is already stopped: <error>, otherwise log at ERROR.framework/python/src/net_orc/network_validator.py:import docker.errors._stop_network_device(self, net_device, kill=False):if container.status == 'running':before stopping/killing.Container <container_name> is not running (status: <status>).docker.errors.NotFoundand log at DEBUG.docker.errors.APIError as e: ife.status_code in (304, 409) or 'not running' in str(e).lower(), log at DEBUG:Container <container_name> is already stopped: <e>, otherwise log at ERROR.framework/python/src/core/testrun.py:_stop_ui(self):if container.status == 'running':before callingcontainer.kill().try/except, catch(docker.errors.NotFound, docker.errors.APIError): pass.Verification Plan
_stop_uiexits cleanly whethertr-uiis running, exited, or not found.pytest testing/unit/.Branch comparison against
dev: dev...fix-ai/container-stop-cleanup-496885581