-
Notifications
You must be signed in to change notification settings - Fork 90
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
Port matching is breaks when docker-compose ps output changes #411
Comments
A good way to solve this problem would be to use the output of
Which will return This lets the regex keep working as expected |
Am working on a fix, will PR when its ready |
@hirochri Nice problem breakdown, I'm actually amazed the regex approach has lasted this long. Please tag me in the PR/message me internally when you need a review. |
Unfortunately I am still seeing this issue on my local machine using docker-compose-rule 1.4.2 which has the fix from #424. macOS Mojave 10.14.6 Example docker ps output when debugging docker-compose-rule:
|
Hopefully this should be fixed in docker-compose 1.25.2, which has the release note:
Docker for mac 2.2.0.0 is scheduled for release will include this fixed version of docker-compose. I think this only affects people on the edge channel of Docker-for-mac. |
Switched back from edge (docker-compose 1.25.1-rc1) to stable (docker-compose 1.25.2) and don't see the issue anymore! |
What happened?
I was using the docker compose rule and found that after adding health checks to my
docker-compose.yml
the docker compose rule fails because it cannot it can't find the internal port for a random container and then triggers this exception:docker-compose-rule/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/Container.java
Line 91 in a2adeae
Did some digging, and came to the conclusion that this breaks because there is some flawed logic in the parsing of the ports from
docker-compose
output.We grab the process output from running
docker-compose ps
here and pass it into theparseFromDockerComposePs
method:docker-compose-rule/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/execution/DefaultDockerCompose.java
Line 228 in 446e363
Within
parseFromDockerComposePs
, a regex is used to match the ports within the outputdocker-compose-rule/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/Ports.java
Line 30 in f07795c
When there are no health checks within the
docker-compose.yml
, the output often looks like this:Here the regex matches successfully and pulls port
1234
out of0.0.0.0:1234->1234/tcp
When there are health checks, the output for
docker-compose ps
gets shifted and truncated at a random spot, causing the port information to be split across multiple lines:This makes it so that the regex is unable to be matched, so no ports are returned from
parseFromDockerComposePs
, and then the entire docker compose rule fails (as mentioned above).Here is a test case that confirms this is the issue:
What did you want to happen?
The parsing of the ports from the command line output should not fail because the whitespacing changed, it should be clever enough to pull out the port information from the output (since all the information is there). Either we do some manipulation of the output coming from
docker-compose ps
, or make the regex that parses it do a little moreThe text was updated successfully, but these errors were encountered: