1

Hope you're all doing as good as possible during those covid times.

Overview

I have a lambda function that runs on a raspberry device with Greengrass version 1. This lambda access my USB port that has an XBee on it (/dev/ttyUSB0) and sends this data to an MQTT on IoT Core and it is working for some months. It functions this way: My GGC receives 5 packages every 5 minutes from a remote station that has some sensors and after unpacking this data, it sends it as a JSON through MQTT.

I'm currently trying to update my GGC_v1 to GGC_v2 and am facing a problem when deploying it. I'm not able to access the local resource on version two when running the same lambda function, even though the recipe has access for reading and writing on the device.

On GGC_V1 is uses the configuration below:

  • Make this function long-lived and keep it running indefinitely
  • Use group default (currently: Greengrass container)
  • Use group default (currently: ggc_user/ggc_group) Also added access to resource /dev/ttyUSB0.

Problem Log:

2021-07-13T20:07:22.890Z [INFO] (pool-2-thread-58) com.weatherStation.XBee: Finding mounted cgroups.. {serviceInstance=0, serviceName=com.weatherStation.XBee, currentState=STARTING}
2021-07-13T20:07:22.909Z [INFO] (Copier) com.weatherStation.XBee: Startup script exited. {exitCode=1, serviceInstance=0, serviceName=com.weatherStation.XBee, currentState=STARTING}
2021-07-13T20:07:22.915Z [INFO] (pool-2-thread-53) com.weatherStation.XBee: shell-runner-start. {scriptName=services.com.weatherStation.XBee.lifecycle.shutdown.script, serviceInstance=0, serviceName=com.weatherStation.XBee, currentState=BROKEN, command=["/greengrass/v2/packages/artifacts/aws.greengrass.LambdaLauncher/2.0.7/lambda-l..."]}
2021-07-13T20:07:23.102Z [WARN] (Copier) com.weatherStation.XBee: stderr. 2021/07/13 17:07:23 could not read process state file /greengrass/v2/work/com.weatherStation.XBee/work/worker/0/state.json: open /greengrass/v2/work/com.weatherStation.XBee/work/worker/0/state.json: no such file or directory. {scriptName=services.com.weatherStation.XBee.lifecycle.shutdown.script, serviceInstance=0, serviceName=com.weatherStation.XBee, currentState=BROKEN}
2021-07-13T20:07:23.220Z [ERROR] (pool-2-thread-60) com.weatherStation.XBee: error while removing dir   {"path": "/greengrass/v2/work/com.weatherStation.XBee/work/worker/0", "errorString": "unlinkat /greengrass/v2/work/com.weatherStation.XBee/work/worker/0/overlays: device or resource busy"}. {serviceInstance=0, serviceName=com.weatherStation.XBee, currentState=BROKEN}

Recipe:


  "RecipeFormatVersion": "2020-01-25",
  "ComponentName": "com.weatherStation.XBee",
  "ComponentVersion": "5.0.2",
  "ComponentType": "aws.greengrass.lambda",
  "ComponentDescription": "",
  "ComponentPublisher": "AWS Lambda",
  "ComponentSource": "arn:aws:lambda:region:account_id:function:Greengrass_WeatherStation",
  "ComponentConfiguration": {
    "DefaultConfiguration": {
      "lambdaExecutionParameters": {
        "EnvironmentVariables": {}
      },
      "containerParams": {
        "memorySize": 16000,
        "mountROSysfs": false,
        "volumes": {},
        "devices": {
          "0": {
            "path": "/dev/ttyUSB0",
            "permission": "rw",
            "addGroupOwner": true
          }
        }
      },
      "containerMode": "GreengrassContainer",
      "timeoutInSeconds": 15,
      "maxInstancesCount": 100,
      "inputPayloadEncodingType": "json",
      "maxQueueSize": 1000,
      "pinned": true,
      "maxIdleTimeInSeconds": 60,
      "statusTimeoutInSeconds": 60,
      "pubsubTopics": {
        "0": {
          "topic": "ggc/weather_station/data",
          "type": "IOT_CORE"
        }
      }
    }
  },
  "ComponentDependencies": {
    "aws.greengrass.LambdaLauncher": {
      "VersionRequirement": ">=2.0.0 <3.0.0",
      "DependencyType": "HARD"
    },
    "aws.greengrass.TokenExchangeService": {
      "VersionRequirement": ">=2.0.0 <3.0.0",
      "DependencyType": "HARD"
    },
    "aws.greengrass.LambdaRuntimes": {
      "VersionRequirement": ">=2.0.0 <3.0.0",
      "DependencyType": "SOFT"
    }
  },
  "Manifests": [
    {
      "Platform": {
        "os": "linux",
        "architecture": "arm"
      },
      "Lifecycle": {},
      "Artifacts": [
        {
          "Uri": "greengrass:lambda-artifact.zip",
          "Digest": "GVgaQlVuSYmfgbwoStd5dfB9WamdQgrhbE72s2fF04ysno=",
          "Algorithm": "SHA-256",
          "Unarchive": "ZIP",
          "Permission": {
            "Read": "OWNER",
            "Execute": "NONE"
          }
        }
      ]
    }
  ],
  "Lifecycle": {
    "startup": {
      "requiresPrivilege": true,
      "script": "{aws.greengrass.LambdaLauncher:artifacts:path}/lambda-launcher start"
    },
    "setenv": {
      "AWS_GREENGRASS_LAMBDA_CONTAINER_MODE": "{configuration:/containerMode}",
      "AWS_GREENGRASS_LAMBDA_ARN": "arn:aws:lambda:region:account_id:function:Greengrass_WeatherStation:5",
      "AWS_GREENGRASS_LAMBDA_FUNCTION_HANDLER": "main.weather_handler",
      "AWS_GREENGRASS_LAMBDA_ARTIFACT_PATH": "{artifacts:decompressedPath}/lambda-artifact",
      "AWS_GREENGRASS_LAMBDA_CONTAINER_PARAMS": "{configuration:/containerParams}",
      "AWS_GREENGRASS_LAMBDA_STATUS_TIMEOUT_SECONDS": "{configuration:/statusTimeoutInSeconds}",
      "AWS_GREENGRASS_LAMBDA_ENCODING_TYPE": "{configuration:/inputPayloadEncodingType}",
      "AWS_GREENGRASS_LAMBDA_PARAMS": "{configuration:/lambdaExecutionParameters}",
      "AWS_GREENGRASS_LAMBDA_RUNTIME_PATH": "{aws.greengrass.LambdaRuntimes:artifacts:decompressedPath}/runtime/",
      "AWS_GREENGRASS_LAMBDA_EXEC_ARGS": "[\"python3.7\",\"-u\",\"/runtime/python/lambda_runtime.py\",\"--handler=main.weather_handler\"]",
      "AWS_GREENGRASS_LAMBDA_RUNTIME": "python3.7"
    },
    "shutdown": {
      "requiresPrivilege": true,
      "script": "{aws.greengrass.LambdaLauncher:artifacts:path}/lambda-launcher stop; {aws.greengrass.LambdaLauncher:artifacts:path}/lambda-launcher clean"
    }
  }
}
brunoto
  • 91
  • 9
  • I am facing the same problem. Have you found a solution since posting this question? – Stephen Gibson Feb 16 '22 at 19:48
  • Unfortunately no, tried posting on AWS forum with no success. I decided to keep with version 1 while this problem persists... Please post an answer here if you happen to find the solution. – brunoto Feb 17 '22 at 20:31

0 Answers0