8000 Additional debugging for network connection failure by dfangl · Pull Request #8602 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content
8000

Additional debugging for network connection failure #8602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 4, 2023
Merged
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
15 changes: 5 additions & 10 deletions localstack/services/awslambda/invocation/lambda_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from abc import ABCMeta, abstractmethod
from datetime import datetime
from pathlib import Path
from typing import IO, TYPE_CHECKING, Dict, Optional, TypedDict
from typing import IO, Dict, Optional, TypedDict

from botocore.exceptions import ClientError

Expand All @@ -31,14 +31,11 @@
StateReasonCode,
TracingMode,
)
from localstack.aws.connect import connect_to
from localstack.services.awslambda.api_utils import qualified_lambda_arn, unqualified_lambda_arn
from localstack.utils.archives import unzip
from localstack.utils.aws import aws_stack
from localstack.utils.strings import long_uid

if TYPE_CHECKING:
from mypy_boto3_s3 import S3Client

LOG = logging.getLogger(__name__)

# To add support for a new runtime, just add it here with the accompanying image postfix
Expand Down Expand Up @@ -168,7 +165,7 @@ def _download_archive_to_file(self, target_file: IO) -> None:

:param target_file: File the code archive should be downloaded into (IO object)
"""
s3_client: "S3Client" = aws_stack.connect_to_service("s3", region_name="us-east-1")
s3_client = connect_to(region_name="us-east-1").s3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sneaky

extra_args = {"VersionId": self.s3_object_version} if self.s3_object_version else {}
s3_client.download_fileobj(
Bucket=self.s3_bucket, Key=self.s3_key, Fileobj=target_file, ExtraArgs=extra_args
Expand All @@ -179,9 +176,7 @@ def generate_presigned_url(self, endpoint_url: str | None = None) -> str:
"""
Generates a presigned url pointing to the code archive
"""
s3_client: "S3Client" = aws_stack.connect_to_service(
"s3", region_name="us-east-1", endpoint_url=endpoint_url
)
s3_client = connect_to(region_name="us-east-1", endpoint_url=endpoint_url).s3
params = {"Bucket": self.s3_bucket, "Key": self.s3_key}
if self.s3_object_version:
params["VersionId"] = self.s3_object_version
Expand Down Expand Up @@ -239,7 +234,7 @@ def destroy(self) -> None:
"""
LOG.debug("Final code destruction for %s", self.id)
self.destroy_cached()
s3_client: "S3Client" = aws_stack.connect_to_service("s3", region_name="us-east-1")
s3_client = connect_to(region_name="us-east-1").s3
kwargs = {"VersionId": self.s3_object_version} if self.s3_object_version else {}
try:
s3_client.delete_object(Bucket=self.s3_bucket, Key=self.s3_key, **kwargs)
Expand Down
18 changes: 13 additions & 5 deletions localstack/utils/container_utils/container_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,11 @@ class ContainerConfiguration:
command: Optional[List[str]] = None
env_vars: Dict[str, str] = dataclasses.field(default_factory=dict)

privileged: Optional[bool] = None
remove: Optional[bool] = None
interactive: Optional[bool] = None
tty: Optional[bool] = None
detach: Optional[bool] = None
privileged: bool = False
remove: bool = False
interactive: bool = False
tty: bool = False
detach: bool = False

stdin: Optional[str] = None
user: Optional[str] = None
Expand Down Expand Up @@ -492,6 +492,14 @@ def get_container_ipv4_for_network(
network_attrs = self.inspect_network(container_network)
containers = network_attrs.get("Containers") or {}
if container_id not in containers:
LOG.debug("Network attributes: %s", network_attrs)
try:
inspection = self.inspect_container(container_name_or_id=container_name_or_id)
LOG.debug("Container %s Attributes: %s", container_name_or_id, inspection)
logs = self.get_container_logs(container_name_or_id=container_name_or_id)
LOG.debug("Container %s Logs: %s", container_name_or_id, logs)
except ContainerException as e:
LOG.debug("Cannot inspect container %s: %s", container_name_or_id, e)
raise ContainerException(
"Container %s is not connected to target network %s",
container_name_or_id,
Expand Down
0