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

Add iotedgehubdev integration #233

Merged
merged 26 commits into from
Aug 15, 2018
Merged

Add iotedgehubdev integration #233

merged 26 commits into from
Aug 15, 2018

Conversation

LazarusX
Copy link
Contributor

@LazarusX LazarusX commented Aug 6, 2018

This PR closes #202

@jongio
Copy link
Member

jongio commented Aug 6, 2018

Please also update the container to includes iotedgehubdev instead of the old ctl. Work with @yorek on coordinating that as he has a PR out to improve the way the containers are built.

@yorek - I'm thinking that instead of running the full agent in the container, we just run iotedgehubdev (simulator) - because the container is only dev scenarios anyway.

So, @LazarusX should be able to do a PR into your PR that just swaps the old ctl for iotedgehubdev.

@yorek
Copy link
Contributor

yorek commented Aug 6, 2018

Sounds good to me, I may need some help with iotedgehubdev, never used before.

@jongio
Copy link
Member

jongio commented Aug 6, 2018

@LazarusX - I get this when I run iotedgedev simulator start

ERROR: Error: [Errno 2] No such file or directory: 'C:\\ProgramData\\iotedgehubdev\\config\\edgehub.json'
ERROR: Error while executing command: iotedgehubdev start -d config\deployment.json. Command '['iotedgehubdev', 'start', '-d', 'config\\deployment.json']' returned non-zero exit status 1.

Looks like I need to run setup first, which I did, then got this:

ERROR: no such image: ${MODULES.filtermodule.amd64}: invalid reference format: repository name must be lowercase
ERROR: Error: Error while executing command: docker-compose -f C:\ProgramData\iotedgehubdev\data\data\docker-compose.yml up -d. Command '['docker-compose', '-f', 'C:\\ProgramData\\iotedgehubdev\\data\\data\\docker-compose.yml', 'up', '-d']' returned non-zero exit status 1.
ERROR: Error while executing command: iotedgehubdev start -d config\deployment.json. Command '['iotedgehubdev', 'start', '-d', 'config\\deployment.json']' returned non-zero exit status 1.

@jongio
Copy link
Member

jongio commented Aug 6, 2018

@LazarusX - Please also write some tests for this. Thanks!

@jongio
Copy link
Member

jongio commented Aug 6, 2018

@LazarusX - Can runtime.py now be removed?

@LazarusX
Copy link
Contributor Author

LazarusX commented Aug 7, 2018

@yorek You can see a quickstart instruction for iotedgehubdev at https://pypi.org/project/iotedgehubdev/ (more detailed documentations are coming soon). Please file issues at https://github.com/Azure/iotedgehubdev/issues. Let me know if you encounter any issues.

@LazarusX
Copy link
Contributor Author

LazarusX commented Aug 7, 2018

@jongio

I get this when I run iotedgedev simulator start

ERROR: Error: [Errno 2] No such file or directory: 'C:\\ProgramData\\iotedgehubdev\\config\\edgehub.json'
ERROR: Error while executing command: iotedgehubdev start -d config\deployment.json. Command '['iotedgehubdev', 'start', '-d', 'config\\deployment.json']' returned non-zero exit status 1.

Yes. You need to run setup before start to generate credentials. I am updating help messages to make it clear.

Looks like I need to run setup first, which I did, then got this:

ERROR: no such image: ${MODULES.filtermodule.amd64}: invalid reference format: repository name must be lowercase
ERROR: Error: Error while executing command: docker-compose -f C:\ProgramData\iotedgehubdev\data\data\docker-compose.yml up -d. Command '['docker-compose', '-f', 'C:\\ProgramData\\iotedgehubdev\\data\\data\\docker-compose.yml', 'up', '-d']' returned non-zero exit status 1.
ERROR: Error while executing command: iotedgehubdev start -d config\deployment.json. Command '['iotedgehubdev', 'start', '-d', 'config\\deployment.json']' returned non-zero exit status 1.

It seems that you didn't build the solution before running based on the image name ${MODULES.filtermodule.amd64}. You can run iotedgedev build or append -b parameter to iotedgedev simulator start.

@jongio
Copy link
Member

jongio commented Aug 7, 2018

@LazarusX - In start, can you automatically detect if setup hasn't been called and call it for the user?

In start can you detect that it hasn't been build and let them know. The error wasn't enough to get me there. Thanks, Jon

@LazarusX
Copy link
Contributor Author

LazarusX commented Aug 7, 2018

@jongio

Can runtime.py now be removed?

I am removing it, as well as updating #201 to document the removal of azure-iot-edge-ctl commands and addition of iotedgehubdev integration

@LazarusX
Copy link
Contributor Author

LazarusX commented Aug 7, 2018

@jongio

In start, can you automatically detect if setup hasn't been called and call it for the user?

That's a bug with iotedgehubdev. I have filed issue Azure/iotedgehubdev#69.

In start can you detect that it hasn't been build and let them know. The error wasn't enough to get me there. Thanks, Jon

I have added the check.

@LazarusX
Copy link
Contributor Author

LazarusX commented Aug 7, 2018

@jongio I have add commits to resolve your comments. Please help review again.

@jongio
Copy link
Member

jongio commented Aug 7, 2018

Get the following with tox

=============================================
======== STOPPING IOT EDGE SIMULATOR ========
=============================================




.ERROR: Error: Error during pull for image hello-world:latest : 500 Server Error: Internal Server Error ("Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on 192.168.65.1:53: read udp 192.168.65.3:50335->192.168.65.1:53: i/o timeout")
>       assert 'IoT Edge Simulator has been started in single module mode.' in result.output
E       assert 'IoT Edge Simulator has been started in single module mode.' in '\n============================================================\n======== STARTING IOT EDGE SIMULATOR IN SINGLE MODE ===...lookup mcr.microsoft.com on 192.168.65.1:53: read udp 192.168.65.3:35990->192.168.65.1:53: i/o timeout")\nERROR: \nNone\n'
E        +  where '\n============================================================\n======== STARTING IOT EDGE SIMULATOR IN SINGLE MODE ===...lookup mcr.microsoft.com on 192.168.65.1:53: read udp 192.168.65.3:35990->192.168.65.1:53: i/o timeout")\nERROR: \nNone\n' = <Result SystemExit()>.output

..\test_simulator.py:59: AssertionError
_____________________________ test_start_solution _____________________________

capfd = <_pytest.capture.CaptureFixture object at 0x000000000589C940>
>       assert 'IoT Edge Simulator has been started in solution mode.' in out
E       assert 'IoT Edge Simulator has been started in solution mode.' in 'ERROR: Error: Error during pull for image hello-world:latest : 500 Server Error: Internal Server Error ("Get https://...son. Command \'[\'iotedgehubdev\', \'start\', \'-d\', \'config\\deployment.json\']\' returned non-zero exit status 1\n\n'

..\test_simulator.py:97: AssertionError
________________________________ test_monitor _________________________________

assert 'Starting event monitor' in out
else:
assert 'Monitoring events from device' in out
assert 'timeCreated' in out
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad merge. The last line should be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests/test_simulator.py is added by me. The timeCreated line is used to check whether we can successfully send D2C messages using iotedgehubdev.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Please increase the timeout to more than 2 seconds as well. Something like 15 seconds should be enough.

@LazarusX
Copy link
Contributor Author

LazarusX commented Aug 7, 2018

@jongio That's weird. What's the result of running docker run hello-world on your machine? The hello-world image in iotedgehubdev is used as a helper to copy credentials to the Docker volume.

@jongio
Copy link
Member

jongio commented Aug 8, 2018

@LazarusX - I ran this:

iotedgedev solution create
iotedgedev build
iotedgedev push
iotedgedev deploy
iotedgedev start
and got this

Network azure-iot-edge-dev is external, skipping
ERROR: no such image: ${MODULES.filtermodule.amd64}: invalid reference format: repository name must be lowercase
ERROR: Error: Error while executing command: docker-compose -f C:\ProgramData\iotedgehubdev\data\data\docker-compose.yml up -d. Command '['docker-compose', '-f', 'C:\\ProgramData\\iotedgehubdev\\data\\data\\docker-compose.yml', 'up', '-d']' returned non-zero exit status 1.
ERROR: Error while executing command: iotedgehubdev start -d config\deployment.json. Command '['iotedgehubdev', 'start', '-d', 'config\\deployment.json']' returned non-zero exit status 1.

I checked config\deployment.json and see the ${} syntax in the file.

I rerun build

and then the config\deployment.json file has the right settings.

I traced it down.

For some reason, the 'deploy' step is not expanding the envvars to the config file correctly.

So run the steps above. Run the deploy step and then look at config\deployment.json

@LazarusX
Copy link
Contributor Author

LazarusX commented Aug 8, 2018

@jongio This should be fixed now. Please try again. I also added more commits.

@LazarusX
Copy link
Contributor Author

LazarusX commented Aug 8, 2018

Due to the issue I mentioned in #236 (comment), if tox stuck after starting the simulator in solution mode for Python 3.6, you might need to open another terminal and run iotedgedev stop.

@jongio
Copy link
Member

jongio commented Aug 10, 2018

For message:

setup Setup IoT Edge simulator. This must be done before starting

Does setup still need to be called before start?

@jongio
Copy link
Member

jongio commented Aug 10, 2018

@LazarusX - I'm seeing this message:

image

@LazarusX
Copy link
Contributor Author

Yes. This is an issue with iotedgehubdev Azure/iotedgehubdev#69. Currently, iotedgehubdev does't provide a method to tell if the user has setup.

@LazarusX
Copy link
Contributor Author

@jongio Conflict resolved.

@jongio
Copy link
Member

jongio commented Aug 10, 2018

Before I can merge this, we'll need to figure out how to kill monitor-process.

Can you think of other options that would be a quick fix? For example, can you call stop once you have verified that messages are received? Or set a timer and call stop when it expires? Or only send a few messages?

I also have a branch where @digimaun and I are trying to figure out how to kill the process, but tox is not running there. I'll work on that today. But a quick fix for you to unblock this merge would be ideal.

Jon

@LazarusX
Copy link
Contributor Author

@jongio Do you mean temporarily getting this PR pass the tox e2e tests, or making the timeout option actually work as advertised on Python 3.6? For former, you can open another terminal window and run iotedgedev stop when you see tox get stuck (usually after creating the containers). For the latter, I might have to think how to implement it in my tomorrow morning :).

@jongio
Copy link
Member

jongio commented Aug 10, 2018

We need to be able to automate tox. So opening another window is not an option. Sure, get some sleep :)

@jongio jongio merged commit 9e91d44 into master Aug 15, 2018
@LazarusX LazarusX deleted the ray-iotedgehubdev branch August 16, 2018 03:07
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

Successfully merging this pull request may close these issues.

Integrate with iotedgehubdev
3 participants