コード例 #1
0
        public async Task <HttpResponseData> SearchStates([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "testhooks/nodeOperations/searchStates")] HttpRequestData req)
        {
            _log.Info("search states");

            var  query      = UriExtension.GetQueryComponents(req.Url);
            Guid?poolId     = UriExtension.GetGuid("poolId", query);
            Guid?scaleSetId = UriExtension.GetGuid("scaleSetId", query);

            List <NodeState>?states = default;

            if (query.ContainsKey("states"))
            {
                states = query["states"].Split('-').Select(s => Enum.Parse <NodeState>(s)).ToList();
            }
            string?poolNameString = UriExtension.GetString("poolName", query);

            PoolName?poolName = poolNameString is null ? null : PoolName.Parse(poolNameString);

            var excludeUpdateScheduled = UriExtension.GetBool("excludeUpdateScheduled", query, false);
            int?numResults             = UriExtension.GetInt("numResults", query);
            var r    = _nodeOps.SearchStates(poolId, scaleSetId, states, poolName, excludeUpdateScheduled, numResults);
            var json = JsonSerializer.Serialize(await r.ToListAsync(), EntityConverter.GetJsonSerializerOptions());
            var resp = req.CreateResponse(HttpStatusCode.OK);
            await resp.WriteStringAsync(json);

            return(resp);
        }
コード例 #2
0
ファイル: TimerWorkers.cs プロジェクト: ranweiler/onefuzz
    public async Async.Task Run([TimerTrigger("00:01:30")] TimerInfo t)
    {
        // NOTE: Update pools first, such that scalesets impacted by pool updates
        // (such as shutdown or resize) happen during this iteration `timer_worker`
        // rather than the following iteration.

        var pools = _poolOps.SearchAll();

        await foreach (var pool in pools)
        {
            if (PoolStateHelper.NeedsWork.Contains(pool.State))
            {
                _log.Info($"update pool: {pool.PoolId} ({pool.Name})");
                await _poolOps.ProcessStateUpdate(pool);
            }
        }

        // NOTE: Nodes, and Scalesets should be processed in a consistent order such
        // during 'pool scale down' operations. This means that pools that are
        // scaling down will more likely remove from the same scalesets over time.
        // By more likely removing from the same scalesets, we are more likely to
        // get to empty scalesets, which can safely be deleted.

        await _nodeOps.MarkOutdatedNodes();

        await _nodeOps.CleanupBusyNodesWithoutWork();

        var nodes = _nodeOps.SearchStates(states: NodeStateHelper.NeedsWorkStates);

        await foreach (var node in nodes)
        {
            _log.Info($"update node: {node.MachineId}");
            await _nodeOps.ProcessStateUpdate(node);
        }

        var scalesets = _scaleSetOps.SearchAll();

        await foreach (var scaleset in scalesets)
        {
            await ProcessScalesets(scaleset);
        }
    }