balena-io / balena-cli

The official balena CLI tool.
Apache License 2.0
454 stars 139 forks source link

Some services failed to build: error pulling image configuration , connection reset by peer #1441

Closed krasi-georgiev closed 5 years ago

krasi-georgiev commented 5 years ago

balena version 11.11.2

Linux Ubuntu installed from zip

DEBUG=1 balena push 192.168.0.113 --env DEBUG=1
[debug] original argv0="balena" argv=[/usr/local/balena/bin/balena,/snapshot/versioned-source/bin/balena,push,192.168.0.113,--env,DEBUG=1] length=6
[debug] Using . as build source
[Debug]   Checking we can access device
[Debug]   Sending request to http://192.168.0.113:48484/ping
[Debug]   Checking device version: 9.15.7
[Info]    Starting build on device 192.168.0.113
[Debug]   Loading project...
[Debug]   Resolving project...
[Info]    Compose file detected
[Debug]   Creating project...
[Debug]   Tarring all non-ignored files...
[Debug]   Sending request to http://192.168.0.113:48484/v2/local/device-info
[Debug]   Found build tasks:
[Debug]       env-config: image pull [arribada/env-config]
[Debug]       smart-postgres: image pull [arribada/smart-connect-postgis:v0.0.1]
[Debug]       smart-connect: image pull [arribada/smart-connect:v0.0.1]
[Debug]       lora-connect: image pull [arribada/lora-connect]
[Debug]       packet-forwarder: image pull [arribada/packet-forwarder]
[Debug]       loraserver: image pull [arribada/loraserver]
[Debug]       appserver: image pull [arribada/lora-app-server]
[Debug]       gatewaybridge: image pull [arribada/lora-gateway-bridge]
[Debug]       geoserver: image pull [arribada/lora-geo-server]
[Debug]       postgresql: image pull [postgres:9.6-alpine]
[Debug]       redis: image pull [redis:5-alpine]
[Debug]       mosquitto: image pull [eclipse-mosquitto]
[Debug]       prometheus: image pull [prom/prometheus]
[Debug]       alertmanager: image pull [prom/alertmanager]
[Debug]   Resolving services with [raspberrypi3|armv7hf]
[Debug]   Found project types:
[Debug]       env-config: External image
[Debug]       smart-postgres: External image
[Debug]       smart-connect: External image
[Debug]       lora-connect: External image
[Debug]       packet-forwarder: External image
[Debug]       loraserver: External image
[Debug]       appserver: External image
[Debug]       gatewaybridge: External image
[Debug]       geoserver: External image
[Debug]       postgresql: External image
[Debug]       redis: External image
[Debug]       mosquitto: External image
[Debug]       prometheus: External image
[Debug]       alertmanager: External image
[Debug]   Probing remote daemon for cache images
[Debug]   Using 52 on-device images for cache...
[Debug]   Starting builds...
Some services failed to build:
        packet-forwarder: error pulling image configuration: Get https://production.cloudflare.docker.com/registry-v2/docker/registry/v2/blobs/sha256/5f/5f2b15d4533c3a60c14bed2ff516fc14e8759fb44bd607868b8df95620266c4b/data?verify=1569088187-lYIjGTWxqjgNLmsIRtYW4KrHcww%3D: read tcp 192.168.0.113:54056->104.18.123.25:443: read: connection reset by peer
        loraserver: error pulling image configuration: Get https://production.cloudflare.docker.com/registry-v2/docker/registry/v2/blobs/sha256/e8/e883704977244cb517fa625bc0cc12c6b4cde5f7c7cab5b29fe1423e3af74eba/data?verify=1569088187-yLwW2w90cx1eBOXxTcVuyEn9D34%3D: read tcp 192.168.0.113:49742->104.18.124.25:443: read: connection reset by peer
        appserver: error pulling image configuration: Get https://production.cloudflare.docker.com/registry-v2/docker/registry/v2/blobs/sha256/1a/1a72660302f06248b2bf59ff306a7c863c9c812c4eca6425f12807fad49b17ca/data?verify=1569088187-i%2B7PUWNh1Y4qsteltmhE%2BZ7ZjOA%3D: read tcp 192.168.0.113:57664->104.18.121.25:443: read: connection reset by peer
        gatewaybridge: error pulling image configuration: Get https://production.cloudflare.docker.com/registry-v2/docker/registry/v2/blobs/sha256/98/98b53ab3430be6091e2330fe91822a7c717e414a4fadca62a15d27b0670beaab/data?verify=1569088187-4qVb6Fqhop4o%2FjfraBeBISTExVc%3D: read tcp 192.168.0.113:34362->104.18.122.25:443: read: connection reset by peer
        geoserver: error pulling image configuration: Get https://production.cloudflare.docker.com/registry-v2/docker/registry/v2/blobs/sha256/a0/a019cf2101fda1f9dd260da9bb54bdfbfe285b6136e0910135d0d32a6363bf68/data?verify=1569088187-hNgs6HggEKmACpVBErTQmGa%2Bl5w%3D: read tcp 192.168.0.113:52442->104.18.125.25:443: read: connection reset by peer
        postgresql: error pulling image configuration: Get https://production.cloudflare.docker.com/registry-v2/docker/registry/v2/blobs/sha256/22/22d8ccf526243d4a9492f794c971e40e36da0c6451e9125cb3eeb5a0680caa18/data?verify=1569088187-PCOeVmPL9EThmPPFEa0JkahfOqQ%3D: read tcp 192.168.0.113:49738->104.18.124.25:443: read: connection reset by peer
        mosquitto: error pulling image configuration: Get https://production.cloudflare.docker.com/registry-v2/docker/registry/v2/blobs/sha256/62/628263b0a8c9cb0c52aceafb7b2106230d2f8e205b0810c654d6fce85270be8d/data?verify=1569088187-%2B285%2FOgkuPcNn6eUPrl0Vn6dqlE%3D: read tcp 192.168.0.113:49744->104.18.124.25:443: read: connection reset by peer

let me know if you need anymore info

krasi-georgiev commented 5 years ago

just tested that if I remove the : it downloads the image mainfest data:

https://production.cloudflare.docker.com/registry-v2/docker/registry/v2/blobs/sha256/5f/5f2b15d4533c3a60c14bed2ff516fc14e8759fb44bd607868b8df95620266c4b/data?verify=1569088187-lYIjGTWxqjgNLmsIRtYW4KrHcww

pdcastro commented 5 years ago

It sounds like balenaEngine (the equivalent to the Docker daemon, running on a balena device -- I assume that 192.168.0.113 is a balena device) is getting "connection reset by peer" when it tries to download "external images". Can you confirm that either your docker-compose.yml file or your Dockerfiles are attempting to pull images from "cloudfare.docker.com"? Perhaps you could share the relevant lines from those files.

just tested that if I remove the : it downloads the image manifest data

Does this mean that you have found the problem, and solved it? Or perhaps this is just additional debugging information.

If the problem persists, could it be a matter of authentication? Are those images being pulled from a private Dockerhub-like repository that requires a username and password to download from? If so, check the following docs and use the --registry-secrets command-line option:

krasi-georgiev commented 5 years ago

It sounds like balenaEngine (the equivalent to the Docker daemon, running on a balena device -- I assume that 192.168.0.113 is a balena device) is getting "connection reset by peer" when it tries to download "external images". Can you confirm that either your docker-compose.yml file or your Dockerfiles are attempting to pull images from "cloudfare.docker.com"? Perhaps you could share the relevant lines from those files.

Here is the full compose file. You can simplify it even to a single service and it still throws the same error. https://github.com/arribada/SMARTLoraTracker/blob/b3679f0bd1bb7ae487f6fac669ad446b023342c1/receiver/docker-compose.yml

just tested that if I remove the : it downloads the image manifest data

Does this mean that you have found the problem, and solved it? Or perhaps this is just additional debugging information.

this is just additional debug info. It seems to me that balena cli is missing some url sanitization and it is sending the requests to the wrong url.

If the problem persists, could it be a matter of authentication? Are those images being pulled from a private Dockerhub-like repository that requires a username and password to download from?

nope these are all public images.

pdcastro commented 5 years ago

@krasi-georgiev, thanks for sharing the docker-compose.yml file. I have tried using it with balena-cli 11.11.2 (standalone zip package) on Ubuntu 18.04.3, pushing the project to a Raspberry Pi 3 running balenaOS 2.38.0+rev1, and the arribada/* images were downloaded without errors:

DEBUG=1 /mnt/data/cli/balena-cli-11.11.2/balena push 192.168.0.20 --env DEBUG=1
[debug] original argv0="/mnt/data/cli/balena-cli-11.11.2/balena" argv=[/mnt/data/cli/balena-cli-11.11.2/balena,/snapshot/versioned-source/bin/balena,push,192.168.0.20,--env,DEBUG=1] length=6
[debug] Using . as build source
[Debug]   Checking we can access device
[Debug]   Sending request to http://192.168.0.20:48484/ping
[Debug]   Checking device version: 9.15.7
[Info]    Starting build on device 192.168.0.20
[Debug]   Loading project...
[Debug]   Resolving project...
[Info]    Compose file detected
[Debug]   Creating project...
[Debug]   Tarring all non-ignored files...
[Debug]   Sending request to http://192.168.0.20:48484/v2/local/device-info
[Debug]   Found build tasks:
[Debug]       packet-forwarder: image pull [arribada/packet-forwarder]
[Debug]       loraserver: image pull [arribada/loraserver]
[Debug]   Resolving services with [raspberrypi3|armv7hf]
[Debug]   Found project types:
[Debug]       packet-forwarder: External image
[Debug]       loraserver: External image
[Debug]   Probing remote daemon for cache images
[Debug]   Using 11 on-device images for cache...
[Debug]   Starting builds...
[Build]   [loraserver] [>                                                  ]  90.15kB/8.822MB
...
[Build]   [loraserver] [==================================================>]  8.822MB/8.822MB
[Build]   [packet-forwarder] [>                                                  ]  473.8kB/45.92MB
...
[Build]   [packet-forwarder] [==================================================>]  45.92MB/45.92MB
[Debug]   Setting device state...
[Debug]   Sending request to http://192.168.0.20:48484/v2/local/target-state
[Debug]   Sending target state: {"local":{"name":"pi-sky","config":{"HOST_CONFIG_disable_splash":"1","HOST_CONFIG_dtparam":"\"i2c_arm=on\",\"spi=on\",\"audio=on\"","HOST_CONFIG_enable_uart":"1","HOST_CONFIG_gpu_mem":"192","SUPERVISOR_LOCAL_MODE":"1","SUPERVISOR_POLL_INTERVAL":"900000","SUPERVISOR_VPN_CONTROL":"true","SUPERVISOR_INSTANT_UPDATE_TRIGGER":"true","SUPERVISOR_CONNECTIVITY_CHECK":"true","SUPERVISOR_LOG_CONTROL":"true","SUPERVISOR_DELTA":"false","SUPERVISOR_DELTA_REQUEST_TIMEOUT":"30000","SUPERVISOR_DELTA_APPLY_TIMEOUT":"0","SUPERVISOR_DELTA_RETRY_COUNT":"30","SUPERVISOR_DELTA_RETRY_INTERVAL":"10000","SUPERVISOR_DELTA_VERSION":"2","SUPERVISOR_OVERRIDE_LOCK":"false","SUPERVISOR_PERSISTENT_LOGGING":"false"},"apps":{"1":{"name":"localapp","commit":"localrelease","releaseId":"1","services":{"1":{"environment":{"CONCENTRATOR_RESET_PIN":"22","CONCENTRATOR_CONFIG":"{\n  \"SX1301_conf\": {\n      \"lorawan_public\": true,\n      \"clksrc\": 1,\n      \"antenna_gain\": 0,\n      \"radio_0\": {\n          \"enable\": true,\n          \"type\": \"SX1257\",\n          \"freq\": 867500000,\n          \"rssi_offset\": -166.0,\n          \"tx_enable\": true,\n          \"tx_freq_min\": 863000000,\n          \"tx_freq_max\": 870000000\n      },\n      \"radio_1\": {\n          \"enable\": true,\n          \"type\": \"SX1257\",\n          \"freq\": 868500000,\n          \"rssi_offset\": -166.0,\n          \"tx_enable\": false\n      },\n      \"chan_multiSF_0\": {\n          \"enable\": true,\n          \"radio\": 1,\n          \"if\": -400000\n      },\n      \"chan_multiSF_1\": {\n          \"enable\": true,\n          \"radio\": 1,\n          \"if\": -200000\n      },\n      \"chan_multiSF_2\": {\n          \"enable\": true,\n          \"radio\": 1,\n          \"if\": 0\n      },\n      \"chan_multiSF_3\": {\n          \"enable\": true,\n          \"radio\": 0,\n          \"if\": -400000\n      },\n      \"chan_multiSF_4\": {\n          \"enable\": true,\n          \"radio\": 0,\n          \"if\": -200000\n      },\n      \"chan_multiSF_5\": {\n          \"enable\": true,\n          \"radio\": 0,\n          \"if\": 0\n      },\n      \"chan_multiSF_6\": {\n          \"enable\": true,\n          \"radio\": 0,\n          \"if\": 200000\n      },\n      \"chan_multiSF_7\": {\n          \"enable\": true,\n          \"radio\": 0,\n          \"if\": 400000\n      },\n      \"chan_Lora_std\": {\n          \"enable\": true,\n          \"radio\": 1,\n          \"if\": -200000,\n          \"bandwidth\": 250000,\n          \"spread_factor\": 7\n      },\n      \"chan_FSK\": {\n          \"enable\": true,\n          \"radio\": 1,\n          \"if\": 300000,\n          \"bandwidth\": 125000,\n          \"datarate\": 50000\n      },\n      \"tx_lut_0\": {\n          \"pa_gain\": 0,\n          \"mix_gain\": 8,\n          \"rf_power\": -6,\n          \"dig_gain\": 0\n      },\n      \"tx_lut_1\": {\n          \"pa_gain\": 0,\n          \"mix_gain\": 10,\n          \"rf_power\": -3,\n          \"dig_gain\": 0\n      },\n      \"tx_lut_2\": {\n          \"pa_gain\": 0,\n          \"mix_gain\": 12,\n          \"rf_power\": 0,\n          \"dig_gain\": 0\n      },\n      \"tx_lut_3\": {\n          \"pa_gain\": 1,\n          \"mix_gain\": 8,\n          \"rf_power\": 3,\n          \"dig_gain\": 0\n      },\n      \"tx_lut_4\": {\n          \"pa_gain\": 1,\n          \"mix_gain\": 10,\n          \"rf_power\": 6,\n          \"dig_gain\": 0\n      },\n      \"tx_lut_5\": {\n          \"pa_gain\": 1,\n          \"mix_gain\": 12,\n          \"rf_power\": 10,\n          \"dig_gain\": 0\n      },\n      \"tx_lut_6\": {\n          \"pa_gain\": 1,\n          \"mix_gain\": 13,\n          \"rf_power\": 11,\n          \"dig_gain\": 0\n      },\n      \"tx_lut_7\": {\n          \"pa_gain\": 2,\n          \"mix_gain\": 9,\n          \"rf_power\": 12,\n          \"dig_gain\": 0\n      },\n      \"tx_lut_8\": {\n          \"pa_gain\": 1,\n          \"mix_gain\": 15,\n          \"rf_power\": 13,\n          \"dig_gain\": 0\n      },\n      \"tx_lut_9\": {\n          \"pa_gain\": 2,\n          \"mix_gain\": 10,\n          \"rf_power\": 14,\n          \"dig_gain\": 0\n      },\n      \"tx_lut_10\": {\n          \"pa_gain\": 2,\n          \"mix_gain\": 11,\n          \"rf_power\": 16,\n          \"dig_gain\": 0\n      },\n      \"tx_lut_11\": {\n          \"pa_gain\": 3,\n          \"mix_gain\": 9,\n          \"rf_power\": 20,\n          \"dig_gain\": 0\n      }\n  },\n\n  \"gateway_conf\": {\n      \"gateway_ID\": \"0242acfffe110006\",\n      \"server_address\": \"gatewaybridge\",\n      \"serv_port_up\": 1700,\n      \"serv_port_down\": 1700,\n      \"keepalive_interval\": 10,\n      \"stat_interval\": 30,\n      \"push_timeout_ms\": 100,\n      \"forward_crc_valid\": true,\n      \"forward_crc_error\": false,\n      \"forward_crc_disabled\": false,\n      #\"gps_tty_path\": \"/dev/ttyAMA0\",\n      \"beacon_period\": 128,\n      \"beacon_freq_hz\": 869525000,\n      \"beacon_datarate\": 9,\n      \"beacon_bw_hz\": 125000,\n      \"beacon_power\": 14,\n      \"beacon_infodesc\": 0\n  }\n}","DEBUG":"1"},"labels":{},"privileged":true,"imageId":1,"serviceName":"packet-forwarder","serviceId":1,"image":"local_image_packet-forwarder:latest","running":true},"2":{"environment":{"POSTGRESQL.DSN":"postgres://loraserver_ns:loraserver_ns@postgresql/loraserver_ns?sslmode=disable","REDIS.URL":"redis://redis:6379","NETWORK_SERVER.BAND.NAME":"EU_863_870","NETWORK_SERVER.GATEWAY.BACKEND.MQTT.SERVER":"tcp://mosquitto:1883","JOIN_SERVER.DEFAULT.SERVER":"http://appserver:8003","GEOLOCATION_SERVER.SERVER":"geoserver:8005","DEBUG":"1"},"labels":{},"imageId":2,"serviceName":"loraserver","serviceId":2,"image":"local_image_loraserver:latest","running":true}},"volumes":{"smart-postgres":{},"smart-connect":{},"lora-postgres":{},"lora-redis":{},"configs":{}},"networks":{}}}},"dependent":{"apps":[],"devices":[]}}
[Debug]   Sending request to http://192.168.0.20:48484/v2/local/target-state
[Debug]   Sending request to http://192.168.0.20:48484/v2/local/device-info
[Live]    Waiting for device state to settle...
[Info]    Streaming device logs...
[Live]    Watching for file changes...
[Debug]   Device state not settled, retrying in 1000ms
[Logs]    [9/23/2019, 3:56:17 PM] Installing service 'packet-forwarder sha256:5f2b15d4533c3a60c14bed2ff516fc14e8759fb44bd607868b8df95620266c4b'
[Logs]    [9/23/2019, 3:56:18 PM] Installed service 'packet-forwarder sha256:5f2b15d4533c3a60c14bed2ff516fc14e8759fb44bd607868b8df95620266c4b'
[Logs]    [9/23/2019, 3:56:18 PM] Starting service 'packet-forwarder sha256:5f2b15d4533c3a60c14bed2ff516fc14e8759fb44bd607868b8df95620266c4b'
[Logs]    [9/23/2019, 3:56:22 PM] Started service 'packet-forwarder sha256:5f2b15d4533c3a60c14bed2ff516fc14e8759fb44bd607868b8df95620266c4b'
[Logs]    [9/23/2019, 3:56:22 PM] [packet-forwarder] Replacing the default global conf with a user defined config from the CONCENTRATOR_CONFIG env
[Logs]    [9/23/2019, 3:56:22 PM] [packet-forwarder] Starting the CONCENTRATOR by reseting pin 22
[Debug]   Device state not settled, retrying in 1000ms
[Logs]    [9/23/2019, 3:56:22 PM] [packet-forwarder] Accessing concentrator reset pin through GPIO22...
...

(For the output above, I commented out all services except for loraserver and packet-forwarder. The loraserver service eventually failed with BadRequestDeviceAPIError: Invalid apps, but the point is that there were no errors downloading the image.)

I.e., I could not reproduce the connection reset by peer errors. Could it be a network issue on the device's local network? Even perhaps firewall config? Are you also using a Raspberry Pi 3? Which version of balenaOS is it running? What else might I need to do to reproduce the issue?

krasi-georgiev commented 5 years ago

yes this is intermittent issue and trying the same thing today runs without the above error.

krasi-georgiev commented 5 years ago

I will reopen if it happens again