Merge lp:~facundo/ubuntuone-client/discriminate-auth-error into lp:ubuntuone-client

Proposed by Facundo Batista on 2009-10-16
Status: Merged
Approved by: dobey on 2009-10-16
Approved revision: 258
Merged at revision: not available
Proposed branch: lp:~facundo/ubuntuone-client/discriminate-auth-error
Merge into: lp:ubuntuone-client
Diff against target: 37 lines
1 file modified
ubuntuone/syncdaemon/action_queue.py (+14/-3)
To merge this branch: bzr merge lp:~facundo/ubuntuone-client/discriminate-auth-error
Reviewer Review Type Date Requested Status
dobey (community) Approve on 2009-10-16
John Lenton 2009-10-16 Approve on 2009-10-16
Review via email: mp+13490@code.launchpad.net

Commit message

Distinguish between Auth failure and other errors.

To post a comment you must log in.
Facundo Batista (facundo) wrote :

Distinguish between Auth failure and other errors.

Now, we only go to AUTH_ERROR state if the Auth effectively failed; if something else happens, we go to unknown error, not provoking the applet to drop the token.

Here are snippets of the log for each situation, tested IRL with this changes (and lp:~facundo/ubuntuone-storage-protocol/discriminate_auth_error also applied):

Authentication OK:

  State - DEBUG - START_SET_CAPABILITIES --[SYS_SET_CAPABILITIES_OK]--> START_AUTHENTICATING
  EQ - DEBUG - push_event: SYS_STATE_CHANGED, args:(), kw:{'state': <NonActiveConnectedSDState START_AUTHENTICATING>}
  ActionQueue - INFO - Oauth OK
  EQ - DEBUG - push_event: SYS_OAUTH_OK, args:(), kw:{}

Authentication FAIL:

  State - DEBUG - START_SET_CAPABILITIES_WITH_METAQ --[SYS_SET_CAPABILITIES_OK]--> START_AUTHENTICATING_WITH_METAQ
  EQ - DEBUG - push_event: SYS_STATE_CHANGED, args:(), kw:{'state': <SyncDaemonState START_AUTHENTICATING_WITH_METAQ>}
  ActionQueue - ERROR - OAuth failed: AUTHENTICATION_FAILED
  EQ - DEBUG - push_event: SYS_OAUTH_ERROR, args:(), kw:{'error': 'AUTHENTICATION_FAILED'}
  State - DEBUG - Event arrived: cancelling timeout watchdog
  ActionQueue - DEBUG - disconnected
  State - DEBUG - START_AUTHENTICATING_WITH_METAQ --[SYS_OAUTH_ERROR]--> AUTH_FAILED
  EQ - DEBUG - push_event: SYS_STATE_CHANGED, args:(), kw:{'state': <AQErrorState AUTH_FAILED>}

Server answered INTERNAL_ERROR:

  State - DEBUG - START_SET_CAPABILITIES_WITH_METAQ --[SYS_SET_CAPABILITIES_OK]--> START_AUTHENTICATING_WITH_METAQ
  EQ - DEBUG - push_event: SYS_STATE_CHANGED, args:(), kw:{'state': <SyncDaemonState START_AUTHENTICATING_WITH_METAQ>}
  ActionQueue - ERROR - StorageRequestError during OAuth: INTERNAL_ERROR
  EQ - DEBUG - push_event: SYS_UNKNOWN_ERROR, args:(), kw:{}
  State - DEBUG - Event arrived: cancelling timeout watchdog
  EQ - DEBUG - push_event: SYS_DISCONNECT, args:(), kw:{}
  HQ - INFO - HashQueue: _hasher stopped
  DBus - INFO - Shuttingdown DBusInterface!
  ActionQueue - DEBUG - disconnected
  State - DEBUG - START_AUTHENTICATING_WITH_METAQ --[SYS_UNKNOWN_ERROR]--> UNKNOWN_ERROR
  EQ - DEBUG - push_event: SYS_STATE_CHANGED, args:(), kw:{'state': <AQErrorState UNKNOWN_ERROR>}

John Lenton (chipaca) wrote :

Awesome.

review: Approve
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone/syncdaemon/action_queue.py'
2--- ubuntuone/syncdaemon/action_queue.py 2009-10-09 08:19:05 +0000
3+++ ubuntuone/syncdaemon/action_queue.py 2009-10-16 17:10:21 +0000
4@@ -44,7 +44,7 @@
5
6 from oauth import oauth
7 from ubuntuone.storageprotocol.context import get_ssl_context
8-from ubuntuone.storageprotocol import protocol_pb2
9+from ubuntuone.storageprotocol import protocol_pb2, request
10 from ubuntuone.storageprotocol.client import ThrottlingStorageClient, \
11 ThrottlingStorageClientFactory
12 from ubuntuone.syncdaemon.logger import mklog, TRACE
13@@ -975,11 +975,22 @@
14 client = self.client
15 try:
16 yield client.oauth_authenticate(oauth_consumer, self.token)
17+ except request.StorageRequestError, e:
18+ if client is not self.client:
19+ return
20+ if e.error_message.error.type == \
21+ protocol_pb2.Error.AUTHENTICATION_FAILED:
22+ logger.error("OAuth failed: %s", e)
23+ self.event_queue.push('SYS_OAUTH_ERROR', error=str(e))
24+ else:
25+ logger.error("StorageRequestError during OAuth: %s", e)
26+ self.event_queue.push('SYS_UNKNOWN_ERROR')
27+ self.deferred.callback(Failure(e))
28 except Exception, e:
29 if client is not self.client:
30 return
31- logger.error("OAuth failed: %s", e.message)
32- self.event_queue.push('SYS_OAUTH_ERROR', error=e.message)
33+ logger.error("Generic error during OAuth: %s", e)
34+ self.event_queue.push('SYS_UNKNOWN_ERROR')
35 self.deferred.callback(Failure(e))
36 else:
37 if client is not self.client:

Subscribers

People subscribed via source and target branches