Skip to content
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

Endpoint empty error #78

Open
didacrarbones opened this issue Feb 16, 2022 · 5 comments
Open

Endpoint empty error #78

didacrarbones opened this issue Feb 16, 2022 · 5 comments

Comments

@didacrarbones
Copy link

On a windows system, the endpoint command returns a weird string:

0.0.0.0:9997\r\n�[0m

That's why the strip here does not change the string, and this line takes the garbage part. I have solved it by using a regexp:

ips = re.findall(r'[0-9]+(?:\.[0-9]+){3}:[0-9]+', endpoint)
assert len(ips) == 1
endpoint = ips[0]

Do you think this is a possible solution that could be merged in?

@n1ngu
Copy link
Contributor

n1ngu commented Feb 16, 2022

Looks like probably an escape character followed by a "reset color" shell sequence.

AFAIU the underlying subprocess shouldn't be using any decorations you have in your shell. Does your docker setup have some kind of colored output plugin?

@langustav
Copy link

langustav commented Apr 21, 2022

I have run into the same issue. However, the problem is not with strip() but with following statement
https://github.com/avast/pytest-docker/blob/master/src/pytest_docker/plugin.py#L87
It can been due to Windows 11. However, it is still bug on pytest_docker (and it is mentioned in the code that line 87 should handle a messy output. But the messy output has changed :) )
I would suggest similar solution. However, without assert (since it is not according to Python standards).
I do not use any colored output plugin. Simple Docker desktop with default settings.

@langustav
Copy link

langustav commented Apr 21, 2022

My proposal with proper exception handling would be something like this.
Replacement for lines 86-87 :

ips = re.findall(r'[0-9]{1,3}(?:\.[0-9]{1,3}){3}:[0-9]{1,5}', endpoint)
if len(ips) == 0:
    raise ValueError(f'Could not found any IP in endpoint {endpoint} for "{service}:{container_port}"')
if len(ips) > 1:
    raise ValueError(f'Found more IPs ({",".join(ips)}) in endpoint {endpoint} for "{service}:{container_port}". '
                              f'Could not decided which port to use. ')
endpoint = ips[0]

However, there could be a problem if this endpoint will be in format: esfasf312sd:5664 (i.e., usage of hostname instead of IP). Also switching to IPv6 will be problematic with this approach.

@gbroll
Copy link

gbroll commented May 2, 2022

I have the same problem on win10, getting some weird output on line 78 (b'\r\n\x1b[0m')
Running Docker Desktop 4.7.1 (77678) and docker-compose version 1.29.2, build 5becea4c

@langustav
Copy link

I have created a pull request for this issue:
#81

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

No branches or pull requests

4 participants