Seems my core device is not receiving shadow update

0

On my core I have ShadowManager and a custom component. I am trying to get the latest shadow test in my custom component. My python code **does ** retrieve a shadow, it's just outdated. I have admittedly been struggling with learning Greengrass and permissions. Hopefully one of you experts can help as I've been looking at this a day and a half now.

These configurations are all copied from Local Debug Console so I am assuming that they are what is actually being used. My shadowManager configuration

---
componentType: "PLUGIN"
configuration:
  rateLimits: {}
  shadowDocumentSizeLimitBytes: 8192
  strategy:
    type: "realTime"
  synchronize:
    coreThing:
      classic: true
    direction: "betweenDeviceAndCloud"
    namedShadows:
    - "test"
dependencies:
- "aws.greengrass.Nucleus:SOFT"
lifecycle: {}
version: "2.2.1"

My component configuration:

---
componentType: "GENERIC"
configuration:
  accessControl:
    aws.greengrass.ipc.mqttproxy:
      com.xxxxxxxx.productivity.cycle_count:mqttproxy:1:
        operations:
        - "aws.greengrass#PublishToIoTCore"
        policyDescription: ""
        resources:
        - "*"
    aws.greengrass.ipc.pubsub:
      com.xxxxxxxx.productivity.cycle_count:pubsub:1:
        operations:
        - "aws.greengrass#SubscribeToTopic"
        - "aws.greengrass#PublishToTopic"
        policyDescription: ""
        resources:
        - "*"
    aws.greengrass.ShadowManager:
      com.xxxxxxxx.productivity.cycle_count:shadow:1:
        operations:
        - "aws.greengrass#GetThingShadow"
        - "aws.greengrass#UpdateThingShadow"
        - "aws.greengrass#DeleteThingShadow"
        - "aws.greengrass#ListNamedShadowsForThing"
        policyDescription: ""
        resources:
        - "$aws/things/*"
        - "*"
dependencies: []
lifecycle:
  Run: "python3 -u /greengrass/v2/packages/artifacts/com.xxxxxxxx.productivity.cycle_count/1.0.138/cycle_count.py"
previousVersion: "1.0.137"
version: "1.0.138"

The policy attached to the cert looks like this:

Policy effect
Policy action
Policy resource
Allow	*	*
Allow	iot:DeleteThingShadow	*
Allow	iot:GetThingShadow	*
Allow	iot:UpdateThingShadow	*
Allow	iot:Connect	*
Allow	iot:Publish	*
Allow	iot:Receive	*
Allow	iot:Subscribe	*
Allow	iot:ListNamedShadowsForThing	*

If I change my python code to get a named shadow that doesn't exist I do get a shadow doesn't exist error message. Any thoughts as to why updating a shadow does not sync with my thing?

EDIT What shadow are you updating in the cloud, and what specifically are you updating? I am editing the shadow called test. I have tried others as well.

How are you checking the shadow on the device? Are you sending multiple requests to getThingShadow, or are you subscribed to shadow changes?

I am retrieving the shadow when a switch is triggered on the RaspberryPi. The code is:

def sample_get_thing_shadow_request(thingName, shadowName):
    
    try:
        # set up IPC client to connect to the IPC server
        shadow_ipc_client = awsiot.greengrasscoreipc.connect()
                
        # create the GetThingShadow request
        get_thing_shadow_request = GetThingShadowRequest()
        get_thing_shadow_request.thing_name = thingName
        get_thing_shadow_request.shadow_name = shadowName
        
        # retrieve the GetThingShadow response after sending the request to the IPC server
        op = shadow_ipc_client.new_get_thing_shadow()
        op.activate(get_thing_shadow_request)
        fut = op.get_response()
        
        result = fut.result(5)
        ret = json.loads(result.payload)
        print(ret)
        return result.payload
    except  BaseException as err:
        print(f"Shadow retrieval exception: {err=}, {type(err)=}")
        
    return result.payload

Before I try this I edit the shadow and put a different value in for ["state"]["desired"]["topic"]. The edit is accepted in the web console. I always get a value from about two days ago when my code runs though. I do not see any log entries from shadowManager unless I ask for a shadow other then test.

I did try creating a new shadow and adding the permission using Local Debug Console. When I request that new shadow I get:

2022-09-29T21:58:51.884Z [INFO] (Copier) com.xxxxxxxx.productivity.cycle_count: stdout. Shadow retrieval exception: err=ResourceNotFoundError(message='No shadow found', resource_type='shadow'), type(err)=<class 'awsiot.greengrasscoreipc.model.ResourceNotFoundError'>. {scriptName=services.com.xxxxxxxx.productivity.cycle_count.lifecycle.Run, serviceName=com.xxxxxxxx.productivity.cycle_count, currentState=RUNNING}

It seems from my noobie end that the shadows are getting updated but the updates are not making it to the core thing.

  • What shadow are you updating in the cloud, and what specifically are you updating?

    How are you checking the shadow on the device? Are you sending multiple requests to getThingShadow, or are you subscribed to shadow changes?

  • I added answers to your questions above in my post edit.

  • hey @flycast. We are still looking into this, thanks for your patience.

flycast
asked 2 years ago321 views
4 Answers
0

Hi,

I see that your custom component running on the core device is unable to receive the latest shadow update. Looking at the policy attached to the certificate, it seems correct to me, as permission for the the iot:GetThingShadow is provided for all resources.

To further investigate the issue, I would need to take a look at the greengrass logs generated pertaining to this specific issue. You can create a technical case using AWS Support console and share us all the logs generated under /greengrass/v2/logs directory[1].

References: [1] https://docs.aws.amazon.com/greengrass/v2/developerguide/monitor-logs.html#access-local-logs

AWS
SUPPORT ENGINEER
answered 2 years ago
  • I DID start a tech support question. I also tested further by testing a different core device. That performed the same. I also tested named shadows vs classic shadows. It would appear that the classic shadow syncs but named shadows do not. I think it looks like some kind of bug.

0

Hi @flycast, Sorry, we couldn`t reporduce the error from our side. Could you provide more logs before the error, especially the greengrass.log? We want to double check if the deployment and sync success. Also, to better reporduce it, could you also provide the OS, nucleus version, and shadow manager version?

AWS
Daojing
answered 2 years ago
  • I have had a support ticket open for 18 days at AWS now. I will post an "answer" on this thread as I can't fit it all in a comment.

0

Hi @flycast, Thanks for providing this info, and sorry for taking so long to handle it. It seems like some communication issues happen between the support engineer and our team. Back to this issue, I remember this support ticket. In this ticket, the related teams already follow up and provide some further requests to the support engineer. I believe the support engineer will reach out to you ASAP.

AWS
Daojing
answered 2 years ago
  • Can I include you in the support ticket somehow? Reading the support ticket it looks like all the communications are being funneled through one first tier support engineer to yourselves (I'm calling you second tier support) and me. There seems to be a few days lag every time that happens. I can't tell if that is because of first tier or second tier support. At any rate I supplied ALL the configurations, code, shadow names in my very first support request on 9/30. I was just asked last Friday 10/14 for the EXACT same information again as if I had never supplied it. Getting frustrated waiting.

0

As mentioned I have had a support ticket open for 17 or 18 days now and it is getting nowhere slowly. I just did some troubleshooting this morning. I created a named shadow named "Sussing" on the core called "PrecoGG1" and then edited the shadow. No information showed up in the PrecoGG1 greengrass.log file.

I then edited the classic shadow and I do see the following entries showing up:

2022-10-17T13:56:16.017Z [INFO] (pool-2-thread-25) com.aws.greengrass.shadowmanager.sync.strategy.BaseSyncStrategy: sync. Executing sync request. {Type=LocalUpdateSyncRequest, thing name=PrecoGG1, shadow name=} 2022-10-17T13:56:16.071Z [INFO] (pool-2-thread-25) com.aws.greengrass.shadowmanager.ipc.UpdateThingShadowRequestHandler: Successfully updated shadow. {service-name=aws.greengrass.ShadowManager, thing name=PrecoGG1, shadow name=, local-version=2} 2

So we know that the classic shadow is syncing.

I went back and edited the named shadow and nothing showed up in the greengrass.log file at all.

My shadowManager configuration looks like this: Shadow Manager:


{
  "reset": [],
  "merge": {
    "strategy": {
      "type": "realTime"
    },
    "synchronize": {
      "coreThing": {
        "classic": true
      },
      "namedShadows": [
        "test",
        "Sussing"
      ],
      "direction": "betweenDeviceAndCloud"
    }
  }
}
flycast
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions