File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change 11from datetime import timedelta
22
3- from django .conf import settings
43from django .db import models
54from django .utils import timezone
65from django .utils .translation import gettext_lazy as _
@@ -24,9 +23,17 @@ def create_key(self, project):
2423
2524 and can be revoked at any time by hitting the /api/v2/revoke/ endpoint.
2625 """
27- delta = (
28- project .container_time_limit or settings .BUILD_TIME_LIMIT
29- ) * 1.25 + settings .RTD_BUILDS_RETRY_DELAY * settings .RTD_BUILDS_MAX_RETRIES
26+ # delta = (
27+ # project.container_time_limit or settings.BUILD_TIME_LIMIT
28+ # ) * 1.25 + settings.RTD_BUILDS_RETRY_DELAY * settings.RTD_BUILDS_MAX_RETRIES
29+ #
30+ # Use 24 hours for now since we are hitting the expiry date and we shouldn't
31+ # https://github.com/readthedocs/readthedocs.org/issues/12467
32+ #
33+ # NOTE: this is the maximum time this token will be valid, since the
34+ # default behavior is to revoke from the builder itself when the build
35+ # at `after_return` immediately before the build finishes
36+ delta = 60 * 60 * 24 # 24h
3037 expiry_date = timezone .now () + timedelta (seconds = delta )
3138 name_max_length = self .model ._meta .get_field ("name" ).max_length
3239 return super ().create_key (
Original file line number Diff line number Diff line change @@ -814,14 +814,14 @@ def test_expiricy_key(self):
814814 project = get (Project )
815815 build_api_key_obj , build_api_key = BuildAPIKey .objects .create_key (project )
816816 expected = (build_api_key_obj .expiry_date - timezone .now ()).seconds
817- self .assertAlmostEqual (expected , 8250 , delta = 5 )
817+ self .assertAlmostEqual (expected , 86400 , delta = 5 )
818818
819819 # Project with a custom containe time limit
820820 project .container_time_limit = 1200
821821 project .save ()
822822 build_api_key_obj , build_api_key = BuildAPIKey .objects .create_key (project )
823823 expected = (build_api_key_obj .expiry_date - timezone .now ()).seconds
824- self .assertAlmostEqual (expected , 9000 , delta = 5 )
824+ self .assertAlmostEqual (expected , 86400 , delta = 5 )
825825
826826 def test_user_doesnt_get_full_api_return (self ):
827827 user_normal = get (User , is_staff = False )
You can’t perform that action at this time.
0 commit comments