mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-19 16:57:40 +03:00
remove purge_old_agents (#6439)
This script was supposed to remove old agents from the Azure Pipelines UI. It may have been useful at some time (notably, when we used ephemeral instances, they did not necessarily get to run their shutdown script), but as it stands now, it's broken. The output from that step ends in: ``` error: 2 derivations need to be built, but neither local builds ('--max-jobs') nor remote builds ('--builders') are enabled ``` after listing the nix packages it would build. Furthermore, it does not seem to be useful as I have not seen any spurious entry in the agents list on Azure since we switched to permanent nodes, on either the Linux or Windows side (and this would only run on Linux, if it ran). I'm also not convinced it ever ran, as I used to see a lot of spurious machines on both Linux and Windows when we did use ephemeral instances. CHANGELOG_BEGIN CHANGELOG_END
This commit is contained in:
parent
d839acdbce
commit
2923048935
@ -1,31 +0,0 @@
|
||||
{ pkgs, python3 }:
|
||||
|
||||
python3.pkgs.buildPythonPackage rec {
|
||||
pname = "azure-devops";
|
||||
version = "5.0.0b4";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "Microsoft";
|
||||
repo = "azure-devops-python-api";
|
||||
rev = version;
|
||||
sha256 = "0g6p839ssn75ly4n4a2vdjfivb37yfv1328k28azm0r4grz3l694";
|
||||
};
|
||||
|
||||
postUnpack = ''
|
||||
rm -R source/scripts
|
||||
mv source/azure-devops/* source
|
||||
rmdir source/azure-devops
|
||||
'';
|
||||
|
||||
propagatedBuildInputs = [
|
||||
python3.pkgs.msrest
|
||||
];
|
||||
|
||||
doCheck = false;
|
||||
|
||||
meta = with pkgs.stdenv.lib; {
|
||||
description = "Azure DevOps Python API";
|
||||
homepage = "https://github.com/Microsoft/azure-devops-python-api";
|
||||
license = licenses.mit;
|
||||
};
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
{ system ? builtins.currentSystem }:
|
||||
|
||||
let
|
||||
pkgs = import (import ../../nix/nixpkgs) {
|
||||
inherit system;
|
||||
config = {};
|
||||
overlays = [];
|
||||
};
|
||||
|
||||
azure-devops = pkgs.callPackage ./azure-devops.nix { };
|
||||
in
|
||||
pkgs.mkShell {
|
||||
buildInputs = [ azure-devops ];
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 .
|
||||
# Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# This script purges agents older than 25 hours in a given pool
|
||||
# Pass VSTS_{ACCOUNT,POOL,TOKEN} as environment variables to it
|
||||
import datetime
|
||||
import os
|
||||
import sys
|
||||
|
||||
from azure.devops.connection import Connection
|
||||
from msrest.authentication import BasicAuthentication
|
||||
|
||||
CUTOFF_HOURS=25
|
||||
|
||||
VSTS_ACCOUNT = os.environ["VSTS_ACCOUNT"]
|
||||
VSTS_POOL = os.environ["VSTS_POOL"]
|
||||
VSTS_TOKEN = os.environ["VSTS_TOKEN"]
|
||||
|
||||
credentials = BasicAuthentication('', VSTS_TOKEN)
|
||||
connection = Connection(base_url="https://dev.azure.com/" + VSTS_ACCOUNT,
|
||||
creds=credentials)
|
||||
|
||||
agent_client = connection.clients_v5_1.get_task_agent_client()
|
||||
|
||||
# retrieve pool id from name
|
||||
pool_id = next(filter(lambda x: x.name == VSTS_POOL, agent_client.get_agent_pools())).id
|
||||
|
||||
for agent in agent_client.get_agents(pool_id):
|
||||
# agents should be killed after 24 hours max
|
||||
cutoff_time = datetime.datetime.now(datetime.timezone.utc)\
|
||||
- datetime.timedelta(hours=CUTOFF_HOURS)
|
||||
if agent.created_on < cutoff_time:
|
||||
if agent.status == 'offline':
|
||||
print("cleaning up agent #{} ({})".format(agent.id, agent.name))
|
||||
agent_client.delete_agent(pool_id, agent.id)
|
||||
else:
|
||||
print("agent still online: #{} ({})".format(agent.id, agent.name),
|
||||
file=sys.stderr)
|
||||
else:
|
||||
print("skipping agent #{} ({}), too new".format(agent.id, agent.name))
|
@ -179,12 +179,6 @@ echo "build:linux --disk_cache=~/.bazel-cache" > ~/.bazelrc
|
||||
) || true
|
||||
CACHE_WARMUP
|
||||
|
||||
# Purge old agents
|
||||
su --login vsts <<'PURGE_OLD_AGENTS'
|
||||
cd daml && \
|
||||
VSTS_ACCOUNT=${vsts_account} VSTS_POOL=${vsts_pool} VSTS_TOKEN=${vsts_token} ./ci/azure-cleanup/purge_old_agents.py || true
|
||||
PURGE_OLD_AGENTS
|
||||
|
||||
# Remove /home/vsts/daml folder that might be present from cache warmup
|
||||
rm -R /home/vsts/daml || true
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user