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

SDK doesn't populate Device cache on first run of device service #376

Closed
lenny-goodell opened this issue Oct 16, 2019 · 18 comments · Fixed by #379 or #384
Closed

SDK doesn't populate Device cache on first run of device service #376

lenny-goodell opened this issue Oct 16, 2019 · 18 comments · Fixed by #379 or #384
Labels
bug Something isn't working

Comments

@lenny-goodell
Copy link
Member

Using latest SDK from master (v0.0.0-20191015162939-14f308f7b3dc as of 10/16/2019) the SDK no longer populates the Device cache for new devices, i.e. when the device service first runs.

The Device cache is then populated properly when the device service is restarted.

Reproduce this issue by:

  • Updating device-virtual-go to latest SDK
  • Build and run with fresh DB.
  • Try sending GET to http://localhost:49995/api/v1/device/name/Random-Float-Device/RandomValue_Float32.
    -This will result in error stating Random-Float-Device not found

Restart the service and resend the GET results in expected result of RandomValue_Float32 being generated.

Note the Profile cache is probably not populated either.

@lenny-goodell lenny-goodell added the bug Something isn't working label Oct 16, 2019
@cloudxxx8
Copy link
Member

I've verified it works fine with device-simple, and I am looking into device-virtual

@cloudxxx8
Copy link
Member

it also works fine in device-modbus, moving this issue to device-virtual

@cloudxxx8
Copy link
Member

new issue opened in device-virtual-go
edgexfoundry/device-virtual-go#56

@lenny-goodell
Copy link
Member Author

@cloudxxx8, I discovered this with my new device-rest-go and confirmed it in device-virtual-go. I did't see this issue until updating to the latest version of the SDK.

@cloudxxx8
Copy link
Member

@lenny-intel ok, I will take more time on this by Monday. We have to fix issue before release.

@cloudxxx8 cloudxxx8 reopened this Oct 18, 2019
@lenny-goodell
Copy link
Member Author

@cloudxxx8 , I just confirmed this issue also with device-random. After a clean start (i.e. no device,profile, etc in DB) I get following error when submitting GET to http://localhost:49988/api/v1/device/name/Random-Integer-Generator01/RandomValue_Int8

Device: Random-Integer-Generator01 not found; GET /api/v1/device/name/Random-Integer-Generator01/RandomValue_Int8

Once I restarted device-random the GET works as expected.

Interestingly, autoevents are working fine.

Note that I debugged this issue with the REST DS and found that the Device cache, and likely the Profile cache are no longer being populate on the first run of the service.

@jdharms
Copy link
Contributor

jdharms commented Oct 18, 2019

@lenny-intel I think I'm running into a similar issue with some testing I'm doing today using device-virtual.

When I run device-virtual for the first time, GET commands work just fine, but PUT commands (with proper json payload) return 400's with this payload:

Handler - execWriteCmd: Put parameters parsing failed: {
	"Min_Int8": "40",
    "Max_Int8": "50"
} /api/v1/device/394fc244-d694-415b-9033-38537deb559c/GenerateRandomValue_Int8

Some logging from the device:

level=ERROR ts=2019-10-18T21:34:39.778534Z app=device-random source=command.go:306 msg="the parameter  does not match any DeviceResource in DeviceProfile"
level=ERROR ts=2019-10-18T21:34:39.778589Z app=device-random source=command.go:307 msg="Handler - execWriteCmd: Put parameters parsing failed: {\n\t\"Min_Int8\": \"40\",\n    \"Max_Int8\": \"50\"\n}"

When I restart the device-random ds, the PUT command works just fine again.

Clearing the database allows me to repro.

@cloudxxx8
Copy link
Member

This issue will be resolve after merging #379 and #381

@cloudxxx8
Copy link
Member

still needs #381

@cloudxxx8 cloudxxx8 reopened this Oct 22, 2019
@cloudxxx8
Copy link
Member

fixed by #381

@lenny-goodell
Copy link
Member Author

@cloudxxx8 , I just tested this fix using latest on master for the SDK and still have the same issue. go.mod file is using github.com/edgexfoundry/device-sdk-go v0.0.0-20191022125515-529816d7109b

529816d7109b is the commit for merging #381

@lenny-goodell lenny-goodell reopened this Oct 22, 2019
@cloudxxx8
Copy link
Member

Do you encounter this issue in both REST and Virtual?

@cloudxxx8
Copy link
Member

there is another issue needs to be fixed in virtual
edgexfoundry/device-virtual-go#59

@lenny-goodell
Copy link
Member Author

@cloudxxx8 , still see the issue in REST and Random.

@lenny-goodell
Copy link
Member Author

@cloudxxx8 , I comment on the latest for PR this about new issue created by that change.

Also seeing this error message on first run (REST and Random) and still seeing the device not found issue with the latest changes.
level=ERROR ts=2019-10-23T16:12:28.093937Z app=device-random source=profiles.go:197 msg="Error when retrieving EnableValueDescriptorManagement configuration from Core Metadata: map[LogLevel:INFO]"

Error message from device-random on first clean run:
Device: Random-Integer-Generator01 not found; GET /api/v1/device/name/Random-Integer-Generator01/RandomValue_Int8

Seeing same on REST DS.

Looks like profiles are getting cached, but not devices. I will debug some more today.

@lenny-goodell lenny-goodell reopened this Oct 23, 2019
@cloudxxx8
Copy link
Member

sorry, I am not sure the reason. We made the verification on virtual, simple, and random.
We will keep fixing this tomorrow.
Add @FelixTing and @weichou1229

@lenny-goodell
Copy link
Member Author

@cloudxxx8 , @FelixTing , @weichou1229 , I have traced this change:

42d494f#diff-f1021e656b92dfcfce91344acd0292bcL71

Adding this line back fixes my issue. I will create a PR later today.

lenny-goodell referenced this issue in lenny-goodell/device-sdk-go Oct 23, 2019
…n run

Added back call to cache.Devices().Add() in createDevice()

closes #376

Signed-off-by: lenny <leonard.goodell@intel.com>
@lenny-goodell
Copy link
Member Author

This ended up being issue with Core MetaData callback not working correctly because the mixed local (DS) and docker (core service) environment that I was testing in. Once I ran core service locally (make run), the callback worked and devices were added on first run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants