Skip to content

Commit 420e9d9

Browse files
author
Manikanta Nallagatla
committed
Clean PR
1 parent bd13f8f commit 420e9d9

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/WebJobs.Script.WebHost/Controllers/InstanceController.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,15 @@ public async Task<IActionResult> Assign([FromBody] EncryptedHostAssignmentContex
5050
[Authorize(Policy = PolicyNames.AdminAuthLevel)]
5151
public async Task<IActionResult> Assign2([FromBody] FunctionsWorkerContainerAssignmentContext workerAssignmentContext)
5252
{
53+
if (workerAssignmentContext?.AssignmentContext == null || workerAssignmentContext.AssignmentContext == null)
54+
{
55+
return BadRequest("Assignment context is missing.");
56+
}
57+
5358
_logger.LogDebug($"Starting container assignment for host : {Request?.Host}");
59+
var assignmentContext = _startupContextProvider.SetContext(workerAssignmentContext.AssignmentContext);
5460

55-
return await AssignInternal(workerAssignmentContext.AssignmentContext);
61+
return await AssignInternal(assignmentContext);
5662
}
5763

5864
[HttpGet]
@@ -73,10 +79,6 @@ public IActionResult GetHttpHealthStatus()
7379

7480
private async Task<IActionResult> AssignInternal(HostAssignmentContext assignmentContext)
7581
{
76-
if (assignmentContext == null)
77-
{
78-
_logger.LogDebug($"Assignment context is null");
79-
}
8082
// before starting the assignment we want to perform as much
8183
// up front validation on the context as possible
8284
string error = await _instanceManager.ValidateContext(assignmentContext);

src/WebJobs.Script.WebHost/Models/FunctionsWorkerContainerAssignmentContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ namespace Microsoft.Azure.WebJobs.Script.WebHost.Models
99
public class FunctionsWorkerContainerAssignmentContext
1010
{
1111
[JsonProperty("assignmentContext")]
12-
public HostAssignmentContext AssignmentContext { get; private set; }
12+
public HostAssignmentContext? AssignmentContext { get; private set; }
1313
}
1414
}

src/WebJobs.Script.WebHost/StartupContextProvider.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ public virtual HostAssignmentContext SetContext(EncryptedHostAssignmentContext e
142142
string decryptedContext = EncryptionHelper.Decrypt(encryptedContext.EncryptedContext, environment: _environment);
143143
var hostAssignmentContext = JsonConvert.DeserializeObject<HostAssignmentContext>(decryptedContext);
144144

145+
return SetContext(hostAssignmentContext);
146+
}
147+
148+
public virtual HostAssignmentContext SetContext(HostAssignmentContext hostAssignmentContext)
149+
{
145150
// Don't update StartupContext for warmup requests
146151
if (!hostAssignmentContext.IsWarmupRequest)
147152
{

0 commit comments

Comments
 (0)