Skip to content

Commit

Permalink
fix(upgradeinsights): calculate upgrade insight status based on clien…
Browse files Browse the repository at this point in the history
…t stats (#287)

* calculate upgrade insight status based on client stats

* nit: change duration var name

* use the same base for comparison

* fix lint
  • Loading branch information
floreks authored Sep 27, 2024
1 parent baa6943 commit 6a5938f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/controller/upgradeinsights_cloudprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ func (in *EKSCloudProvider) fromInsightStatus(status *types.InsightStatus) *cons
return nil
}

func (in *EKSCloudProvider) fromClientStats(stats []types.ClientStat) *console.UpgradeInsightStatus {
const failedBeforeDuration = 24.0 // in hours
for _, stat := range stats {
if stat.LastRequestTime != nil && time.Since(*stat.LastRequestTime).Hours() < failedBeforeDuration {
return lo.ToPtr(console.UpgradeInsightStatusFailed)
}
}

return lo.ToPtr(console.UpgradeInsightStatusPassing)
}

func (in *EKSCloudProvider) toInsightDetails(insight *types.Insight) []*console.UpgradeInsightDetailAttributes {
if insight.CategorySpecificSummary == nil {
return nil
Expand All @@ -137,6 +148,7 @@ func (in *EKSCloudProvider) toInsightDetails(insight *types.Insight) []*console.
Replacement: r.ReplacedWith,
ReplacedIn: r.StartServingReplacementVersion,
RemovedIn: r.StopServingVersion,
Status: in.fromClientStats(r.ClientStats),
})
}

Expand Down

0 comments on commit 6a5938f

Please sign in to comment.