Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
do not loose proxy objects when setting state
Browse files Browse the repository at this point in the history
  • Loading branch information
stas committed Sep 22, 2022
1 parent 4f9682d commit ef81612
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/ApiService/ApiService/Functions/TimerProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public async Async.Task Run([TimerTrigger("00:00:30")] TimerInfo myTimer) {
// out of date
if (proxy.Outdated && !(await _context.ProxyOperations.IsUsed(proxy))) {
_logger.Warning($"scaleset-proxy: outdated and not used: {proxy.Region}");
await proxyOperations.SetState(proxy, VmState.Stopping);
proxy = await proxyOperations.SetState(proxy, VmState.Stopping);
// If something is "wrong" with a proxy, delete & recreate it
} else if (!proxyOperations.IsAlive(proxy)) {
_logger.Error($"scaleset-proxy: alive check failed, stopping: {proxy.Region}");
await proxyOperations.SetState(proxy, VmState.Stopping);
proxy = await proxyOperations.SetState(proxy, VmState.Stopping);
} else {
await proxyOperations.SaveProxyConfig(proxy);
}
Expand Down Expand Up @@ -89,7 +89,9 @@ public async Async.Task Run([TimerTrigger("00:00:30")] TimerInfo myTimer) {
await foreach (var nsg in nsgOpertions.ListNsgs()) {
if (nsgOpertions.OkToDelete(regions, nsg.Data.Location!, nsg.Data.Name)) {
if (nsg.Data.NetworkInterfaces.Count == 0 && nsg.Data.Subnets.Count == 0) {
await nsgOpertions.StartDeleteNsg(nsg.Data.Name);
if (!await nsgOpertions.StartDeleteNsg(nsg.Data.Name)) {
_logger.Warning($"failed to start deleting NSG {nsg.Data.Name}");
}
}
}
}
Expand Down

0 comments on commit ef81612

Please sign in to comment.