Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

self-hosted agents not removing after job finishes #3898

Open
BenH-Puregym opened this issue Jul 11, 2022 · 9 comments
Open

self-hosted agents not removing after job finishes #3898

BenH-Puregym opened this issue Jul 11, 2022 · 9 comments

Comments

@BenH-Puregym
Copy link

I have a self-hosted agent setup as per the documentation here.
I've added run once to the script as per documentation here however sometimes it removes the agent and sometimes it doesn't which results in lots of random offline agents sitting there waiting for manual removal.

The whole point of adding this run once is so that when the job finishes it removes the agent.
image

@astlock
Copy link

astlock commented Jul 14, 2022

The documentation says that the agent will be stopped, not removed. Some script from the outside should handle the removal from the pool. We do it like this.

${AZP_HOME}/run.sh --once
shutdown

function shutdown()
{
  cd ${AZP_HOME}
  echo "$(date) ${AZP_HOME}/config.sh remove"
  ${AZP_HOME}/svc.sh uninstall
  ${AZP_HOME}/config.sh remove \
      --unattended \
      --token "${TOKEN}" \
      --auth pat
  echo "$(date): ${AZP_HOME}/config.sh removed"
  exit 0
}

@BenH-Puregym
Copy link
Author

BenH-Puregym commented Jul 14, 2022

I don't see where it says it will be just be stopped? it says it will "spin down gracefully":
Agents in this mode will accept only one job and then spin down gracefully (useful for running in [Docker](https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops) on a service like Azure Container Instances).
they should be removed every time and like I said they sometimes remove but sometimes they don't remove which proves it does remove the agents just not always.

I have a cron job setup externally which targets the devops API and removes them but would be nice if it just removed it like it should without any additional script.

worth noting I'm mostly just seeing this with windows agents, linux ones seem to work fine.

@github-actions
Copy link

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

@github-actions github-actions bot added the stale label Jan 10, 2023
@BenH-Puregym
Copy link
Author

yes still an issue

@github-actions github-actions bot removed the stale label Jan 10, 2023
@kmbisset89
Copy link

Still an issue

@github-actions
Copy link

github-actions bot commented Oct 6, 2023

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

@github-actions github-actions bot added the stale label Oct 6, 2023
@Nickmman
Copy link

Nickmman commented Oct 6, 2023

Still an issue

@github-actions github-actions bot removed the stale label Oct 6, 2023
@ruisantox
Copy link

I do not have the problem running in Linux but I have the same problem running in windows agent. Version 3.230

Can we have some feedback ? thank you

btw if the job is cancelled i am 60% sure that will not exit gracefully

@cariad-chris
Copy link

Same issue even with the shutdown function.
Using SPN auth in my case. Logs say successfully removed but shows as offline in the pool

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

No branches or pull requests

7 participants