Skip to content

Commit 5b1c4c2

Browse files
committed
Reuse SystemCapabilityEvaluator for a server mode session
1 parent 2d0b078 commit 5b1c4c2

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/AWS.Deploy.CLI/ServerMode/Controllers/DeploymentController.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,15 @@ private IServiceProvider CreateSessionServiceProvider(SessionState state)
699699
services.AddSingleton<IAWSResourceQueryer>(state.AWSResourceQueryService);
700700
}
701701

702+
if (state.SystemCapabilityEvaluator == null)
703+
{
704+
services.AddSingleton<ISystemCapabilityEvaluator, SystemCapabilityEvaluator>();
705+
}
706+
else
707+
{
708+
services.AddSingleton<ISystemCapabilityEvaluator>(state.SystemCapabilityEvaluator);
709+
}
710+
702711
services.AddCustomServices();
703712
var serviceProvider = services.BuildServiceProvider();
704713

@@ -710,9 +719,11 @@ private IServiceProvider CreateSessionServiceProvider(SessionState state)
710719
awsOptions.Region = RegionEndpoint.GetBySystemName(state.AWSRegion);
711720
});
712721

713-
// Cache the SessionAWSResourceQuery with the session state so it can be reused in future
714-
// ServerMode API calls with the same session id.
722+
// Cache the SessionAWSResourceQuery and SystemCapabilityEvaluator with the session state
723+
// so they can be reused in future ServerMode API calls with the same session id. This avoids reloading
724+
// existing resources from AWS and running the Docker/Node checks when they're not expected to change.
715725
state.AWSResourceQueryService = serviceProvider.GetRequiredService<IAWSResourceQueryer>() as SessionAWSResourceQuery;
726+
state.SystemCapabilityEvaluator = serviceProvider.GetRequiredService<ISystemCapabilityEvaluator>() as SystemCapabilityEvaluator;
716727

717728
return serviceProvider;
718729
}

src/AWS.Deploy.CLI/ServerMode/SessionState.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Threading.Tasks;
66
using AWS.Deploy.CLI.ServerMode.Services;
77
using AWS.Deploy.Common;
8+
using AWS.Deploy.Orchestration;
89

910
namespace AWS.Deploy.CLI.ServerMode
1011
{
@@ -30,6 +31,8 @@ public class SessionState
3031

3132
public SessionAWSResourceQuery? AWSResourceQueryService { get; set; }
3233

34+
public SystemCapabilityEvaluator? SystemCapabilityEvaluator { get; set; }
35+
3336
public Task? DeploymentTask { get; set; }
3437

3538
public SessionState(

0 commit comments

Comments
 (0)