-
Notifications
You must be signed in to change notification settings - Fork 42
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
feat!: Ensure that all autoevent resource scheduler gets invoked properly during every boot of the target machine #445
Draft
TuhinDasgupta-eaton
wants to merge
5
commits into
edgexfoundry:main
Choose a base branch
from
TuhinDasgupta-eaton:Invoke
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9b65b43
Ensure that all autoevent resource scheduler gets invoked properly wi…
TuhinDasgupta-eaton 09e7030
Use iot_data_maps to create list of new devices being added
TuhinDasgupta-eaton fd79f1e
Signed-off-by: Tuhin Dasgupta [email protected]
TuhinDasgupta-eaton 463d138
Use iot_data_maps to create list of new devices being added
TuhinDasgupta-eaton 7918e98
Resolving build issues
TuhinDasgupta-eaton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what effect this is intended to have - looks as though autoevents will only be started for devices added via edgex_add_device?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iain-anderson Thanks for the review... I am putting my observation and analysis below point wise:
The autoevents gets invoked in 2 ways for 2 different scenarios:
1. When we boot target for the very first time:
In this scenario the device profile and default device interfaces (viz. eth0 in this case) gets added to metadata for the very first time.
After the successful addition of the device the autoevents gets scheduled and invoked from the API's in the below order:
edgex_devmap_populate_devices---->add_locked---->edgex_device_autoevent_start---->ae_runner
2. When we reboot the target or poweroff and start the target:
In this scenario the device profile and default device interfaces (viz. eth0 in this case) is already in the entry and hence when sdk tries
to add the device in metadata, it goes for a check initially where it is found that device already exits in the entry and hence the device
profile and device just needs to be updated in the sdk in order to invoke autoevents with the help of device profile update callback.
Issue in target machine:
It runs fine when target gets booted for the very first time. But after reboot a flaky issue is found. Only 1st autoevent is invoked and rest
all of them are not appearing. Hence, in this case when we try to acquire value of rest of the autoevent resources from edgex developer's UI
we get 502 error.
Root cause of the issue:
After reboot when service starts, sometimes the below order of API's gets triggered first before the device exist check while device addition.
edgex_devmap_populate_devices---->add_locked--->edgex_device_autoevent_start---->ae_runner
Since the device is already in metadata even before the existing check, the above API order tries to invoke the autoevents for the device with schedulers.
The ae_runner works in schedulers running parallely. Meanwhile there is an attempt for adding device where it is found under the check that
device already exists. Under the same check there is an API edgex_device_release call which has call for edgex_device_autoevent_stop inside
which actually stops and deletes the remaining autoevent schedulers which are yet to be run. Once stopped further no autoevents gets triggered ever.
In this scenario no device profile update callback gets invoked which also triggers the autoevents.
Possible fix:
We can make a data structure which would contain the list of only newly added device. We will do a search operation on the data structure just before edgex_device_autoevent_start
during the API order call as mentioned above earlier. This will make sure that autoevents gets invoked with this API order call only for newly added device.
edgex_devmap_populate_devices---->add_locked---->search_devsdk_device--->{if search for a new device successful}---->edgex_device_autoevent_start---->ae_runner
For devices already in the metadata entry, the autoevents will be automatically scheduled and invoked by the device profile update callback.