예제 #1
0
    public async Async.Task Halt(Scaleset scaleset)
    {
        var shrinkQueue = new ShrinkQueue(scaleset.ScalesetId, _context.Queue, _log);
        await shrinkQueue.Delete();

        await foreach (var node in _context.NodeOperations.SearchStates(scaleSetId: scaleset.ScalesetId))
        {
            _log.Info($"{SCALESET_LOG_PREFIX} deleting node scaleset_id {scaleset.ScalesetId} machine_id {node.MachineId}");
            await _context.NodeOperations.Delete(node);
        }
        _log.Info($"{SCALESET_LOG_PREFIX} scaleset delete starting: scaleset_id:{scaleset.ScalesetId}");

        if (await _context.VmssOperations.DeleteVmss(scaleset.ScalesetId))
        {
            _log.Info($"{SCALESET_LOG_PREFIX}scaleset deleted: scaleset_id {scaleset.ScalesetId}");
            var r = await Delete(scaleset);

            if (!r.IsOk)
            {
                _log.WithHttpStatus(r.ErrorV).Error($"Failed to delete scaleset record {scaleset.ScalesetId}");
            }
        }
        else
        {
            var r = await Replace(scaleset);

            if (!r.IsOk)
            {
                _log.WithHttpStatus(r.ErrorV).Error($"Failed to save scaleset record {scaleset.ScalesetId}");
            }
        }
    }
예제 #2
0
    public async Async.Task <Pool> Halt(Pool pool)
    {
        //halt the pool immediately
        var scalesets = _context.ScalesetOperations.SearchByPool(pool.Name);
        var nodes     = _context.NodeOperations.SearchByPoolName(pool.Name);

        if (scalesets is null && nodes is null)
        {
            var poolQueue = GetPoolQueue(pool.PoolId);
            await _context.Queue.DeleteQueue(poolQueue, StorageType.Corpus);

            var shrinkQueue = new ShrinkQueue(pool.PoolId, _context.Queue, _logTracer);
            await shrinkQueue.Delete();

            _logTracer.Info($"pool stopped, deleting: {pool.Name}");
            var r = await Delete(pool);

            if (!r.IsOk)
            {
                _logTracer.Error($"Failed to delete pool: {pool.Name} due to {r.ErrorV}");
            }
        }

        if (scalesets is not null)
        {
            await foreach (var scaleset in scalesets)
            {
                if (scaleset is not null)
                {
                    await _context.ScalesetOperations.SetState(scaleset, ScalesetState.Halt);
                }
            }
        }

        if (nodes is not null)
        {
            await foreach (var node in nodes)
            {
                await _context.NodeOperations.SetHalt(node);
            }
        }

        return(pool);
    }