Skip to content

LDM as provisioner of debug-enabled containers #12851

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

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

MEPalma
Copy link
Contributor

@MEPalma MEPalma commented Jul 10, 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 10, 2025
@MEPalma MEPalma self-assigned this Jul 10, 2025
@MEPalma MEPalma added the semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases label Jul 10, 2025
Copy link

Test Results - Preflight, Unit

21 854 tests  ±0   20 197 ✅ ±0   6m 15s ⏱️ +3s
     1 suites ±0    1 657 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit 90030a5. ± Comparison against base commit f0f8045.

Copy link

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 9s ⏱️ +2s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit 90030a5. ± Comparison against base commit f0f8045.

Copy link

Test Results (amd64) - Integration, Bootstrap

    5 files      5 suites   2h 23m 0s ⏱️
5 282 tests 4 353 ✅ 929 💤 0 ❌
5 288 runs  4 353 ✅ 935 💤 0 ❌

Results for commit 90030a5.

Copy link

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   1h 43m 27s ⏱️ - 2m 45s
4 923 tests ±0  4 147 ✅ ±0  776 💤 ±0  0 ❌ ±0 
4 925 runs  ±0  4 147 ✅ ±0  778 💤 ±0  0 ❌ ±0 

Results for commit 90030a5. ± Comparison against base commit f0f8045.

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.

1 participant