Skip to content

Commit

Permalink
Ensuring JobHost restart suppresion aligns with request lifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiocav committed Nov 17, 2024
1 parent 6f7b2d5 commit d830150
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/WebJobs.Script.WebHost/Controllers/FunctionsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Azure.WebJobs.Script.Description;
using Microsoft.Azure.WebJobs.Script.Management.Models;
using Microsoft.Azure.WebJobs.Script.WebHost.Extensions;
Expand Down Expand Up @@ -80,12 +81,10 @@ public async Task<IActionResult> CreateOrUpdate(string name, [FromBody] Function
return BadRequest($"{name} is not a valid function name");
}

bool success, configChanged;
FunctionMetadataResponse functionMetadataResponse;
using (fileMonitoringService.SuspendRestart(true))
{
(success, configChanged, functionMetadataResponse) = await _functionsManager.CreateOrUpdate(name, functionMetadata, Request);
}
var restartSuspensionScope = fileMonitoringService.SuspendRestart(true);
Response.RegisterForDispose(restartSuspensionScope);

(bool success, _, FunctionMetadataResponse functionMetadataResponse) = await _functionsManager.CreateOrUpdate(name, functionMetadata, Request);

if (success)
{
Expand Down Expand Up @@ -200,12 +199,10 @@ public async Task<IActionResult> Delete(string name, [FromServices] IFileMonitor
return NotFound();
}

bool deleted;
string error;
using (fileMonitoringService.SuspendRestart(true))
{
(deleted, error) = await _functionsManager.TryDeleteFunction(function);
}
var restartSuspensionScope = fileMonitoringService.SuspendRestart(true);
Response.RegisterForDispose(restartSuspensionScope);

(bool deleted, string error) = await _functionsManager.TryDeleteFunction(function);

if (deleted)
{
Expand Down

0 comments on commit d830150

Please sign in to comment.