Skip to content

Commit

Permalink
Merge branch 'fix_greengrass_prov' into 'main'
Browse files Browse the repository at this point in the history
fix(greengrass-provisioning): added logging and doc fix

See merge request proserve-es/robotics-and-engineering-gsp/cdf/aws-connected-device-framework!79
  • Loading branch information
hassankhokhar committed Aug 4, 2022
2 parents b18bdd2 + d7ec930 commit 53ad6e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 29 deletions.
9 changes: 9 additions & 0 deletions source/packages/services/greengrass2-provisioning/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,15 @@ A template is what defines what components should be deployed to a Greengrass2 c

Replace `<template-name>` with the name of the template.

**NOTE: The template name is used as part of creating a thing group name, thing group applies limitation on how the name can be defined. Refer to the points below for quick reference and refer to the link on the thing group naming convention from the developer document**
[Thing Group Developer Document](https://docs.aws.amazon.com/iot/latest/developerguide/thing-groups.html)

```
- Thing group names can't contain international characters, such as û, é and ñ.
- You should not use personally identifiable information in your thing group name. The thing group name can appear in unencrypted communications and reports.
- You should not use a colon character ( : ) in a thing group name. The colon character is used as a delimiter by other AWS IoT services and this can cause them to parse strings with thing group names incorrectly.
```

#### Request

```sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,35 +52,6 @@ export class DeploymentsService {
this.ggv2 = ggv2Factory();
}

// public async get(name:string): Promise<Core> {
// logger.debug(`deployments.service get: in: name:${name}`);

// ow(name, ow.string.nonEmpty);

// const coreFuture = this.coresDao.get(name);
// const installedComponentsFuture = this.ggv2.send(
// new ListInstalledComponentsCommand({
// coreDeviceThingName: name
// // TODO: manage pagination of installed components
// }));
// const [core, components] = await Promise.all([coreFuture, installedComponentsFuture]);
// logger.silly(`deployments.service get: components:${JSON.stringify(components)}`);

// core.installedComponents= [];
// if ((components.installedComponents?.length??0)>0) {
// for (const c of components.installedComponents) {
// core.installedComponents.push({
// key: c.componentName,
// version: c.componentVersion
// // TODO: determine whether installed component matches what is on template or not
// })
// }
// }

// logger.debug(`deployments.service get: exit: ${JSON.stringify(core)}`);
// return core;
// }

public async createDeployments(taskId: string, deployments: NewDeployment[]): Promise<Deployment[]> {
logger.debug(`deployments.service createDeployments: in: taskId:${taskId}, deployments: ${JSON.stringify(deployments)}`);

Expand Down Expand Up @@ -147,6 +118,7 @@ export class DeploymentsService {
try {
await this.ggv2.send(new GetCoreDeviceCommand({ coreDeviceThingName: deployment.coreName }));
} catch (e) {
logger.error(`deployments.service createDeployment: error: ${JSON.stringify(e)}`);
if (e.name === 'ResourceNotFoundException') {
this.markAsFailed(deployment, 'Core device not registered with Greengrass V2');
} else {
Expand Down Expand Up @@ -181,6 +153,7 @@ export class DeploymentsService {
logger.silly(`deployments.service createDeployment: CreateThingGroupCommandOutput: ${JSON.stringify(r)}`);
thingGroupArn = r.thingGroupArn;
} catch (e) {
logger.error(`deployments.service createDeployment: error: ${JSON.stringify(e)}`);
if (e.name === 'ResourceAlreadyExistsException') {
logger.warn(`deployments.service createDeployment: thingGroup: ${thingGroupName} already exists`);
const r = await this.iot.send(new DescribeThingGroupCommand({ thingGroupName }));
Expand Down Expand Up @@ -228,6 +201,7 @@ export class DeploymentsService {
logger.silly(`deployments.service createDeployment: TagResourceCommandOutput: ${JSON.stringify(tagResourceOutput)}`);

} catch (e) {
logger.error(`deployments.service createDeployment: error: ${JSON.stringify(e)}`);
this.markAsFailed(deployment, `Failed to create deployment: ${e.name}`);
}
}
Expand All @@ -237,6 +211,7 @@ export class DeploymentsService {
try {
await this.templatesService.associateDeployment(template)
} catch (e) {
logger.error(`deployments.service createDeployment: error: ${JSON.stringify(e)}`);
this.markAsFailed(deployment, `Failed to associate deployment with template: ${e.name}`);
}
}
Expand Down Expand Up @@ -272,6 +247,7 @@ export class DeploymentsService {
thingGroupName: template.deployment.thingGroupName
}));
} catch (e) {
logger.error(`deployments.service createDeployment: error: ${JSON.stringify(e)}`);
this.markAsFailed(deployment, `Failed to add core device to deployment thing group target: ${e.name}`);
}
}
Expand Down

0 comments on commit 53ad6e4

Please sign in to comment.