Skip to content

Commit 4af2b11

Browse files
add vmtype alternative
1 parent c33b622 commit 4af2b11

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

CloudController.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public async Task<Machine> CreateNewRunner(string arch, string size, string runn
6969

7070
// Select VM size for job - All AMD
7171
string vmSize = _configSizes.FirstOrDefault(x => x.Arch == arch && x.Name == size)?.VmType;
72+
string vmSizeAlt = _configSizes.FirstOrDefault(x => x.Arch == arch && x.Name == size)?.VmTypeAlternative;
7273

7374
if (string.IsNullOrEmpty(vmSize))
7475
{
@@ -112,6 +113,7 @@ public async Task<Machine> CreateNewRunner(string arch, string size, string runn
112113
// Grab server type
113114
List<ServerType> srvTypes = await _client.ServerType.Get();
114115
long? srvType = srvTypes.FirstOrDefault(x => x.Name == vmSize)?.Id;
116+
long? srvTypeAlt = srvTypes.FirstOrDefault(x => x.Name == vmSizeAlt)?.Id;
115117

116118
// Grab SSH keys
117119
List<SshKey> sshKeys = await _client.SshKey.Get();
@@ -155,10 +157,18 @@ public async Task<Machine> CreateNewRunner(string arch, string size, string runn
155157
];
156158

157159
int ct = 0;
158-
160+
bool useAlternative = false;
161+
159162
while (!success)
160163
{
161-
if (ct == dataCenters.Count)
164+
165+
if (ct == dataCenters.Count && !useAlternative)
166+
{
167+
_logger.LogWarning($"Unable to create VM of type {vmSize}. Switching to alt size {vmSizeAlt}...");
168+
srvType = srvTypeAlt;
169+
ct = 0;
170+
}
171+
else if (ct == dataCenters.Count)
162172
{
163173
throw new Exception($"Unable to find any htz DC able to host {name} of size {size}");
164174
}

Models/MachineSize.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ public class MachineSize
55
public string Name { get; set; }
66
public string Arch { get; set; }
77
public string VmType { get; set; }
8+
9+
public string VmTypeAlternative { get; set; }
810
}

0 commit comments

Comments
 (0)