mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-11 17:51:33 +00:00
fix linux proxy extensions provisioning failures (#2401)
* fix linux proxy extensions provisioning failures * format Co-authored-by: stas <statis@microsoft.com>
This commit is contained in:
@ -121,7 +121,7 @@ public class Extensions : IExtensions {
|
||||
public static VMExtensionWrapper AzSecExtension(AzureLocation region) {
|
||||
return new VMExtensionWrapper {
|
||||
Location = region,
|
||||
Name = "AzureSecurityLinuxAgent",
|
||||
Name = "Microsoft.Azure.Security.Monitoring.AzureSecurityLinuxAgent",
|
||||
Publisher = "Microsoft.Azure.Security.Monitoring",
|
||||
TypePropertiesType = "AzureSecurityLinuxAgent",
|
||||
TypeHandlerVersion = "2.0",
|
||||
@ -147,7 +147,7 @@ public class Extensions : IExtensions {
|
||||
|
||||
return new VMExtensionWrapper {
|
||||
Location = region,
|
||||
Name = "AzureMonitorLinuxAgent",
|
||||
Name = "Microsoft.Azure.Monitor.AzureMonitorLinuxAgent",
|
||||
Publisher = "Microsoft.Azure.Monitor",
|
||||
TypePropertiesType = "AzureMonitorLinuxAgent",
|
||||
AutoUpgradeMinorVersion = true,
|
||||
|
@ -81,12 +81,12 @@ public class ProxyOperations : StatefulOrm<Proxy, VmState, ProxyOperations>, IPr
|
||||
public bool IsAlive(Proxy proxy) {
|
||||
var tenMinutesAgo = DateTimeOffset.UtcNow - TimeSpan.FromMinutes(10);
|
||||
|
||||
if (proxy.Heartbeat != null && proxy.Heartbeat.TimeStamp < tenMinutesAgo) {
|
||||
if (proxy.Heartbeat is not null && proxy.Heartbeat.TimeStamp < tenMinutesAgo) {
|
||||
_logTracer.Info($"last heartbeat is more than an 10 minutes old: {proxy.Region} - last heartbeat:{proxy.Heartbeat} compared_to:{tenMinutesAgo}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (proxy.Heartbeat != null && proxy.TimeStamp != null && proxy.TimeStamp < tenMinutesAgo) {
|
||||
if (proxy.Heartbeat is not null && proxy.TimeStamp is not null && proxy.TimeStamp < tenMinutesAgo) {
|
||||
_logTracer.Error($"no heartbeat in the last 10 minutes: {proxy.Region} timestamp: {proxy.TimeStamp} compared_to:{tenMinutesAgo}");
|
||||
return false;
|
||||
}
|
||||
@ -104,7 +104,7 @@ public class ProxyOperations : StatefulOrm<Proxy, VmState, ProxyOperations>, IPr
|
||||
return true;
|
||||
}
|
||||
|
||||
if (proxy.CreatedTimestamp != null) {
|
||||
if (proxy.CreatedTimestamp is not null) {
|
||||
if (proxy.CreatedTimestamp < (DateTimeOffset.UtcNow - PROXY_LIFESPAN)) {
|
||||
_logTracer.Info($"proxy older than 7 days:proxy-created:{proxy.CreatedTimestamp} state:{proxy.State}");
|
||||
return true;
|
||||
@ -205,7 +205,7 @@ public class ProxyOperations : StatefulOrm<Proxy, VmState, ProxyOperations>, IPr
|
||||
}
|
||||
|
||||
private async Task<Proxy> SetFailed(Proxy proxy, Error error) {
|
||||
if (proxy.Error != null) {
|
||||
if (proxy.Error is not null) {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
@ -231,9 +231,9 @@ public class ProxyOperations : StatefulOrm<Proxy, VmState, ProxyOperations>, IPr
|
||||
|
||||
public static Vm GetVm(Proxy proxy, InstanceConfig config) {
|
||||
var tags = config.VmssTags;
|
||||
var proxyVmSku = "";
|
||||
string proxyVmSku;
|
||||
const string PROXY_IMAGE = "Canonical:UbuntuServer:18.04-LTS:latest";
|
||||
if (config.ProxyVmSku == null) {
|
||||
if (config.ProxyVmSku is null) {
|
||||
proxyVmSku = "Standard_B2s";
|
||||
} else {
|
||||
proxyVmSku = config.ProxyVmSku;
|
||||
@ -255,7 +255,7 @@ public class ProxyOperations : StatefulOrm<Proxy, VmState, ProxyOperations>, IPr
|
||||
var vm = GetVm(proxy, config);
|
||||
var vmData = await _context.VmOperations.GetVm(vm.Name);
|
||||
|
||||
if (vmData == null) {
|
||||
if (vmData is null) {
|
||||
return await SetFailed(proxy, new Error(ErrorCode.PROXY_FAILED, new[] { "azure not able to find vm" }));
|
||||
}
|
||||
|
||||
@ -264,7 +264,7 @@ public class ProxyOperations : StatefulOrm<Proxy, VmState, ProxyOperations>, IPr
|
||||
}
|
||||
|
||||
var ip = await _context.IpOperations.GetPublicIp(vmData.NetworkProfile.NetworkInterfaces[0].Id);
|
||||
if (ip == null) {
|
||||
if (ip is null) {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user