microsoft / azure-pipelines-agent

Azure Pipelines Agent 🚀
MIT License
1.7k stars 856 forks source link

[Question]: Agent running with --once in container, with two jobs, shows as offline when second one queued. #4338

Open dazinator opened 12 months ago

dazinator commented 12 months ago

Describe your question

I am running a pipelines agent as a docker container (swarm) - so that it shows up in pipelines --> environments.

The docker container is run with the --once argument and a restart policy with a small delay a mentioned in the docs here: https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops#start-the-image

devops-pipelines-agent:    
    image: foo.azurecr.io/foo/environment-agent:${PIPELINES_AGENT_TAG}
    deploy:
      replicas: 1      
      restart_policy:        
        condition: any
        delay: 1s
    command: --once

What I find is that when I have an azure-pipelines..yaml with two jobs to be run one after the other, on the agent e.g shortened for brevity:

jobs:
  - deployment: thingA
  - deployment: thingB
    dependsOn: thingA
    condition: succeeded()

The agent goes offline after the first job, and azure devops then fails the second job due to the agent being "offline"

image

The agent is only offline for a very breif period of time according to the restart policy, a few seconds plus start uptime etc.

I thought I could work around this by scaling theagent to replica's 2. However as both agents are the same environnment, this just causes the jobs to fan oout and be run oon both agents, as oopposed to being queued and picked up by the first available "online".

I like the features of environments agents,and deployment jobs, but this seems like a bug? I could switch too agent pools with replica's 2 and my above suggested workaround should hopefully then work, but this should nnot be necessary?

Versions

Current agent version: '3.220.5' Agent running as: 'root'

running pipeline on dev.azure.com

Environment type (Please select at least one enviroment where you face this issue)

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Operation system

Ubuntu 20.04

Version controll system

git (azure devops)

Azure DevOps Server Version (if applicable)

No response

DenisRumyantsev commented 11 months ago

Hi, @dazinator thanks for reporting! We are currently working on more prioritized issues but will get back to this one soon.

github-actions[bot] commented 5 months ago

This issue has had no activity in 180 days. Please comment if it is not actually stale

dazinator commented 5 months ago

Not stale