E M f496393ee6
feat: materialize openapi.yaml from the storage image; drop ApiChecker
The openapi.yaml driving NSwag client generation is no longer committed.
A build-time target in LogosStorageClient.csproj extracts it byte-for-byte
from the Logos Storage image (STORAGEDOCKERIMAGE, default latest-dist-tests)
via 'docker cp' whenever a Docker daemon is reachable, always overwriting so
the generated client matches the container under test. Where no daemon is
reachable (the CI runner pod) the spec must be pre-placed on disk by the
job's initContainer, else the build fails loudly.

Because StoragePlugin's PreBuildEvent runs before project references are
built, the old hash-injection prebuild read the spec before it could be
materialized and baked a stale hash. Materialization and the ApiChecker
hash check are therefore mutually exclusive, so ApiChecker and the
LogosStoragePluginPrebuild project are removed here.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

# Conflicts:
#	ProjectPlugins/LogosStorageClient/openapi.yaml
#	ProjectPlugins/StoragePlugin/ApiChecker.cs

# Conflicts:
#	ProjectPlugins/LogosStorageClient/openapi.yaml
#	ProjectPlugins/StoragePlugin/ApiChecker.cs
2026-06-25 16:39:13 +10:00

104 lines
3.6 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;
public ContainerLogosStorageStarter(IPluginTools pluginTools, LogosStorageContainerRecipe recipe, ProcessControlMap processControlMap)
{
this.pluginTools = pluginTools;
this.recipe = recipe;
this.processControlMap = processControlMap;
}
public ILogosStorageInstance[] BringOnline(LogosStorageSetup logosStorageSetup)
{
LogSeparator();
Log($"Starting {logosStorageSetup.Describe()}...");
var startupConfig = CreateStartupConfig(logosStorageSetup);
var containers = StartLogosStorageContainers(startupConfig, logosStorageSetup.NumberOfNodes, logosStorageSetup.Location);
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);
}
}
}