Skip to content

Commit

Permalink
Fix backup identification
Browse files Browse the repository at this point in the history
  • Loading branch information
franklupo committed Jun 19, 2023
1 parent a168672 commit 9a35e14
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 36 deletions.
63 changes: 29 additions & 34 deletions src/Corsinvest.ProxmoxVE.Diagnostic.Api/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Corsinvest.ProxmoxVE.Api.Extension.Utils;
using Corsinvest.ProxmoxVE.Api.Shared.Models.Cluster;
using Corsinvest.ProxmoxVE.Api.Shared.Models.Common;
using Corsinvest.ProxmoxVE.Api.Shared.Models.Node;
using Corsinvest.ProxmoxVE.Api.Shared.Models.Vm;
using Humanizer.Bytes;
using Newtonsoft.Json;

namespace Corsinvest.ProxmoxVE.Diagnostic.Api;

Expand Down Expand Up @@ -479,7 +475,7 @@ private static void CheckNode(InfoHelper.Info info,
{
Id = errorId,
ErrorCode = "IN0001",
Description = $"{updateCount} Update availble",
Description = $"{updateCount} Update available",
Context = DiagnosticResultContext.Node,
SubContext = "Update",
Gravity = DiagnosticResultGravity.Info,
Expand All @@ -495,7 +491,7 @@ private static void CheckNode(InfoHelper.Info info,
{
Id = errorId,
ErrorCode = "IN0001",
Description = $"{updateImportantCount} Update Important availble",
Description = $"{updateImportantCount} Update Important available",
Context = DiagnosticResultContext.Node,
SubContext = "Update",
Gravity = DiagnosticResultGravity.Warning,
Expand Down Expand Up @@ -599,7 +595,7 @@ private static void CheckLxc(InfoHelper.Info info,
{
var node = GetNode(info, item.Node);
var vm = node.Lxc.FirstOrDefault(a => a.Detail.VmId == item.VmId);
CheckCommonVm(info, result, settings.Qemu, vm, DiagnosticResultContext.Lxc, node, item.VmId.ToString());
CheckCommonVm(info, result, settings.Lxc, vm, DiagnosticResultContext.Lxc, node, item.VmId.ToString());
}
}

Expand Down Expand Up @@ -833,15 +829,15 @@ private static void CheckCommonVm<TDetail, TConfig>(InfoHelper.Info info,

#region Vm State
result.AddRange(vm.Pending.Where(a => a.Key == "vmstate")
.Select(a => new DiagnosticResult
{
Id = id,
ErrorCode = "WV0001",
Description = $"Found vmstate '{a.Value}'",
Context = DiagnosticResultContext.Qemu,
SubContext = "VM State",
Gravity = DiagnosticResultGravity.Critical,
}));
.Select(a => new DiagnosticResult
{
Id = id,
ErrorCode = "WV0001",
Description = $"Found vmstate '{a.Value}'",
Context = DiagnosticResultContext.Qemu,
SubContext = "VM State",
Gravity = DiagnosticResultGravity.Critical,
}));
#endregion

#region Backup
Expand All @@ -850,37 +846,36 @@ private static void CheckCommonVm<TDetail, TConfig>(InfoHelper.Info info,
if (!found)
{
//in all backup
found = info.Cluster.Backups.Where(a => a.Enabled)
.SelectMany(a => a.VmId.Split(','))
.Any(a => Convert.ToInt64(a) == vmid);
found = info.Cluster.Backups.Where(a => a.Enabled && string.IsNullOrEmpty(a.VmId))
.SelectMany(a => a.VmId.Split(','))
.Any(a => Convert.ToInt64(a) == vmid);

//in pool
if (!found)
{
//in pool
foreach (var item in info.Cluster.Backups
.Where(a => a.Enabled && !string.IsNullOrWhiteSpace(a.Pool))
.Select(a => a.Pool))
{
found = info.Pools.Where(a => a.Id == item)
.SelectMany(a => a.Detail.Members)
.Any(a => a.ResourceType == ClusterResourceType.Vm && a.VmId == vmid);

.SelectMany(a => a.Detail.Members)
.Any(a => a.ResourceType == ClusterResourceType.Vm && a.VmId == vmid);
if (found) { break; }
}
}
}

if (!found)
{
result.Add(new DiagnosticResult
if (!found)
{
Id = id,
ErrorCode = "CC0001",
Description = "vzdump backup not configured",
Context = context,
SubContext = "Backup",
Gravity = DiagnosticResultGravity.Warning,
});
result.Add(new DiagnosticResult
{
Id = id,
ErrorCode = "CC0001",
Description = "vzdump backup not configured",
Context = context,
SubContext = "Backup",
Gravity = DiagnosticResultGravity.Warning,
});
}
}

//check disk no backup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType>

<Version>1.5.10</Version>
<Version>1.5.11</Version>
<Company>Corsinvest Srl</Company>
<Authors>Corsinvest Srl</Authors>
<Copyright>Corsinvest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<Version>1.4.7</Version>
<Version>1.4.8</Version>
<TargetFramework>net7.0</TargetFramework>
<AssemblyName>cv4pve-diag</AssemblyName>
<Company>Corsinvest Srl</Company>
Expand Down

0 comments on commit 9a35e14

Please sign in to comment.