Skip to content

Commit 59c95b6

Browse files
authored
Logs: add build_id attribute to set_builder_scale_in_protection (#12504)
This will help us to know what builds weren't unable to set AWS scale-in protection. It could give us some insights about why these builds were killed.
1 parent 105e124 commit 59c95b6

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

readthedocs/projects/tasks/builds.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ def before_start(self, task_id, args, kwargs):
430430
# once we don't need to rely on `self.data.project`.
431431
if self.data.project.has_feature(Feature.SCALE_IN_PROTECTION):
432432
set_builder_scale_in_protection.delay(
433+
build_id=self.data.build_pk,
433434
builder=socket.gethostname(),
434435
protected_from_scale_in=True,
435436
)
@@ -783,6 +784,7 @@ def after_return(self, status, retval, task_id, args, kwargs, einfo):
783784
# Disable scale-in protection on this instance
784785
if self.data.project.has_feature(Feature.SCALE_IN_PROTECTION):
785786
set_builder_scale_in_protection.delay(
787+
build_id=self.data.build_pk,
786788
builder=socket.gethostname(),
787789
protected_from_scale_in=False,
788790
)

readthedocs/projects/tasks/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,15 @@ def send_external_build_status(version_type, build_pk, commit, status):
192192

193193

194194
@app.task(queue="web")
195-
def set_builder_scale_in_protection(builder, protected_from_scale_in):
195+
def set_builder_scale_in_protection(build_id, builder, protected_from_scale_in):
196196
"""
197197
Set scale-in protection on this builder ``builder``.
198198
199199
This way, AWS will not scale-in this builder while it's building the documentation.
200200
This is pretty useful for long running tasks.
201201
"""
202202
structlog.contextvars.bind_contextvars(
203+
build_id=build_id,
203204
builder=builder,
204205
protected_from_scale_in=protected_from_scale_in,
205206
)

0 commit comments

Comments
 (0)