Skip to content

Commit

Permalink
Fix Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Honigeintopf committed Nov 4, 2024
1 parent 9605a18 commit c6b5758
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
12 changes: 11 additions & 1 deletion controllers/set/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ func (c *controller) deleteIfUnhealthyOrTimeout(r *controllers.Ctx[*v2.FirewallS
}

func (c *controller) isFirewallUnhealthy(fw *v2.Firewall) bool {

statusReport := evaluateFirewallConditions(fw, c.c.GetFirewallHealthTimeout())
return statusReport.IsUnhealthy

if statusReport.IsReady {
return false
}

if statusReport.IsUnhealthy {
return true
}

return false
}
13 changes: 7 additions & 6 deletions controllers/set/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func evaluateFirewallConditions(fw *v2.Firewall, healthTimeout time.Duration) Fi

return FirewallConditionStatus{
IsReady: allConditionsMet,
IsProgressing: created && allocationTimeExceeded,
IsUnhealthy: !allConditionsMet || unhealthyTimeExceeded,
IsProgressing: allocationTimeExceeded,
IsUnhealthy: unhealthyTimeExceeded,
}
}

Expand All @@ -38,14 +38,15 @@ func (c *controller) setStatus(r *controllers.Ctx[*v2.FirewallSet], ownedFirewal

for _, fw := range ownedFirewalls {
statusReport := evaluateFirewallConditions(fw, c.c.GetFirewallHealthTimeout())

if statusReport.IsReady {
r.Target.Status.ReadyReplicas++
} else if statusReport.IsProgressing {
continue
}
if statusReport.IsProgressing {
r.Target.Status.ProgressingReplicas++
} else {
r.Target.Status.UnhealthyReplicas++
continue
}
r.Target.Status.UnhealthyReplicas++
}

revision, err := controllers.Revision(r.Target)
Expand Down

0 comments on commit c6b5758

Please sign in to comment.