microsoft / azure-container-apps

Roadmap and issues for Azure Container Apps
MIT License
372 stars 29 forks source link

Improve "Tutorial: Deploy self-hosted CI/CD runners" #1316

Closed calle2010 closed 1 month ago

calle2010 commented 1 month ago

Please provide us with the following information:

This issue is a: (mark with an x)

Issue description

We are following this tutorial: https://learn.microsoft.com/en-us/azure/container-apps/tutorial-ci-cd-runners-jobs?tabs=bash&pivots=container-apps-jobs-self-hosted-ci-cd-azure-pipelines

Beyond of what the tutorial explains, we want to have two different types of agents, offering different capabilities, e. g. a "Java" agent and a "Node.js" agent. Therefore, we created

We set "min-executions" to 0, just as in the tutorial.

Now, the issue is, whenever a build needs an agent from the pool, one agent of each type is created, but only one is used by the job and terminates after the build. The other one stays online because there was no job.

To reduce costs, we'd rather have no idling agent. Also, the risk is the idle agent is later used by another build job and then terminated in the middle of the build because the "replica-timeout" is reached.

Steps to reproduce

  1. follow the tutorial
  2. Do the steps "Create a placeholder self-hosted agent" and "Create a self-hosted agent as an event-driven job" again, with different scale-rule-name, but the same pool name. Use different environment variables to specify capabilities.
  3. Run a job specifying a "demand" which matches only one of the agents.

Expected behavior [What you expected to happen.]

Just the matching agent as specified by the demand should be started.

Actual behavior [What actually happened.]

Two agents are started, but only one is used by the job. The other stays online and waits for a matching job.

Additional context

I think the behavior we see is correct, but unsatisfactory.

I would wish the tutorial to explain this situation and recommend a better way. I guess we would have to use two different pools for the different kinds of agents? But we didn't try this, yet.

v-vish commented 1 month ago

@calle2010 It's important to specify the demands in the scaler configuration so that KEDA can correctly determine when to initiate a job execution. By setting these demands, KEDA ensures that jobs are only triggered when the required conditions are met, such as the available agent pool having the necessary capabilities.

Please refer this URL for more details :https://keda.sh/docs/2.14/scalers/azure-pipelines/.

If you need any further assistance, feel free to reach out. Thanks again!

calle2010 commented 1 month ago

We got it working based on your hint. In hindsight, it would be great to put this hint into the tutorial, in section "Create a self-hosted agent as an event-driven job" in the table for scale rule metadata parameter, e. g. "The metadata for the scale rule. If you want to have multiple agents in the same pool with different capabilities, see the Keda documentation (link)."

v-vish commented 1 month ago

Thank you for the feedback! We're glad the hint was helpful, and it's great to hear you got it working. We’ll make sure to update that section with a link to the KEDA documentation for further reference.