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

Build Docker Image and Urllib3 - TypeError: object of type '_TemporaryFileWrapper' has no len() #1669

Closed
jeevanreddyg opened this issue Feb 14, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@jeevanreddyg
Copy link

Hi Team,

We are trying to build an image using docker python package and while building image, urllib3 throwing the below exception, could you please suggest a solution?

File "C:\Projects\POC\OpenTelemetry-Issue\main.py", line 8, in <module>
  image, logs = docker_client.images.build(
File "c:\Projects\POC\OpenTelemetry-Issue\venv\lib\site-packages\docker\models\images.py", line 298, in build
  resp = self.client.api.build(**kwargs)
File "c:\Projects\POC\OpenTelemetry-Issue\venv\lib\site-packages\docker\api\build.py", line 264, in build
  response = self._post(
File "c:\Projects\POC\OpenTelemetry-Issue\venv\lib\site-packages\docker\utils\decorators.py", line 46, in inner
  return f(self, *args, **kwargs)
File "c:\Projects\POC\OpenTelemetry-Issue\venv\lib\site-packages\docker\api\client.py", line 233, in _post
  return self.post(url, **self._set_request_timeout(kwargs))
File "c:\Projects\POC\OpenTelemetry-Issue\venv\lib\site-packages\requests\sessions.py", line 635, in post
  return self.request("POST", url, data=data, json=json, **kwargs)
File "c:\Projects\POC\OpenTelemetry-Issue\venv\lib\site-packages\requests\sessions.py", line 587, in request
  resp = self.send(prep, **send_kwargs)
File "c:\Projects\POC\OpenTelemetry-Issue\venv\lib\site-packages\requests\sessions.py", line 701, in send
  r = adapter.send(request, **kwargs)
File "c:\Projects\POC\OpenTelemetry-Issue\venv\lib\site-packages\requests\adapters.py", line 489, in send
  resp = conn.urlopen(
File "c:\Projects\POC\OpenTelemetry-Issue\venv\lib\site-packages\opentelemetry\instrumentation\urllib3\__init__.py", line 216, in instrumented_urlopen
  request_size = 0 if body is None else len(body)
TypeError: object of type '_TemporaryFileWrapper' has no len()

Steps to reproduce

  1. pip install the below packages
opentelemetry-distro==0.36b0
opentelemetry-distro[otlp]==0.36b0
opentelemetry-instrumentation-urllib3
docker
  1. Create any sample docker image (Dockerfile)
FROM ubuntu
WORKDIR /app
COPY . /app
  1. Run the below code snippet (main.py)
import docker
from opentelemetry.instrumentation.urllib3 import URLLib3Instrumentor
docker_client = docker.from_env()
URLLib3Instrumentor().instrument()
image, logs = docker_client.images.build(
            path=".",
            tag="test",
            dockerfile="Dockerfile",
        )

Note: It was working fine with version 0.30 but failing with recent versions.

@jeevanreddyg jeevanreddyg added the bug Something isn't working label Feb 14, 2023
@shalevr
Copy link
Member

shalevr commented Feb 14, 2023

Hi
It will be fixed in this PR:
#1399

@lzchen
Copy link
Contributor

lzchen commented Mar 28, 2023

@shalevr

Can this issue be closed?

@shalevr shalevr closed this as completed Mar 29, 2023
@jeevanreddyg
Copy link
Author

Thank you, we will verify and let you know if any issues are observed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants