Skip to content

Commit

Permalink
auth@edge: fix refreshauth error handling (#458)
Browse files Browse the repository at this point in the history
Previous "break" statement would cause None to be returned by the
function, which refreshauth did not expect. Changing it to raise pushes
the error into refresh auth so it can invalidate the token as expected.

parseauth also uses this shared function, and this should also help
avoid unexpected error handling in it.

Cosmetically, removed the traceback logging from the http method because
it didn't show anything farther up the stack than the
http_post_with_retry method (just request/urllib spam)
  • Loading branch information
troyready authored Sep 21, 2020
1 parent 2b4274d commit c0e407c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]
### Fixed
- fixed an issues causing static sites in regions other than us-east-1 to redirect to the s3 object until CloudFront was able to use the global endpoint of the bucket
- fixed uncaught static site auth@edge errors in refresh token handling

## [1.13.0] - 2020-09-14
### Added
Expand Down
4 changes: 1 addition & 3 deletions runway/hooks/staticsite/auth_at_edge/templates/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import logging
import re
import time
import traceback
from datetime import datetime
from random import random
from urllib import request # pylint: disable=no-name-in-module
Expand Down Expand Up @@ -304,9 +303,8 @@ def http_post_with_retry(url, data, headers):
except Exception as err:
LOGGER.error("HTTP POST to %s failed (attempt %s)", url, attempts)
LOGGER.error(err)
LOGGER.error(traceback.print_exc())
if attempts >= 5:
break
raise
if attempts >= 2:
# After attempting twice do some exponential backoff with jitter
time.sleep((25 * (pow(2, attempts) + random() * attempts)) / 1000)
Expand Down

0 comments on commit c0e407c

Please sign in to comment.