Deleting AutoScale table entries on vmss shutdown. (#3455)

* Deleting AutoScale table entries on vmss shutdown.

* FIx.

* Trying again

* Fixing delete.

* Updating autoscale to orm

* Removing comments.
This commit is contained in:
Noah McGregor Harper 2023-08-28 14:53:32 -07:00 committed by GitHub
parent c4d0cd754b
commit 10bb79a08c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -1,5 +1,4 @@
using System.Net;
using System.Text.Json;
using System.Text.Json;
using System.Threading.Tasks;
using ApiService.OneFuzzLib.Orm;
using Azure;
@ -10,9 +9,7 @@ using Microsoft.IdentityModel.Tokens;
namespace Microsoft.OneFuzz.Service;
public interface IAutoScaleOperations {
public Async.Task<ResultVoid<(HttpStatusCode Status, string Reason)>> Insert(AutoScale autoScale);
public interface IAutoScaleOperations : IOrm<AutoScale> {
public Async.Task<AutoScale?> GetSettingsForScaleset(ScalesetId scalesetId);

View File

@ -499,6 +499,13 @@ public class ScalesetOperations : StatefulOrm<Scaleset, ScalesetState, ScalesetO
_logTracer.AddHttpStatus(r.ErrorV);
_logTracer.LogError("Failed to delete scaleset record {ScalesetId}", scaleset.ScalesetId);
}
var autoscaleEntry = await _context.AutoScaleOperations.GetSettingsForScaleset(scaleset.ScalesetId);
if (autoscaleEntry is null) {
_logTracer.LogInformation("Could not find autoscale settings for scaleset {ScalesetId}", scaleset.ScalesetId);
} else {
_logTracer.LogInformation("Deleting autoscale entry for scaleset {ScalesetId}", scaleset.ScalesetId);
_ = await _context.AutoScaleOperations.Delete(autoscaleEntry);
}
} else {
var r = await Update(scaleset);
if (!r.IsOk) {