Setting up future-containers

This commit is contained in:
benbierens 2024-04-09 09:30:45 +02:00
parent 605004286a
commit 69666d3fee
No known key found for this signature in database
GPG Key ID: 877D2C2E09A22F3A
4 changed files with 42 additions and 6 deletions

View File

@ -43,6 +43,11 @@ namespace KubernetesWorkflow
return new StartResult(cluster, containerRecipes, deployment, internalService, externalService); return new StartResult(cluster, containerRecipes, deployment, internalService, externalService);
} }
public void WaitUntilOnline(RunningContainer container)
{
WaitUntilDeploymentOnline(container.Recipe.Name);
}
public PodInfo GetPodInfo(RunningDeployment deployment) public PodInfo GetPodInfo(RunningDeployment deployment)
{ {
var pod = GetPodForDeployment(deployment); var pod = GetPodForDeployment(deployment);
@ -372,7 +377,6 @@ namespace KubernetesWorkflow
}; };
client.Run(c => c.CreateNamespacedDeployment(deploymentSpec, K8sNamespace)); client.Run(c => c.CreateNamespacedDeployment(deploymentSpec, K8sNamespace));
WaitUntilDeploymentOnline(deploymentSpec.Metadata.Name);
var name = deploymentSpec.Metadata.Name; var name = deploymentSpec.Metadata.Name;
return new RunningDeployment(name, podLabel); return new RunningDeployment(name, podLabel);

View File

@ -9,8 +9,8 @@ namespace KubernetesWorkflow
public interface IStartupWorkflow public interface IStartupWorkflow
{ {
IKnownLocations GetAvailableLocations(); IKnownLocations GetAvailableLocations();
RunningContainers Start(int numberOfContainers, ContainerRecipeFactory recipeFactory, StartupConfig startupConfig); FutureContainers Start(int numberOfContainers, ContainerRecipeFactory recipeFactory, StartupConfig startupConfig);
RunningContainers Start(int numberOfContainers, ILocation location, ContainerRecipeFactory recipeFactory, StartupConfig startupConfig); FutureContainers Start(int numberOfContainers, ILocation location, ContainerRecipeFactory recipeFactory, StartupConfig startupConfig);
PodInfo GetPodInfo(RunningContainer container); PodInfo GetPodInfo(RunningContainer container);
PodInfo GetPodInfo(RunningContainers containers); PodInfo GetPodInfo(RunningContainers containers);
CrashWatcher CreateCrashWatcher(RunningContainer container); CrashWatcher CreateCrashWatcher(RunningContainer container);
@ -45,12 +45,12 @@ namespace KubernetesWorkflow
return locationProvider.GetAvailableLocations(); return locationProvider.GetAvailableLocations();
} }
public RunningContainers Start(int numberOfContainers, ContainerRecipeFactory recipeFactory, StartupConfig startupConfig) public FutureContainers Start(int numberOfContainers, ContainerRecipeFactory recipeFactory, StartupConfig startupConfig)
{ {
return Start(numberOfContainers, KnownLocations.UnspecifiedLocation, recipeFactory, startupConfig); return Start(numberOfContainers, KnownLocations.UnspecifiedLocation, recipeFactory, startupConfig);
} }
public RunningContainers Start(int numberOfContainers, ILocation location, ContainerRecipeFactory recipeFactory, StartupConfig startupConfig) public FutureContainers Start(int numberOfContainers, ILocation location, ContainerRecipeFactory recipeFactory, StartupConfig startupConfig)
{ {
return K8s(controller => return K8s(controller =>
{ {
@ -67,7 +67,18 @@ namespace KubernetesWorkflow
{ {
componentFactory.Update(controller); componentFactory.Update(controller);
} }
return rc; return new FutureContainers(rc, this);
});
}
public void WaitUntilOnline(RunningContainers rc)
{
K8s(controller =>
{
foreach (var c in rc.Containers)
{
controller.WaitUntilOnline(c);
}
}); });
} }

View File

@ -0,0 +1,20 @@
namespace KubernetesWorkflow.Types
{
public class FutureContainers
{
private readonly RunningContainers runningContainers;
private readonly StartupWorkflow workflow;
public FutureContainers(RunningContainers runningContainers, StartupWorkflow workflow)
{
this.runningContainers = runningContainers;
this.workflow = workflow;
}
public RunningContainers WaitForOnline()
{
workflow.WaitUntilOnline(runningContainers);
return runningContainers;
}
}
}

View File

@ -93,6 +93,7 @@ namespace CodexPlugin
var workflow = pluginTools.CreateWorkflow(); var workflow = pluginTools.CreateWorkflow();
result.Add(workflow.Start(1, location, recipe, startupConfig)); result.Add(workflow.Start(1, location, recipe, startupConfig));
} }
return result.ToArray(); return result.ToArray();
} }