Skip to content

Celery: user builder instead of instance as argument #11337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions readthedocs/projects/tasks/builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def before_start(self, task_id, args, kwargs):
# once we don't need to rely on `self.data.project`.
if self.data.project.has_feature(Feature.SCALE_IN_PROTECTION):
set_builder_scale_in_protection.delay(
instance=socket.gethostname(),
builder=socket.gethostname(),
protected_from_scale_in=True,
)

Expand Down Expand Up @@ -746,7 +746,7 @@ def after_return(self, status, retval, task_id, args, kwargs, einfo):
# Disable scale-in protection on this instance
if self.data.project.has_feature(Feature.SCALE_IN_PROTECTION):
set_builder_scale_in_protection.delay(
instance=socket.gethostname(),
builder=socket.gethostname(),
protected_from_scale_in=False,
)

Expand Down
10 changes: 5 additions & 5 deletions readthedocs/projects/tasks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,14 @@ def send_external_build_status(version_type, build_pk, commit, status):


@app.task(queue="web")
def set_builder_scale_in_protection(instance, protected_from_scale_in):
def set_builder_scale_in_protection(builder, protected_from_scale_in):
"""
Set scale-in protection on this builder ``instance``.
Set scale-in protection on this builder ``builder``.

This way, AWS will not scale-in this instance while it's building the documentation.
This way, AWS will not scale-in this builder while it's building the documentation.
This is pretty useful for long running tasks.
"""
log.bind(instance=instance, protected_from_scale_in=protected_from_scale_in)
log.bind(builder=builder, protected_from_scale_in=protected_from_scale_in)

if settings.DEBUG or settings.RTD_DOCKER_COMPOSE:
log.info(
Expand All @@ -188,7 +188,7 @@ def set_builder_scale_in_protection(instance, protected_from_scale_in):
)

# web-extra-i-0c3e866c4e323928f
hostname_match = re.match(r"([a-z\-]+)-(i-[a-f0-9]+)", instance)
hostname_match = re.match(r"([a-z\-]+)-(i-[a-f0-9]+)", builder)
if not hostname_match:
log.warning(
"Unable to set scale-in protection. Hostname name matching not found.",
Expand Down