Unable to Connect Greengrass Core IPC When Component Setup for Web Deployment

0

Introduction

I used gdk component build to generate a component's artifacts and recipes in the generatedgreengrass-build folder.
See below for screen shot of the folder structure.
Enter image description here

Here's the generated recipe.yml. The gdk is configured to build artifcats as zip.

ComponentConfiguration:
  DefaultConfiguration:
    accessControl:
      aws.greengrass.ipc.mqttproxy:
        com.twisthink.SystemController:mqttproxy:1:
          operations:
          - aws.greengrass#SubscribeToIoTCore
          policyDescription: Allows access to subscribe to IoT Core topic
          resources:
          - $aws/things/{iot:thingName}/jobs/get/accepted
          - $aws/things/{iot:thingName}/jobs/get/rejected
        com.twisthink.SystemController:mqttproxy:2:
          operations:
          - aws.greengrass#PublishToIoTCore
          policyDescription: Allows access to publish to IoT Core topic
          resources:
          - $aws/things/{iot:thingName}/jobs/get
ComponentDescription: This is simple Hello World component written in Python.
ComponentName: myExample
ComponentPublisher: myname
ComponentVersion: 1.0.1
Manifests:
- Artifacts:
  - URI: s3://BUCKET_NAME/COMPONENT_NAME/COMPONENT_VERSION/example.zip
    Unarchive: ZIP
  Lifecycle:
    Run:
      RequiresPrivilege: true
      Script: sudo python3 {artifacts:decompressedPath}/example/main.py
  Platform:
    os: linux
RecipeFormatVersion: '2020-01-25'

I then ran the following commands to locally deploy my component:

cd greengrass-build
sudo greengrass-cli deployment create --recipeDir recipes --artifactDir artifacts --merge "myExample=1.0.1"

Problem

Here's what I see in the ....greengrass/v2/logs/myExample.log:

2023-02-10T21:10:17.518Z [WARN] (Copier) myExample: stderr. File "/home/me/greengrass/v2/packages/artifacts-unarchived/myExample/1.0.1/example/main.py", line 41, in __init__. {scriptName=services.myExample.lifecycle.Run.Script, serviceName=myExample, currentState=RUNNING}
2023-02-10T21:10:17.518Z [WARN] (Copier) myExample: stderr. self.ipc_client_v2 = GreengrassCoreIPCClientV2(). {scriptName=services.myExample.lifecycle.Run.Script, serviceName=myExample, currentState=RUNNING}
2023-02-10T21:10:17.518Z [WARN] (Copier) myExample: stderr. File "/usr/local/lib/python3.8/dist-packages/awsiot/greengrasscoreipc/clientv2.py", line 31, in __init__. {scriptName=services.myExample.lifecycle.Run.Script, serviceName=myExample, currentState=RUNNING}
2023-02-10T21:10:17.518Z [WARN] (Copier) myExample: stderr. client = awsiot.greengrasscoreipc.connect(). {scriptName=services.myExample.lifecycle.Run.Script, serviceName=myExample, currentState=RUNNING}
2023-02-10T21:10:17.518Z [WARN] (Copier) myExample: stderr. File "/usr/local/lib/python3.8/dist-packages/awsiot/greengrasscoreipc/__init__.py", line 45, in connect. {scriptName=services.myExample.lifecycle.Run.Script, serviceName=myExample, currentState=RUNNING}
2023-02-10T21:10:17.518Z [WARN] (Copier) myExample: stderr. ipc_socket = os.environ["AWS_GG_NUCLEUS_DOMAIN_SOCKET_FILEPATH_FOR_COMPONENT"]. {scriptName=services.myExample.lifecycle.Run.Script, serviceName=myExample, currentState=RUNNING}
2023-02-10T21:10:17.518Z [WARN] (Copier) myExample: stderr. File "/usr/lib/python3.8/os.py", line 675, in __getitem__. {scriptName=services.myExample.lifecycle.Run.Script, serviceName=myExample, currentState=RUNNING}
2023-02-10T21:10:17.518Z [WARN] (Copier) myExample: stderr. raise KeyError(key) from None. {scriptName=services.myExample.lifecycle.Run.Script, serviceName=myExample, currentState=RUNNING}
2023-02-10T21:10:17.518Z [WARN] (Copier) myExample: stderr. KeyError: 'AWS_GG_NUCLEUS_DOMAIN_SOCKET_FILEPATH_FOR_COMPONENT'. {scriptName=services.myExample.lifecycle.Run.Script, serviceName=myExample, currentState=RUNNING}
2023-02-10T21:10:17.540Z [INFO] (Copier) myExample: Run script exited. {exitCode=1, serviceName=myExample, currentState=RUNNING}

Question

Why is AWS_GG_NUCLEUS_DOMAIN_SOCKET_FILEPATH_FOR_COMPONENT missing from the environment variable? And how can I fix that? P.S. I do not get this error when I run my component with non-zipped artifacts.

ictwist
gefragt vor einem Jahr702 Aufrufe
1 Antwort
1
Akzeptierte Antwort

Your recipe has sudo, do not use sudo, this is what RequiresPrivilege is for.

sudo will drop all environment variables.

Cheers,

Michael

AWS
EXPERTE
beantwortet vor einem Jahr
  • You're right. I changed the Lifecycle part of my recipe to

      Lifecycle:
        Run:
          RequiresPrivilege: true
          Script: python3 {artifacts:decompressedPath}/example/main.py
    

    And this worked. Thanks Michael!

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen