Skip to content

Commit

Permalink
Merge pull request #1315 from yaacov/if-vm-archived-finished-ro-runni…
Browse files Browse the repository at this point in the history
…ng-ignore-errors

🐞 If Plan finished ignore errors and warnings in plan
  • Loading branch information
yaacov authored Sep 3, 2024
2 parents 977b511 + 0aa07cd commit d966985
Showing 1 changed file with 29 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,14 @@ export const getPlanPhase = (data: PlanData): PlanPhase => {

if (!plan) return 'Unknown';

// Check condition category
const isCritical = plan?.status?.conditions?.find(
(c) => c.category === 'Critical' && c.status === 'True',
);

if (isCritical) {
return 'Error';
}

// Check condition category
const isWarn = plan?.status?.conditions?.find(
(c) => c.category === 'Warn' && c.status === 'True',
);

// Check for vm errors
const vmError = plan?.status?.migration?.vms?.find((vm) => vm?.error);

// Check condition type
const conditions = getConditions(plan);

if (!conditions || conditions?.length < 1) {
return 'Unknown';
}

// Check for Archived
if (plan?.spec?.archived && !conditions.includes('Archived')) {
return 'Archiving';
}
Expand All @@ -39,10 +23,33 @@ export const getPlanPhase = (data: PlanData): PlanPhase => {
return 'Archived';
}

// Check for Succeeded
if (conditions.includes('Succeeded')) {
return 'Succeeded';
}

// Check for Canceled
if (conditions.includes('Canceled')) {
return 'Canceled';
}

// CHeck for Running
if (conditions.includes('Executing')) {
return 'Running';
}

// Check condition category
const isCritical = plan?.status?.conditions?.find(
(c) => c.category === 'Critical' && c.status === 'True',
);

if (isCritical) {
return 'Error';
}

// Check for vm errors
const vmError = plan?.status?.migration?.vms?.find((vm) => vm?.error);

if (conditions.includes('Failed')) {
return 'Failed';
}
Expand All @@ -51,18 +58,15 @@ export const getPlanPhase = (data: PlanData): PlanPhase => {
return 'vmError';
}

// Check condition category
const isWarn = plan?.status?.conditions?.find(
(c) => c.category === 'Warn' && c.status === 'True',
);

if (isWarn) {
return 'Warning';
}

if (conditions.includes('Canceled')) {
return 'Canceled';
}

if (conditions.includes('Executing')) {
return 'Running';
}

if (conditions.includes('Ready')) {
return 'Ready';
}
Expand Down

0 comments on commit d966985

Please sign in to comment.