@@ -17,7 +17,7 @@ import (
1717 "k8s.io/apimachinery/pkg/types"
1818)
1919
20- func UpdateCanaryStatusAndEvent (ctx context.Context , canary v1.Canary , results []* pkg.CheckResult ) {
20+ func UpdateCanaryStatusAndEvent (ctx context.Context , canary v1.Canary , results []* pkg.CheckResult , now time. Time ) {
2121 if CanaryStatusChannel == nil {
2222 return
2323 }
@@ -40,7 +40,6 @@ func UpdateCanaryStatusAndEvent(ctx context.Context, canary v1.Canary, results [
4040 var highestLatency float64
4141 var uptimeAgg dutyTypes.Uptime
4242
43- transitioned := false
4443 for _ , result := range results {
4544 // Increment duration
4645 duration += result .Duration
@@ -62,26 +61,22 @@ func UpdateCanaryStatusAndEvent(ctx context.Context, canary v1.Canary, results [
6261 highestLatency = latency .Rolling1H
6362 }
6463
64+ transitioned := false
6565 // Transition
6666 // q := query.CheckQueryParams{Check: checkID, StatusCount: 1}
6767 // if canary.Status.LastTransitionedTime != nil {
6868 // q.Start = canary.Status.LastTransitionedTime.Format(time.RFC3339)
6969 // }
7070
71- latestCheckStatus , err := db .LatestCheckStatus (ctx , checkID )
71+ latestCheckStatus , err := db .LatestCheckStatus (ctx , checkID , now )
7272 if err != nil || latestCheckStatus == nil {
7373 transitioned = true
7474 } else if latestCheckStatus .Status != result .Pass {
7575 transitioned = true
7676 }
7777 if transitioned {
78- transitionTime := time .Now ()
79- if latestCheckStatus != nil {
80- transitionTime = latestCheckStatus .CreatedAt
81- }
82-
83- checkStatus [checkID ].LastTransitionedTime = & metav1.Time {Time : transitionTime }
84- lastTransitionedTime = & metav1.Time {Time : transitionTime }
78+ checkStatus [checkID ].LastTransitionedTime = & metav1.Time {Time : now }
79+ lastTransitionedTime = & metav1.Time {Time : now }
8580 }
8681
8782 if result .Message != "" {
0 commit comments