Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching on ListComponentTypes appears to have errors when using multiple Alarm Types #136

Open
haweston opened this issue Nov 17, 2022 · 1 comment
Assignees
Labels

Comments

@haweston
Copy link
Collaborator

haweston commented Nov 17, 2022

What happened:
I noticed an issue with the caching on the ListComponentTypes used by GetAlarms where it’s returning the wrong cached result after the server boots up. GetAlarms should return 1 entry for each alarm. The workspace has 6 alarms that are of a component type that extends com.amazon.iotsitewise.alarm called com.j.construction.alarm. The first time data is pulled it shows just 6, but when a refresh occurs it shows all 6 entries twice.

What you expected to happen:

After refresh there should still only be 6 entries

How to reproduce it (as minimally and precisely as possible):
Work space with zero basic alarms
Work space with zero alarms derived from basic alarm
workspace with zero sitewise alarms
workspace with 1+ alarms derived from sitewise alarms

Use GetAlarm query and display it in a Table Panel and get 1+ entries

Refresh data query and get 2 times 1+ entries

Screenshots

Screen Shot 2022-11-17 at 10 56 16 AM

Enhanced Logs
Added logging in get alarms of the basicComponentType returned on: https://github.com/grafana/grafana-iot-twinmaker-app/blob/11172022_Release/pkg/plugin/twinmaker/handler.go#L484 and sitewiseComponentType returned on https://github.com/grafana/grafana-iot-twinmaker-app/blob/11172022_Release/pkg/plugin/twinmaker/handler.go#L497

First pull logs:
ogger=plugin.grafana-iot-twinmaker-datasource t=2022-11-16T22:51:39.28193045Z level=info msg=“basic component types found: {\n ComponentTypeSummaries: [{\n Arn: \“arn:aws:iottwinmaker:us-east-1:iotrociaccount:workspace/AmazonOwnedTypesWorkspace/component-type/com.amazon.iotsitewise.alarm\“,\n ComponentTypeId: \“com.amazon.iotsitewise.alarm\“,\n CreationDateTime: 2022-06-15 00:57:17.495 +0000 UTC,\n Description: \“iotsitewise alarm native component type\“,\n Status: {\n Error: {\n\n },\n State: \“ACTIVE\“\n },\n UpdateDateTime: 2022-06-15 00:57:17.495 +0000 UTC\n }],\n WorkspaceId: \“JDemo\“\n}”
logger=plugin.grafana-iot-twinmaker-datasource t=2022-11-16T22:51:39.517052546Z level=info msg=“sitewise component types found: {\n ComponentTypeSummaries: [{\n Arn: \“arn:aws:iottwinmaker:us-east-1:282301944532:workspace/JDemo/component-type/com.j.construction.alarm\“,\n ComponentTypeId: \“com.j.construction.alarm\“,\n CreationDateTime: 2022-07-12 01:10:12.323 +0000 UTC,\n Description: \“J construction alarm type\“,\n Status: {\n Error: {\n\n },\n State: \“ACTIVE\“\n },\n UpdateDateTime: 2022-07-12 01:10:12.323 +0000 UTC\n }],\n WorkspaceId: \“JDemo\“\n}”

Second pull logs (note cache comment in logs):
logger=plugin.grafana-iot-twinmaker-datasource t=2022-11-16T22:52:31.158936973Z level=debug msg=“using cached value” key=ListComponentTypesJDemo///com.amazon.iottwinmaker.alarm.basic@
logger=plugin.grafana-iot-twinmaker-datasource t=2022-11-16T22:52:31.159047101Z level=info msg=“basic component types found: {\n ComponentTypeSummaries: [{\n Arn: \“arn:aws:iottwinmaker:us-east-1:282301944532:workspace/JDemo/component-type/com.j.construction.alarm\“,\n ComponentTypeId: \“com.j.construction.alarm\“,\n CreationDateTime: 2022-07-12 01:10:12.323 +0000 UTC,\n Description: \“Jconstruction alarm type\“,\n Status: {\n Error: {\n\n },\n State: \“ACTIVE\“\n },\n UpdateDateTime: 2022-07-12 01:10:12.323 +0000 UTC\n }],\n WorkspaceId: \“JDemo\“\n}”
logger=plugin.grafana-iot-twinmaker-datasource t=2022-11-16T22:52:31.159078839Z level=debug msg=“using cached value” key=ListComponentTypes
JDemo///com.amazon.iotsitewise.alarm@
logger=plugin.grafana-iot-twinmaker-datasource t=2022-11-16T22:52:31.159155796Z level=info msg=“sitewise component types found: {\n ComponentTypeSummaries: [{\n Arn: \“arn:aws:iottwinmaker:us-east-1:282301944532:workspace/JDemo/component-type/com.j.construction.alarm\“,\n ComponentTypeId: \“com.j.construction.alarm\“,\n CreationDateTime: 2022-07-12 01:10:12.323 +0000 UTC,\n Description: \“J construction alarm type\“,\n Status: {\n Error: {\n\n },\n State: \“ACTIVE\“\n },\n UpdateDateTime: 2022-07-12 01:10:12.323 +0000 UTC\n }],\n WorkspaceId: \“JDemo\“\n}”

Anything else we need to know?:

Environment:

  • Grafana version:

  • Plugin version:

  • OS Grafana is installed on:

  • User OS & Browser:

  • Others:

@haweston haweston added the type/bug Something isn't working label Nov 17, 2022
@toddtreece toddtreece self-assigned this Nov 17, 2022
@taleena taleena assigned haweston and unassigned toddtreece Jan 24, 2023
@haweston
Copy link
Collaborator Author

I retested this using the original dataset and it's still occurring on main branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Backlog
Development

No branches or pull requests

4 participants