Skip to content

feat: add python remote debug support#138

Open
morgan-dgk wants to merge 13 commits into
GoogleCloudPlatform:developmentfrom
morgan-dgk:feat/add-python-remote-debug-support
Open

feat: add python remote debug support#138
morgan-dgk wants to merge 13 commits into
GoogleCloudPlatform:developmentfrom
morgan-dgk:feat/add-python-remote-debug-support

Conversation

@morgan-dgk

@morgan-dgk morgan-dgk commented May 28, 2026

Copy link
Copy Markdown

This pull request is based on #53. The majority of the changes introduced have been cherry-picked unchanged from that branch.

Some changes to the original commits included in #53 were required to resolve conflicts and bring the original feature branch up-to-date with the current state of the development branch.

Resolves #51.

All tests passed successfully.

Change-Id: Id1ab768dfaabb7868713ac238c8840406e2c98c0
GitOrigin-RevId: daf3412c40c0d2509e543470f02608b6c4761fe3
@morgan-dgk morgan-dgk changed the title Feat/add python remote debug support feat: add python remote debug support May 28, 2026
@morgan-dgk morgan-dgk force-pushed the feat/add-python-remote-debug-support branch 2 times, most recently from aa5a330 to d73ddc9 Compare May 28, 2026 03:31
@morgan-dgk

morgan-dgk commented May 28, 2026

Copy link
Copy Markdown
Author

Converting back to a draft, there are some permission issues related to postgres data folder for some reason when attempting to install openssh-server.

Was a local build caching issue 🥲, works as expected.

@morgan-dgk morgan-dgk marked this pull request as draft May 28, 2026 06:45
@morgan-dgk morgan-dgk marked this pull request as ready for review May 28, 2026 07:16
@morgan-dgk morgan-dgk force-pushed the feat/add-python-remote-debug-support branch from f6444d5 to b948b44 Compare June 2, 2026 06:14
@viktorl-dev

Copy link
Copy Markdown
Collaborator

Hi, Morgan. Thank you for the PR. I'm going to review it and provide some feedback.

Viktor

@viktorl-dev viktorl-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The PR looks good overall. Please address the comments above, and I think we'll be good to go.

Comment thread composer_local_dev/docker_files/entrypoint.sh Outdated
Comment thread composer_local_dev/docker_files/entrypoint.sh
Comment thread composer_local_dev/cli.py
Comment on lines +264 to +265
@option_enable_ssh
@option_ssh_port

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think it also makes sense to enable these 2 options for start and restart.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I've pushed up some changes that aim to address this.

I assume this requires modifying load_from_config and EnvironmentConfig to respect the value of these variables.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sure, the changes look good to me 👍

Comment thread composer_local_dev/environment.py Outdated
Comment thread README.md
Comment thread composer_local_dev/cli.py
Comment thread composer_local_dev/environment.py Outdated
@morgan-dgk

Copy link
Copy Markdown
Author

Thanks your feedback @viktorl-dev. I've addressed all of the above points with the exception of adding --enable-ssh and --ssh-port to the start and restart commands.

I've added my questions on that point above 🙂.

@morgan-dgk morgan-dgk force-pushed the feat/add-python-remote-debug-support branch from b907555 to 408d395 Compare June 4, 2026 01:04
strobil and others added 10 commits June 4, 2026 11:05
`install_and_run_sshd` previously failed as the base Airflow images do
not include the default ubuntu package repositories. As such, the
openssh-server package could not be found.

Additionally, the ssh_host_keys generated by sshd are owned by root.
This causes permission related failures since the container runs as user
airflow.
Also add these arguments to `start` and `restart` commands
@morgan-dgk morgan-dgk force-pushed the feat/add-python-remote-debug-support branch from 408d395 to a2ea548 Compare June 4, 2026 01:05
@morgan-dgk morgan-dgk requested a review from viktorl-dev June 4, 2026 23:13
@ahidalgob ahidalgob requested review from ahidalgob and removed request for viktorl-dev June 9, 2026 09:49

@viktorl-dev viktorl-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I've added a few more comments. A quick summary of next steps:

  1. Fixing these issues may cause some existing tests to break, so please verify them.
  2. Do you think we should add additional test cases for the new features?

Comment thread composer_local_dev/environment.py Outdated
# By default, the container runs as the user `airflow` with UID 999. Set
# this env variable to "True" to make it run as the current host user.
"COMPOSER_CONTAINER_RUN_AS_HOST_USER": "False",
"COMPOSER_CONTAINER_ENABLE_SSHD": str(enable_ssh),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd suggest making the naming consistent: if we add an option named --enable-ssh, the corresponding environment variable should also be named COMPOSER_CONTAINER_ENABLE_SSH

Comment thread composer_local_dev/environment.py Outdated
Comment on lines +393 to +406
if "enable_ssh" in self.config:
self.enable_ssh = (
enable_ssh
if enable_ssh is not None
else self.get_str_param("enable_ssh")
)
self.ssh_port = (
ssh_port
if ssh_port is not None
else self.parse_int_param("ssh_port", allowed_range=(0, 65536))
)
else:
self.enable_ssh = False
self.ssh_port = None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks a bit convoluted. I suggest refactoring it as follows:

        self.enable_ssh = self.config.get("enable_ssh", constants.DEFAULT_ENABLE_SSH)
        self.ssh_port = self.config.get("ssh_port", constants.DEFAULT_SSH_PORT)

        if enable_ssh is not None:
            self.enable_ssh = enable_ssh

        if ssh_port is not None:
            self.ssh_port = ssh_port

So you'd also need to add DEFAULT_ENABLE_SSH = False to constants.py

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I just realized I missed this part in my suggestion:

self.parse_int_param("ssh_port", allowed_range=(0, 65536))

Could you please incorporate this.

P.S.: though it should be 65535 and not 65536. Yeah, I can see there are many places with the same wrong number. We'll handle this later on.

Comment thread composer_local_dev/environment.py Outdated
self.database_engine == constants.DatabaseEngine.sqlite3
)
self.port: int = port if port is not None else 8080
self.enable_ssh: bool = enable_ssh

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd suggest setting it to the default value as well:

Suggested change
self.enable_ssh: bool = enable_ssh
self.enable_ssh: bool = enable_ssh if enable_ssh is not None else constants.DEFAULT_ENABLE_SSH

@morgan-dgk

Copy link
Copy Markdown
Author

@viktorl-dev I've made the required changes and confirmed that the existing tests continue to pass.

@morgan-dgk

Copy link
Copy Markdown
Author

I see periodic failures starting the database container:

Failed to log action (psycopg2.OperationalError) could not translate 
host name "composer-local-dev-db-testenv" to address: Name or service not known

Unsure why this is occuring.

sudo chown -R airflow:airflow "$FAST_API_DIR"
fi

if [ "${COMPOSER_CONTAINER_ENABLE_SSHD}" = "True" ]; then

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Here, a variable hasn't been renamed. What is more interesting is that all tests are green even with this "not yet renamed" variable. Could you please add a test case that specifically catches this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants