mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-05-07 18:09:36 +00:00
* ci(docker): build dist-tests images * Update to .net 10, kubernetes client 18.0.13 Kubernetes client 18.0.13 is compatible with Kubernetes 1.34.x. The Kubernetes version is selected automatically by kubeadm in docker desktop (v1.34.1). See https://github.com/kubernetes-client/csharp#version-compatibility for a compatibility table. * Updates to support Kubernetes upgrade * bump openapi.yaml to match openapi.yaml in the logos-storage-nim docker image * bump doc to .net 10 * bump docker to .net 10 * Build image with latest tag always Always build an image with a latest tag (as well as a sha commit hash) when there's a push to master * docker image tag as "latest" only when pushing to master * Update docker image to install doctl * Remove doctl install kubeconfig is now created and uses a plain bearer token instead of using doctl as a credential mgr * Rename and remove all instances of Codex * Further remove CodexNetDeployer as it is no longer needed --------- Co-authored-by: Adam Uhlíř <adam@uhlir.dev>
108 lines
3.8 KiB
C#
108 lines
3.8 KiB
C#
using LogosStorageClient;
|
|
using Core;
|
|
using KubernetesWorkflow;
|
|
using KubernetesWorkflow.Types;
|
|
using Utils;
|
|
|
|
namespace StoragePlugin
|
|
{
|
|
public class ContainerLogosStorageStarter : ILogosStorageStarter
|
|
{
|
|
private readonly IPluginTools pluginTools;
|
|
private readonly ProcessControlMap processControlMap;
|
|
private readonly LogosStorageContainerRecipe recipe;
|
|
private readonly ApiChecker apiChecker;
|
|
|
|
public ContainerLogosStorageStarter(IPluginTools pluginTools, LogosStorageContainerRecipe recipe, ProcessControlMap processControlMap)
|
|
{
|
|
this.pluginTools = pluginTools;
|
|
this.recipe = recipe;
|
|
this.processControlMap = processControlMap;
|
|
apiChecker = new ApiChecker(pluginTools);
|
|
}
|
|
|
|
public ILogosStorageInstance[] BringOnline(LogosStorageSetup logosStorageSetup)
|
|
{
|
|
LogSeparator();
|
|
Log($"Starting {logosStorageSetup.Describe()}...");
|
|
|
|
var startupConfig = CreateStartupConfig(logosStorageSetup);
|
|
|
|
var containers = StartLogosStorageContainers(startupConfig, logosStorageSetup.NumberOfNodes, logosStorageSetup.Location);
|
|
|
|
apiChecker.CheckCompatibility(containers);
|
|
|
|
foreach (var rc in containers)
|
|
{
|
|
var podInfo = GetPodInfo(rc);
|
|
var podInfos = string.Join(", ", rc.Containers.Select(c => $"Container: '{c.Name}' PodLabel: '{c.RunningPod.StartResult.Deployment.PodLabel}' runs at '{podInfo.K8SNodeName}'={podInfo.Ip}"));
|
|
Log($"Started node with image '{containers.First().Containers.First().Recipe.Image}'. ({podInfos})");
|
|
LogEthAddress(rc);
|
|
}
|
|
LogSeparator();
|
|
|
|
return containers.Select(CreateInstance).ToArray();
|
|
}
|
|
|
|
public void Decommission()
|
|
{
|
|
}
|
|
|
|
private StartupConfig CreateStartupConfig(LogosStorageSetup logosStorageSetup)
|
|
{
|
|
var startupConfig = new StartupConfig();
|
|
startupConfig.NameOverride = logosStorageSetup.NameOverride;
|
|
startupConfig.Add(logosStorageSetup);
|
|
return startupConfig;
|
|
}
|
|
|
|
private RunningPod[] StartLogosStorageContainers(StartupConfig startupConfig, int numberOfNodes, ILocation location)
|
|
{
|
|
var futureContainers = new List<FutureContainers>();
|
|
for (var i = 0; i < numberOfNodes; i++)
|
|
{
|
|
var workflow = pluginTools.CreateWorkflow();
|
|
futureContainers.Add(workflow.Start(1, location, recipe, startupConfig));
|
|
}
|
|
|
|
return futureContainers
|
|
.Select(f => f.WaitForOnline())
|
|
.ToArray();
|
|
}
|
|
|
|
private PodInfo GetPodInfo(RunningPod rc)
|
|
{
|
|
var workflow = pluginTools.CreateWorkflow();
|
|
return workflow.GetPodInfo(rc);
|
|
}
|
|
|
|
private ILogosStorageInstance CreateInstance(RunningPod pod)
|
|
{
|
|
var instance = LogosStorageInstanceContainerExtension.CreateFromPod(pod);
|
|
var processControl = new LogosStorageContainerProcessControl(pluginTools, pod, onStop: () =>
|
|
{
|
|
processControlMap.Remove(instance);
|
|
});
|
|
processControlMap.Add(instance, processControl);
|
|
return instance;
|
|
}
|
|
|
|
private void LogSeparator()
|
|
{
|
|
Log("----------------------------------------------------------------------------");
|
|
}
|
|
|
|
private void LogEthAddress(RunningPod rc)
|
|
{
|
|
var account = rc.Containers.First().Recipe.Additionals.Get<EthAccount>();
|
|
if (account == null) return;
|
|
Log($"{rc.Name} = {account}");
|
|
}
|
|
|
|
private void Log(string message)
|
|
{
|
|
pluginTools.GetLog().Log(message);
|
|
}
|
|
}
|
|
}
|