こんな事象が発生した
あるプロダクトをcloneしてテスト実行しようと思ったら↓のようなエラーが発生した。
$ sam local invoke "${FUNC}" -e event.json
Traceback (most recent call last):
File "/usr/local/Cellar/aws-sam-cli/0.15.0/libexec/lib/python3.7/site-packages/urllib3/connectionpool.py", line 384, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "/usr/local/Cellar/aws-sam-cli/0.15.0/libexec/lib/python3.7/site-packages/urllib3/connectionpool.py", line 380, in _make_request
httplib_response = conn.getresponse()
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1321, in getresponse
response.begin()
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 296, in begin
version, status, reason = self._read_status()
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 257, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 589, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out
During handling of the above exception, another exception occurred:
~ 省略 ~
File "/usr/local/Cellar/aws-sam-cli/0.15.0/libexec/lib/python3.7/site-packages/docker/api/client.py", line 230, in _get
return self.get(url, **self._set_request_timeout(kwargs))
File "/usr/local/Cellar/aws-sam-cli/0.15.0/libexec/lib/python3.7/site-packages/requests/sessions.py", line 546, in get
return self.request('GET', url, **kwargs)
File "/usr/local/Cellar/aws-sam-cli/0.15.0/libexec/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/Cellar/aws-sam-cli/0.15.0/libexec/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/local/Cellar/aws-sam-cli/0.15.0/libexec/lib/python3.7/site-packages/requests/adapters.py", line 529, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)
ちなみに環境はこんな感じ
$ sam --version
SAM CLI, version 0.15.0
$ python -V
Python 3.7.0
$ docker -v
Docker version 18.09.2, build 6247962
何ぞこれ?
→ docker がおかしくなると起きる現象のよう
解決策
docker をrestartしたら動くようになった
$ sam local invoke "${FUNC}" -e event.json
2019-05-08 18:55:04 Found credentials in shared credentials file: ~/.aws/credentials
2019-05-08 18:55:04 Invoking hello-world (go1.x)
Fetching lambci/lambda:go1.x Docker container image.................................................................................................................................................................................................... ..................................................................................................
2019-05-08 18:55:40 Mounting /workspace/hello-world as /var/task:ro,delegated inside runtime container
START RequestId: 74e4d6a4-3f61-1dcb-c4bd-f8ec32da4504 Version: $LATEST
[SUCCESS] event doing!! - ObjectCreated:Put
[aws:s3 - 1970-01-01 00:00:00 +0000 UTC] Bucket = test.secondly, Key = app/test.json
END RequestId: 74e4d6a4-3f61-1dcb-c4bd-f8ec32da4504
REPORT RequestId: 74e4d6a4-3f61-1dcb-c4bd-f8ec32da4504 Duration: 4.49 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 6 MB
null