Prevent duplicate query in local health check

This commit is contained in:
Alan Rominger 2022-01-27 15:27:07 -05:00
parent b678d61318
commit 285ff080d0
No known key found for this signature in database
GPG Key ID: C2D7EAAA12B63559

View File

@ -263,7 +263,11 @@ class Instance(HasPolicyEditsMixin, BaseModel):
self.mark_offline(perform_save=False, errors=errors)
update_fields.extend(['cpu_capacity', 'mem_capacity', 'capacity', 'errors'])
self.save(update_fields=update_fields)
# disabling activity stream will avoid extra queries, which is important for heatbeat actions
from awx.main.signals import disable_activity_stream
with disable_activity_stream():
self.save(update_fields=update_fields)
def local_health_check(self):
"""Only call this method on the instance that this record represents"""