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>
97 lines
3.5 KiB
C#
97 lines
3.5 KiB
C#
using LogosStorageClient;
|
|
using LogosStorageClient.Hooks;
|
|
using Core;
|
|
|
|
namespace StoragePlugin
|
|
{
|
|
public class StoragePlugin : IProjectPlugin, IHasLogPrefix, IHasMetadata
|
|
{
|
|
private const bool UseContainers = true;
|
|
|
|
private readonly ILogosStorageStarter logosStorageStarter;
|
|
private readonly IPluginTools tools;
|
|
private readonly LogosStorageLogLevel defaultLogLevel = LogosStorageLogLevel.Trace;
|
|
private readonly LogosStorageHooksFactory hooksFactory = new LogosStorageHooksFactory();
|
|
private readonly ProcessControlMap processControlMap = new ProcessControlMap();
|
|
private readonly LogosStorageDockerImage logosStorageDockerImage = new LogosStorageDockerImage();
|
|
private readonly LogosStorageContainerRecipe recipe;
|
|
private readonly LogosStorageWrapper logosStorageWrapper;
|
|
|
|
public StoragePlugin(IPluginTools tools)
|
|
{
|
|
this.tools = tools;
|
|
|
|
recipe = new LogosStorageContainerRecipe(logosStorageDockerImage);
|
|
logosStorageStarter = CreateLogosStorageStarter();
|
|
logosStorageWrapper = new LogosStorageWrapper(tools, processControlMap, hooksFactory);
|
|
}
|
|
|
|
private ILogosStorageStarter CreateLogosStorageStarter()
|
|
{
|
|
if (UseContainers)
|
|
{
|
|
Log("Using Containerized Logos Storage instances");
|
|
return new ContainerLogosStorageStarter(tools, recipe, processControlMap);
|
|
}
|
|
|
|
Log("Using Binary Logos Storage instances");
|
|
return new BinaryLogosStorageStarter(tools, processControlMap);
|
|
}
|
|
|
|
public string LogPrefix => "(LogosStorage) ";
|
|
|
|
public void Awake(IPluginAccess access)
|
|
{
|
|
}
|
|
|
|
public void Announce()
|
|
{
|
|
// give codex docker image to contracts plugin.
|
|
|
|
Log($"Loaded with Logos Storage ID: '{logosStorageWrapper.GetLogosStorageId()}' - Revision: {logosStorageWrapper.GetLogosStorageRevision()}");
|
|
}
|
|
|
|
public void AddMetadata(IAddMetadata metadata)
|
|
{
|
|
metadata.Add("storageid", logosStorageWrapper.GetLogosStorageId());
|
|
metadata.Add("storagerevision", logosStorageWrapper.GetLogosStorageRevision());
|
|
}
|
|
|
|
public void Decommission()
|
|
{
|
|
logosStorageStarter.Decommission();
|
|
}
|
|
|
|
public ILogosStorageInstance[] DeployLogosStorageNodes(int numberOfNodes, Action<ILogosStorageSetup> setup)
|
|
{
|
|
var logosStorageSetup = GetSetup(numberOfNodes, setup);
|
|
return logosStorageStarter.BringOnline(logosStorageSetup);
|
|
}
|
|
|
|
public IStorageNodeGroup WrapLogosStorageContainers(ILogosStorageInstance[] instances)
|
|
{
|
|
instances = instances.Select(c => SerializeGate.Gate(c as LogosStorageInstance)).ToArray();
|
|
return logosStorageWrapper.WrapLogosStorageInstances(instances);
|
|
}
|
|
|
|
public void AddLogosStorageHooksProvider(ILogosStorageHooksProvider hooksProvider)
|
|
{
|
|
if (hooksFactory.Providers.Contains(hooksProvider)) return;
|
|
hooksFactory.Providers.Add(hooksProvider);
|
|
}
|
|
|
|
private LogosStorageSetup GetSetup(int numberOfNodes, Action<ILogosStorageSetup> setup)
|
|
{
|
|
var logosStorageSetup = new LogosStorageSetup(numberOfNodes);
|
|
logosStorageSetup.LogLevel = defaultLogLevel;
|
|
setup(logosStorageSetup);
|
|
return logosStorageSetup;
|
|
}
|
|
|
|
private void Log(string msg)
|
|
{
|
|
tools.GetLog().Log(msg);
|
|
}
|
|
}
|
|
}
|