Skip to content

Commit ecd0e70

Browse files
committed
fixes serialization issue of containerAdditionals
1 parent 5bbb95f commit ecd0e70

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

Framework/KubernetesWorkflow/Recipe/ContainerAdditionals.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Newtonsoft.Json.Linq;
1+
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Linq;
23

34
namespace KubernetesWorkflow.Recipe
45
{
@@ -21,14 +22,13 @@ public static ContainerAdditionals CreateFromUserData(IEnumerable<object> userDa
2122
var typeName = GetTypeName(typeof(T));
2223
var userData = Additionals.SingleOrDefault(a => a.Type == typeName);
2324
if (userData == null) return default;
24-
var jobject = (JObject)userData.UserData;
25-
return jobject.ToObject<T>();
25+
return JsonConvert.DeserializeObject<T>(userData.UserData);
2626
}
2727

2828
private static Additional ConvertToAdditional(object userData)
2929
{
3030
var typeName = GetTypeName(userData.GetType());
31-
return new Additional(typeName, userData);
31+
return new Additional(typeName, JsonConvert.SerializeObject(userData));
3232
}
3333

3434
private static string GetTypeName(Type type)
@@ -41,13 +41,13 @@ private static string GetTypeName(Type type)
4141

4242
public class Additional
4343
{
44-
public Additional(string type, object userData)
44+
public Additional(string type, string userData)
4545
{
4646
Type = type;
4747
UserData = userData;
4848
}
4949

5050
public string Type { get; }
51-
public object UserData { get; }
51+
public string UserData { get; }
5252
}
5353
}

ProjectPlugins/CodexPlugin/CodexSetup.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public class MarketplaceSetup : IMarketplaceSetup
169169
public bool IsValidator { get; private set; }
170170
public Ether InitialEth { get; private set; } = 0.Eth();
171171
public TestToken InitialTestTokens { get; private set; } = 0.Tst();
172-
public EthAccountSetup EthAccountSetup { get; private set; } = new EthAccountSetup();
172+
public EthAccountSetup EthAccountSetup { get; } = new EthAccountSetup();
173173

174174
public IMarketplaceSetup AsStorageNode()
175175
{
@@ -201,8 +201,8 @@ public override string ToString()
201201
var result = "[(clientNode)"; // When marketplace is enabled, being a clientNode is implicit.
202202
result += IsStorageNode ? "(storageNode)" : "()";
203203
result += IsValidator ? "(validator)" : "() ";
204-
result += $"Address: '{EthAccountSetup}' ";
205-
result += $"{InitialEth.Eth} / {InitialTestTokens}";
204+
result += $"Pinned address: '{EthAccountSetup}' ";
205+
result += $"{InitialEth} / {InitialTestTokens}";
206206
result += "] ";
207207
return result;
208208
}
@@ -235,6 +235,7 @@ public EthAccount[] GetAll()
235235

236236
public override string ToString()
237237
{
238+
if (!accounts.Any()) return "NoEthAccounts";
238239
return string.Join(",", accounts.Select(a => a.ToString()).ToArray());
239240
}
240241
}

ProjectPlugins/CodexPlugin/CodexStarter.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using CodexPlugin.Hooks;
22
using Core;
3+
using GethPlugin;
34
using KubernetesWorkflow;
45
using KubernetesWorkflow.Types;
56
using Logging;
@@ -38,6 +39,7 @@ public RunningPod[] BringOnline(CodexSetup codexSetup)
3839
var podInfo = GetPodInfo(rc);
3940
var podInfos = string.Join(", ", rc.Containers.Select(c => $"Container: '{c.Name}' PodLabel: '{c.RunningPod.StartResult.Deployment.PodLabel}' runs at '{podInfo.K8SNodeName}'={podInfo.Ip}"));
4041
Log($"Started node with image '{containers.First().Containers.First().Recipe.Image}'. ({podInfos})");
42+
LogEthAddress(rc);
4143
}
4244
LogSeparator();
4345

@@ -144,6 +146,13 @@ private void LogSeparator()
144146
Log("----------------------------------------------------------------------------");
145147
}
146148

149+
private void LogEthAddress(RunningPod rc)
150+
{
151+
var account = rc.Containers.First().Recipe.Additionals.Get<EthAccount>();
152+
if (account == null) return;
153+
Log($"{rc.Name} = {account}");
154+
}
155+
147156
private void Log(string message)
148157
{
149158
pluginTools.GetLog().Log(message);

0 commit comments

Comments
 (0)