Hello @banto-78 lets try to reproduce this step-by-step. The command that we are looking into takes the content of the $J_FILE variable and attempts to add some fields in there. According to the Dockerfile, this $J_FILE variable is set by reading the file at /usr/src/app/iot-edge/samples/simulated_device_cloud_upload/src/simulated_device_cloud_upload_lin.json.
First of all we need to make sure this is working as expected, as dt-rush mentioned above the path needs to be updated by adding v1. Once you figured out the correct path remember to update it in the line below.
Once this is sorted out the file should never result as empty. Now if we have fields missing this probably means that one or more of the env vars $DEVICE1, $DEVICE2, $DEVICE1KEY or $DEVICE2KEY are missing.
Many thanks for your message. The missing path issue I think I’ve fixed already. All paths are (or looks to me) up to date including J_FILE:
J_FILE=$(cat /usr/src/app/iot-edge/v1/samples/simulated_device_cloud_upload/src/simulated_device_cloud_upload_lin.json)
I have defined the device env variables $DEVICE1, $DEVICE2, $DEVICE1KEY or $DEVICE2KEY too. The replace.json is produced but still empty.
Few additional notes though:
1
why the script has “sleep infinity” ? I have removed it since it will never let the script continue…
2
According to the JSON structure this code:
…
jq ‘.modules[1].args[0].deviceId="’$DEVICE1’"’ | \
jq ‘.modules[1].args[0].deviceKey="’$DEVICE1KEY’"’ | \
jq ‘.modules[1].args[1].deviceId="’$DEVICE2’"’ | \
jq ‘.modules[1].args[1].deviceKey="’$DEVICE2KEY’"’ \
> replaced.json
Also checking it out @banto_78 , the issue might be in case the code is copy-paste from the blog. Even if in the blog source there are no trailing whitespaces, but in the paste there are trailing whitespace on the echo .... line, that I see also in your comment above (this one: Combining Balena and Azure IoT Edge )
The \ concatenation of lines only works if that character is the last one in the line (no trailing white spaces are allowed). If I copy paste from the blog, I run into an issue, if I trim the whitespace on that first line, it all works fine. So I guess the blame is on how our blog renders code, unfortunately…
https://github.com/maxtheaviator/resin-azure-iotedge-multicontainer can be interesting indeed but I get error during the build, like:
…
Step 3/11 : RUN pip3 install --upgrade setuptools pip
[iotedge] —> Running in ef85c9745838
[iotedge] Traceback (most recent call last):
[iotedge] File “/usr/local/bin/pip3”, line 7, in
[iotedge] from pip._internal import main
[iotedge] File “/usr/lib/python3/dist-packages/pip/init.py”, line 72, in
[iotedge] from pip.log import logger
[iotedge] File “/usr/lib/python3/dist-packages/pip/log.py”, line 9, in
[iotedge] import colorama, pkg_resources
[iotedge] File “/usr/lib/python3/dist-packages/pkg_resources.py”, line 1520, in
[iotedge] register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
[iotedge] AttributeError: module ‘importlib._bootstrap’ has no attribute ‘SourceFileLoader’
[iotedge]
[iotedge] Removing intermediate container ef85c9745838
[Info] Uploading images
[iotedge] The command ‘/bin/sh -c pip3 install --upgrade setuptools pip’ returned a non-zero code: 1
…
I have also changed the base image to:
FROM balenalib/raspberrypi3-python:3.6-jessie-build
That looks like an issue with Python or Pip when trying to upgrade setuptools or pip. I suggest you to ask in a Python specific forum, as they will be able to help much more than us (our Python knowledge is not extensive)!
I have fixed the error above. It was related to python and pip installation in Dockerfile.
Now when the container starts it gives this error:
02.07.19 17:47:19 (+0200) iotedge ERROR: Error during pull for image local/azure-iotedge-runtime-resin:latest
02.07.19 17:47:19 (+0200) iotedge 404 Client Error: Not Found (“pull access denied for local/azure-iotedge-runtime-resin, repository does not exist or may require ‘docker login’”)
02.07.19 17:47:19 (+0200) iotedge ERROR: Exiting with errors. Return code: 1
yeah, what I would do is put in a sleep infinity just above that line in the start script, then once that sleep is running, i would try run that line manually from the command line. My suspicion is that it is not finding a Dockerfile in the /azure-iotedge-runtime directory and so the container engine is trying to pull the image from dockerhub, but it doesn’t exist