aws / aws-iot-device-sdk-python-v2

Next generation AWS IoT Client SDK for Python using the AWS Common Runtime
Apache License 2.0
408 stars 213 forks source link

Example with new_list_components / ListComponentsOperation ? #222

Closed Minipada closed 2 years ago

Minipada commented 3 years ago

Confirm by changing [ ] to [x] below:

Platform/OS/Device EC2 ubuntu 20

Describe the question I am trying to get the list of components being deployed during a deployment using new_list_components.

For that, I am running a bootstrap script and trying to get the list of components deployed. Here is my function. It times out.

def list_components():
    """List components from g   reengrass deployment."""
    ipc_client: GreengrassCoreIPCClient = awsiot.greengrasscoreipc.connect()
    request = ListComponentsRequest()
    operation: ListComponentsOperation = ipc_client.new_list_components()
    operation.activate(request)
    futureResponse = operation.get_response()
    response = futureResponse.result(30)  # seconds

    return response.value

I am not sure what I am doing wrong. Link to the documentation

jmklix commented 3 years ago

Can you try increasing the timeout to more than the default to 10 seconds. You can do this when calling

awsiot.greengrasscoreipc.connect(*, ipc_socket=None, authtoken=None, lifecycle_handler=None, timeout=10.0)
Minipada commented 3 years ago

@jmklix Thanks for the prompt answer. I just tried, it didn't change anything. The timeout comes from the request:

2021-08-10T18:39:03.449Z [INFO] (pool-2-thread-28) my_component: shell-runner-start. {scriptName=services.my_component.lifecycle.Bootstrap.Script, serviceName=my_component, currentState=FINISHED, command=["python3 /greengrass/v2/packages/artifacts/my_component/0..."]}
2021-08-10T18:39:33.633Z [INFO] (Copier) my_component: stdout. environ({'GGC_VERSION': '2.3.0', 'AWS_GG_NUCLEUS_DOMAIN_SOCKET_FILEPATH_FOR_COMPONENT': '/greengrass/v2/ipc.socket', 'AWS_CONTAINER_AUTHORIZATION_TOKEN': '6YVRRQRYFV6HWJPJ', 'AWS_IOT_THING_NAME': 'GGC-david-test-DELETE-ME', 'ros_interface': 'ros', 'HOME': '/root', 'AWS_DEFAULT_REGION': 'us-east-1', 'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin', 'AWS_GG_NUCLEUS_DOMAIN_SOCKET_FILEPATH': '/greengrass/v2/ipc.socket', 'AWS_CONTAINER_CREDENTIALS_FULL_URI': 'http://localhost:44161/2016-11-01/credentialprovider/', 'AWS_REGION': 'us-east-1', 'JAVA_HOME': '/usr/lib/jvm/java-16-openjdk-amd64', 'PWD': '/greengrass/v2/work/my_component', 'SVCUID': '6YVRRQRYFV6HWJPJ', 'LC_CTYPE': 'C.UTF-8'}). {scriptName=services.my_component.lifecycle.Bootstrap.Script, serviceName=my_component, currentState=FINISHED}
2021-08-10T18:39:33.846Z [WARN] (Copier) my_component: stderr. Traceback (most recent call last):. {scriptName=services.my_component.lifecycle.Bootstrap.Script, serviceName=my_component, currentState=FINISHED}
2021-08-10T18:39:33.846Z [WARN] (Copier) my_component: stderr. File "/greengrass/v2/packages/artifacts/my_component/0.0.46/netplan_update2.py", line 129, in <module>. {scriptName=services.my_component.lifecycle.Bootstrap.Script, serviceName=my_component, currentState=FINISHED}
2021-08-10T18:39:33.847Z [WARN] (Copier) my_component: stderr. print(list_components()). {scriptName=services.my_component.lifecycle.Bootstrap.Script, serviceName=my_component, currentState=FINISHED}
2021-08-10T18:39:33.847Z [WARN] (Copier) my_component: stderr. File "/greengrass/v2/packages/artifacts/my_component/0.0.46/netplan_update2.py", line 52, in list_components. {scriptName=services.my_component.lifecycle.Bootstrap.Script, serviceName=my_component, currentState=FINISHED}
2021-08-10T18:39:33.847Z [WARN] (Copier) my_component: stderr. response = futureResponse.result(30)  # seconds. {scriptName=services.my_component.lifecycle.Bootstrap.Script, serviceName=my_component, currentState=FINISHED}
2021-08-10T18:39:33.848Z [WARN] (Copier) my_component: stderr. File "/usr/lib/python3.8/concurrent/futures/_base.py", line 446, in result. {scriptName=services.my_component.lifecycle.Bootstrap.Script, serviceName=my_component, currentState=FINISHED}
2021-08-10T18:39:33.848Z [WARN] (Copier) my_component: stderr. raise TimeoutError(). {scriptName=services.my_component.lifecycle.Bootstrap.Script, serviceName=my_component, currentState=FINISHED}
2021-08-10T18:39:33.848Z [WARN] (Copier) my_component: stderr. concurrent.futures._base.TimeoutError. {scriptName=services.my_component.lifecycle.Bootstrap.Script, serviceName=my_component, currentState=FINISHED}
jmklix commented 2 years ago

How do you have your bootstrap script setup to run?

Minipada commented 2 years ago

the component, in the start part was just using python my_script.py

jmklix commented 2 years ago

ListComponentsOperation is only usable by the CLI component and will always throw an unauthorized error. The available API functions that you can use will be documented here.

github-actions[bot] commented 2 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.