LDM as provisioner of debug-enabled containers by MEPalma · Pull Request #12824 · localstack/localstack · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

LDM as provisioner of debug-enabled containers #12824

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

MEPalma
Copy link
Contributor

@MEPalma MEPalma commented Jul 2, 2025

Motivation

The current LDM implementation depends heavily on the Lambda service’s container provisioning logic, injecting LDM-specific parameter overrides throughout various parts of the service to support debug-enabled containers. This fragmented integration makes LDM difficult to maintain and limits control over the lifecycle of debug-enabled containers. This refactor centralizes LDM responsibilities by transforming it into a dedicated provisioner for debug-enabled containers. As a result, the Lambda service is relieved of most LDM-related logic. Additionally, these changes ensure that debug-enabled containers persist across multiple invocations, allowing the debug client to remain connected or reconnect after disconnections.

Changes

  • LDM as a debug-enabled container provisioner
  • removed LDM fragments in the lambda provider
  • introduce new ExecutionEnvironment subtype for container-enabled execution environments
  • avoid container restarts between debug invokes, for compatibility python lambda functions must include a revised debug server logic:
def handler(event, context):
    print(event)
    return event

def wait_for_debug_client(port: int=19891, timeout: int=3600):
    import time, threading
    import sys, glob
    sys.path.append(glob.glob(".venv/lib/python*/site-packages")[0])
    import debugpy

    if not hasattr(wait_for_debug_client, "_debugpy_listening"):
        wait_for_debug_client._debugpy_listening = False

    if not wait_for_debug_client._debugpy_listening:
        try:
            debugpy.listen(("0.0.0.0", port))
            wait_for_debug_client._debugpy_listening = True
            print(f"debugpy is now listening on port {port}")
        except RuntimeError as e:
            print(f"debugpy.listen() failed or already active: {e}")

    if not debugpy.is_client_connected():
        print("Waiting for client to attach debugger...")

        def cancel_wait():
            time.sleep(timeout)
            print("Canceling debug wait task after timeout...")
            debugpy.wait_for_client.cancel()

        threading.Thread(target=cancel_wait, daemon=True).start()
        debugpy.wait_for_client()
    else:
        print("Debugger already attached.")

wait_for_debug_client()
  • several other related changes

@MEPalma MEPalma added this to the Playground milestone Jul 2, 2025
@MEPalma MEPalma self-assigned this Jul 2, 2025
@MEPalma MEPalma added the semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases label Jul 2, 2025
Copy link

github-actions bot commented Jul 2, 2025

Test Results - Preflight, Unit

21 795 tests  ±0   20 138 ✅ ±0   6m 18s ⏱️ ±0s
     1 suites ±0    1 657 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit 3feac01. ± Comparison against base commit fdef993.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jul 2, 2025

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 11s ⏱️ -8s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit 3feac01. ± Comparison against base commit fdef993.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jul 2, 2025

Test Results (amd64) - Integration, Bootstrap

    5 files      5 suites   2h 24m 13s ⏱️
5 270 tests 4 342 ✅ 928 💤 0 ❌
5 276 runs  4 342 ✅ 934 💤 0 ❌

Results for commit 3feac01.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jul 2, 2025

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   1h 45m 47s ⏱️ + 2m 39s
4 913 tests +1  4 137 ✅ +1  776 💤 ±0  0 ❌ ±0 
4 915 runs  +1  4 137 ✅ +1  778 💤 ±0  0 ❌ ±0 

Results for commit 3feac01. ± Comparison against base commit fdef993.

♻️ This comment has been updated with latest results.

@gregfurman gregfurman force-pushed the MEP-LDM-LDM_as_provisioner branch from 32e729d to fec91f6 Compare July 2, 2025 10:07
Copy link
Contributor

@gregfurman gregfurman left a comment

Choose a reason for hiding this comment

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

LGTM! Did you run an LDM flow manually to verify all works fine? Also, I did a rebase since I wanted to do a full run against pro and some changes were not present in your branch.

Happy to merge once we have:

  • A green pro CI run.
  • Manual verification of LDM.


if not lambda_arn:
return lambda_arn
lambda_arn_parts = lambda_arn.split(":")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Should we not specifically be checking if the service is lambda? Perhaps we should use api_utils.function_locators_from_arn or localstack.utils.aws.arns.parse_arn.

@MEPalma MEPalma marked this pull request as ready for review July 2, 2025 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.