Skip to content

Commit

Permalink
show what is found
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg committed Nov 13, 2023
1 parent 19af489 commit e71acec
Showing 1 changed file with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,24 @@ def _check_if_node_is_removable(node: Node) -> bool:

def _is_task_waiting_for_resources(task: Task) -> bool:
# NOTE: https://docs.docker.com/engine/swarm/how-swarm-mode-works/swarm-task-states/
if (
not task.Status
or not task.Status.State
or not task.Status.Message
or not task.Status.Err
with log_context(
logger, level=logging.DEBUG, msg=f"_is_task_waiting_for_resources: {task}"
):
return False
return (
task.Status.State == TaskState.pending
and task.Status.Message == _PENDING_DOCKER_TASK_MESSAGE
and (
_INSUFFICIENT_RESOURCES_DOCKER_TASK_ERR in task.Status.Err
or _NOT_SATISFIED_SCHEDULING_CONSTRAINTS_TASK_ERR in task.Status.Err
if (
not task.Status
or not task.Status.State
or not task.Status.Message
or not task.Status.Err
):
return False
return (
task.Status.State == TaskState.pending
and task.Status.Message == _PENDING_DOCKER_TASK_MESSAGE
and (
_INSUFFICIENT_RESOURCES_DOCKER_TASK_ERR in task.Status.Err
or _NOT_SATISFIED_SCHEDULING_CONSTRAINTS_TASK_ERR in task.Status.Err
)
)
)


async def _associated_service_has_no_node_placement_contraints(
Expand Down Expand Up @@ -187,6 +190,10 @@ async def pending_service_tasks_with_insufficient_resources(
)

sorted_tasks = sorted(tasks, key=_by_created_dt)
logger.debug(
"found following tasks that might trigger autoscaling: %s",
[task.ID for task in tasks],
)

return [
task
Expand Down

0 comments on commit e71acec

Please sign in to comment.