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

EdgeAgent: Fix error handling in GetTwin #1329

Merged
merged 5 commits into from
Jun 13, 2019

Conversation

varunpuranik
Copy link
Contributor

The issue -

  • Currently the EdgeAgentConnection gets the EdgeAgent config from the twin once initially, and thereafter via a desired properties update callback or periodic GetTwin call.
  • The twin that is returned in the Reconcile loop is the cached value.
  • If getting the twin and parsing it fails, an error is returned to the Reconcile loop (via the IConfigSource interface) instead.
  • Because of this, if the periodic GetTwin call fails, an error gets cached and returned for each of the subsequent Reconcile loops.

The fix

  • The GetTwin code has retry to deal with transient errors. This PR updates that code to get a new ModuleClient every time. This takes care of the case where the SDK throws an ObjectDisposedException on the GetTwin call and goes into a bad state. The subsequent GetTwin calls should now succeed.
  • If the GetTwin fails, it is not regarded as bad config and not returned to Reconcile. Instead the previous cached config is returned. Only if a GetTwin succeeds but parsing the twin fails, it is regarded as bad input and returned to the Reconcile logic as an Exception.

}
catch (Exception ex) when (!ex.IsFatal())
catch (Exception e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

catch if not fatal?

@varunpuranik varunpuranik merged commit 85f7887 into Azure:master Jun 13, 2019
@varunpuranik varunpuranik deleted the eafix1 branch June 13, 2019 18:52
varunpuranik added a commit to varunpuranik/iotedge that referenced this pull request Jun 18, 2019
* Fix EdgeAgentConnection

* Add test

* Add tests

* Fix test

* Fix test and cleanup
myagley pushed a commit that referenced this pull request Jun 18, 2019
* EdgeAgent: Fix error handling in GetTwin (#1329)

* Fix EdgeAgentConnection

* Add test

* Add tests

* Fix test

* Fix test and cleanup

* Add when not fatal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants