-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Add Docker Debugging Fixture #21357
Add Docker Debugging Fixture #21357
Conversation
- DEBUG_CONTAINER_IMAGE=${DEBUG_CONTAINER_IMAGE} | ||
- DEBUG_CONTAINER_JAVA_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 | ||
server: | ||
# You will need to create a remote JVM debugging Run Configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally use the Ubuntu OS and never had issues with remote debugging (just added this var to the required dockerfile), but for MAC users there may be some issues with IPs. I've heard that this tool may help https://github.com/chipmk/docker-mac-net-connect
Maybe it would be worth also this link to notes. @suhomud knows better how it works on MAC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@etsybaev good call out, definitely need that tool for the mac setup
The intent of this change is that you would no longer need to make any changes to Dockerfile
s since those changes should never be committed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not have a better suggestion at this time so let's start with this approach. I highlighted a few changes so that it fits better within how we are reading configs currently, will be good for me once those are addressed.
*/ | ||
static List<String> localDebuggingOptions(final String containerName) { | ||
final boolean shouldAddDebuggerOptions = | ||
Optional.ofNullable(System.getenv("DEBUG_CONTAINER_IMAGE")).filter(StringUtils::isNotEmpty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add the environment lookups to
airbyte/airbyte-config/config-models/src/main/java/io/airbyte/config/EnvConfigs.java
Line 38 in fca3940
public class EnvConfigs implements Configs { |
For context, all the config goes through EnvConfigs
, we're in the process of migrating to micronaut which should also be handling configuration for us: https://github.com/airbytehq/airbyte/blob/master/airbyte-workers/src/main/resources/application.yml. I am thinking airbyte.container.docker.debug-container-java-opts
might make sense for the time being.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opting to not implement this change - this is for debugging only and probably should be more broadly integrated into the standard execution process. Could add as a follow on
.map(ProcessFactory.extractShortImageName(containerName)::equals).orElse(false) | ||
&& Optional.ofNullable(System.getenv("DEBUG_CONTAINER_JAVA_OPTS")).isPresent(); | ||
if (shouldAddDebuggerOptions) { | ||
return List.of("-e", "JAVA_TOOL_OPTIONS=" + System.getenv("DEBUG_CONTAINER_JAVA_OPTS"), "-p5005:5005"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional: We may want to extract the port to a specific config as well.
.map(ProcessFactory.extractShortImageName(containerName)::equals).orElse(false) | ||
&& Optional.ofNullable(System.getenv("DEBUG_CONTAINER_JAVA_OPTS")).isPresent(); | ||
if (shouldAddDebuggerOptions) { | ||
return List.of("-e", "JAVA_TOOL_OPTIONS=" + System.getenv("DEBUG_CONTAINER_JAVA_OPTS"), "-p5005:5005"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not entirely sure how this JAVA_TOOL_OPTIONS=X
is getting rebuilt, do we need some extra quotes here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its ok as is, this is all getting passed into a command List/Array to be sent to the docker run command. Specifically not using JAVA_TOOL_OPTIONS
as the env variable so that the container which is running this doesn't try and process it, but the result of this command should effectively be a List with 3 strings
/** | ||
* !! ONLY FOR DEBUGGING, SHOULD NOT BE USED IN PRODUCTION !! If you set the DEBUG_CONTAINER_IMAGE | ||
* environment variable, and it matches the image name of a spawned container, this method will add | ||
* the necessary params to connect a debugger. For example, to enable this for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be worth adding this information to some dev docs if you know where they are, quick search sent me through all the specific connector's readme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll poke around and see if I can find a good docs home
Airbyte Code Coverage
|
What
Add options to allow for Environment Variables to set debugging options on docker containers
How
Docker Compose can inherit environment variables from the host as well as compose multiple yaml files together. For multivalue (lists) in Docker compose it will concat the values together. By adding additional environment variables in the
docker-compose.debug.yaml
we can add additonal options which are not activated with the standarddocker-compose.yaml
.This approach also does not require rebuilding the image since the environment variables are passed in at runtime.