Merge lp://staging/~nikwen/account-polld/authentication-penalty-count into lp://staging/~ubuntu-push-hackers/account-polld/trunk

Proposed by Niklas Wenzel
Status: Merged
Approved by: Jonas G. Drange
Approved revision: 159
Merged at revision: 140
Proposed branch: lp://staging/~nikwen/account-polld/authentication-penalty-count
Merge into: lp://staging/~ubuntu-push-hackers/account-polld/trunk
Diff against target: 147 lines (+48/-35)
2 files modified
cmd/account-polld/account_manager.go (+47/-24)
cmd/account-polld/main.go (+1/-11)
To merge this branch: bzr merge lp://staging/~nikwen/account-polld/authentication-penalty-count
Reviewer Review Type Date Requested Status
Jonas G. Drange (community) Approve
PS Jenkins bot continuous-integration Pending
Alberto Mardegan Pending
Review via email: mp+272031@code.staging.launchpad.net

Commit message

When authentification of an account fails continuously, we should wait a bit before trying again (part of the issue experienced in LP: #1496773)

Description of the change

When authentification of an account fails continuously, we should wait a bit before trying again. Part of the issue experienced in LP: #1496773.

To post a comment you must log in.
Revision history for this message
Niklas Wenzel (nikwen) wrote :

This also fixes the example case provided in the description of LP: #1383298. However, it does fix the "Connection errors should not increase the penalty count" part.

Revision history for this message
Niklas Wenzel (nikwen) wrote :

I tested this now and found that this does not work yet. I'll fix it though. ;)

Revision history for this message
Niklas Wenzel (nikwen) wrote :

After better understanding the account-polld code, I now think that we can solve the "reauthentication" (aka retrying to poll the account with a previous auth failure as that results in reauthentication in case of token expiry and in ignoring temporary network issues) in a better way.

Yet, merging this one will fix the problem experienced with the current implementation, so I vote for doing so right now, but I will still prepare a better version based on this one as soon as possible that is tackling only the "reauthentication in case of token expiry and ignoring temporary issues" part instead of all auth errors.

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Ok, given that the auth errors are passed from C instead of being native Go errors, I think that this will be harder than I though. Partly revising my previous statement, I'll have to see how easy the "ignoring only temporary issues" part is going to be.

That confirms me in my suggestion to get this preliminary (but working!) solution in for now.

147. By Niklas Wenzel

Logic fix

Revision history for this message
Niklas Wenzel (nikwen) wrote :

One idea would be to manually select those that we want/don't want from libsignon-glib's signon-errors.h.

148. By Niklas Wenzel

Fix possible race condition

Revision history for this message
Niklas Wenzel (nikwen) wrote :

The last commit should fix a race condition I found while testing. I'll report back tomorrow if it is gone now.

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Tested it for a day and it seems to work fine now. :)

Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

Do you have a way for me to confirm the fix, i.e. a way to trigger the aggressive polld behaviour?

review: Needs Information
Revision history for this message
Niklas Wenzel (nikwen) wrote :

That's actually a very good question.

I often get an auth failure after rebooting my phone because it tries to authenticate before the phone establishes a network connection. You could try that and set down the authTriesUntilPenalty to 1.
Otherwise, you could try letting it run in the background for some time and your Gmail tokens will at some point have to be refreshed. However, this is always just one auth failure instead of the many from the bug report. As I noted over there, I currently don't have any idea how to reproduce that kind of behaviour. Maybe changing your Gmail account password might work... (The real password without updating it on the phone.)

What I *can* confirm though is that this doesn't break anything. I've been running it for more than a week now and I've got notifications just fine and the logs look good when a token expires. ;)

Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

I can confirm that it doesn't break anything, but from using the new steps to reproduce (which I hope replicates the bug accurately), it doesn't fix the issue either. :|

Maybe your fix fixes an authentication failure, but not a token expiry (which _easily_ causes endless loops, and is seen all over the logs attached in bug 1496773)

review: Needs Fixing
149. By Niklas Wenzel

Treat token expiry the same as auth errors

150. By Niklas Wenzel

Prevent endless refreshes on password changes

151. By Niklas Wenzel

Reset failedAuthenticationTries counter properly in token expiry cases

152. By Niklas Wenzel

Try to fix immediate reauth issue

153. By Niklas Wenzel

Fix minor issue

154. By Niklas Wenzel

Add log output

155. By Niklas Wenzel

Minor changes

156. By Niklas Wenzel

Refactoring

157. By Niklas Wenzel

Comment fixes

158. By Niklas Wenzel

Comment changes

159. By Niklas Wenzel

Remove remaining TODO comment

Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

Looks good, works well!

review: Approve
Revision history for this message
Niklas Wenzel (nikwen) wrote :

Thanks for approving! :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches