Skip to content

Container Placement Strategies not working #8836

Closed

Description

@ChrisJBurns

Summary

We have set our container replacement strategies to the following:

concourse:
    web:
        checkContainerPlacementStrategies:
        - limit-active-containers
        - fewest-build-containers
        containerPlacementStrategies:
        - limit-active-containers
        - fewest-build-containers
        noInputContainerPlacementStrategies:
        - limit-active-containers
        - fewest-build-containers

Expected results

We expect containers to be spread across the workers.

Actual results

We get workers with an disproportionate amount of containers. Often resulting in our builds failing because they've hit the container limit even if there are other workers that have plenty of room.

image

Additional context

The default max limit is 250.

Triaging info

  • Concourse version: 7.10.0
  • Browser (if applicable): Chrome

Activity

  1. xtremerui commented on Oct 10, 2023

    @xtremerui
    Contributor

    Just want to make sure if CONCOURSE_MAX_ACTIVE_CONTAINERS_PER_WORKER is set

  2. ChrisJBurns commented on Oct 11, 2023

    @ChrisJBurns
    Author

    This is on the web deployment:
    image

    This is on the stateful set for the workers:
    image

    We are adding this value in the Helm Chart: concourse.web.limitActiveContainers: 200

    So it doesn't seem to be honouring the max container limit since the screenshot in the original post had workers with over 200 containers

  3. mhlic commented on Oct 31, 2023

    @mhlic

    We are also seeing this behavior with the containers not being spread out, and the limit-active-containers not being respected

  4. ChrisJBurns commented on Feb 28, 2024

    @ChrisJBurns
    Author

    @xtremerui Any updates on the above?

  5. taylorsilva commented on Apr 4, 2024

    @taylorsilva
    Member

    So I have a guess as to why people run into issues like this still. I think it's because FindOrSelectWorker() can be called any number of times in parallel:

    func (pool Pool) FindOrSelectWorker(

    This function is how each step selects a worker and is the main entry point to container placement. We can see where it's getting called:
    image

    So if there's no limit on how many get/put/task steps are being run at any given time, I think it's highly likely that you can end up in a situation where there are a bunch of steps trying to find workers at the same time. They all look at the current data available to them and make the same choice which then goes over the limits set by operators and your worker falls over.

    My current theory is that putting a rate limit on the number of calls to FindOrSelectWorker() would help with this general "workers failing" issue. It would likely mean steps take a bit longer to initialize, but I'd wager that situation is better than "my entire job failed because the worker fell over".


    I actually have another theory now from when I was helping someone on discord.

    Now as to why the container limit is not being respected... I think it has to do with the fact that the worker placement decision happens on the web nodes and the active_containers number comes directly from the worker (not 100% sure about this "fact"). That number is periodically updated by the worker. I forget the frequency but I'd guess it's something like every 30s. This means the active_containers number could end up being very stale from the web nodes perspective.

  6. analytically commented on Mar 15, 2025

    @analytically
  7. moved this from Icebox to Backlog in Concourse Roadmapon May 21, 2025
  8. moved this from Backlog to Icebox in Concourse Roadmapon Dec 2, 2025
  9. taylorsilva commented on Apr 18, 2026

    @taylorsilva
    Member

    Looking at this again and I think I previously conflated this issue with some other behaviour I had seen related to container scheduling.

    My previous comment was referring to an issue I've observed where users set the CONCOURSE_MAX_ACTIVE_CONTAINERS_PER_WORKER to some value, and then Concourse goes past that value. This is a different issue from what OP was posting. Let's ignore what I previously commented and focus on OP's issue.

    OP was saying the strategies they passed in were not being used at all. Looking at the images posted, it looks like only the volume-locality strategy is being used based on how extremely skewed container placement is.

    The only time I've seen this is in environments where multiple web nodes are being used, and one of the web nodes is not configured with the container placement strategies as other web nodes. Once all web nodes had the same configuration, container placement worked as expected.

    I've locally tested this by running a Concourse cluster with 4 workers and running a job that generates multiple task containers. I saw a very even distribution of the containers across all four workers. The tasks did all have multiple input volumes, which would have skewed container placement if volume locality was being used.

    Default using volume-locality, one worker gets most of the containers:

    Image

    Setting all three container placement strategies to limit-active-containers,fewest-build-containers, with max containers set to 10:

    CONCOURSE_CONTAINER_PLACEMENT_STRATEGY: "limit-active-containers,fewest-build-containers"
    CONCOURSE_NO_INPUT_CONTAINER_PLACEMENT_STRATEGY: "limit-active-containers,fewest-build-containers"
    CONCOURSE_CHECK_CONTAINER_PLACEMENT_STRATEGY: "limit-active-containers,fewest-build-containers"
    CONCOURSE_MAX_ACTIVE_CONTAINERS_PER_WORKER: 10
    
    Image

    A nearly even distribution of containers across all four workers.

    I think OP has a configuration issue. From what I can tell, container placement works as expected. It looks like you're using the helm chart, so maybe there's a bug in there that's not correctly setting the placement strategies? I did a quick test rendering the helm chart with custom placement strategies and it appears to be rendered correctly. https://ci.concourse-ci.org/ is also deployed with the helm chart and is using a non-default container placement strategy. I can see our container distribution is pretty even:

    Image

    I'm going to open a PR that adds an info log line to the web command that will print all strategies being used. That should help operators verify if there's a configuration issue with any of their web nodes. That PR will close this issue.

    If you're still seeing this issue please comment here. Like I said, this may be a helm configuration issue. As far as I can tell, if configured, container placement strategies do work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions