Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 0 additions & 1 deletion landoapi/workers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ def refresh_enabled_repos(self):
for r in self.applicable_repos
if treestatus_subsystem.client.is_open(repo_clone_subsystem.repos[r].tree)
]
logger.info(f"{len(self.enabled_repos)} enabled repos: {self.enabled_repos}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was removing this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I am not sure if it is a useful thing to have in the logs constantly, since this is basically the repos in the environment variable, minus any trees that are closed. Perhaps it makes more sense to add it as a warning instead, if the two don't match?


def start(self, max_loops: int | None = None):
"""Run setup sequence and start the event loop."""
Expand Down
32 changes: 29 additions & 3 deletions landoapi/workers/landing_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,37 @@ def __init__(self, *args, **kwargs):
self.last_job_finished = None
self.refresh_enabled_repos()

def loop(self):
logger.debug(
f"{len(self.applicable_repos)} applicable repos: {self.applicable_repos}"
def check_landing_worker_warnings(self):
"""Log messages that show various important statistics about the landing worker."""
TOO_MANY_ATTEMPTS_THRESHOLD = 10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to the class-level, or perhaps add it as a kwarg so we can override it.

# TODO: should this threshold be different for try landing worker?
QUEUE_SIZE_THRESHOLD = 20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this threshold variable.

ACTIVE_STATUSES = (
LandingJobStatus.SUBMITTED,
LandingJobStatus.DEFERRED,
LandingJobStatus.IN_PROGRESS,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tuple is a copy of the applicable_statuses variable in job_queue_query. Let's move them to a variable where they can be shared (maybe a class-level LandingJobStatus.active_statuses or something along those lines).


queue_size = LandingJob.query.filter(
LandingJob.status.in_(ACTIVE_STATUSES)
).count()
if queue_size >= QUEUE_SIZE_THRESHOLD:
logger.warning(f"The landing queue size of {queue_size} exceeds threshold")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the threshold size here like f"... exceeds threshold {QUEUE_SIZE_THRESHOLD}."


runaway_jobs = LandingJob.query.filter(
LandingJob.status.in_(ACTIVE_STATUSES),
LandingJob.attempts >= TOO_MANY_ATTEMPTS_THRESHOLD,
)

if runaway_jobs.count() > 0:
job = runaway_jobs.all()[0]
logger.warning(
f"Active landing job ({job}) has too many attempts ({job.attempts})"
)
Comment on lines +113 to +117
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we cancel the job in that case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a good idea, but I think it would be outside the scope of this PR since it would require us to also send a notification email. Maybe it can be done as a follow up.


def loop(self):
self.check_landing_worker_warnings()

# Check if any closed trees reopened since the beginning of this iteration
if len(self.enabled_repos) != len(self.applicable_repos):
self.refresh_enabled_repos()
Expand Down