@@ -65,14 +65,27 @@ type availableUpdates struct {
65
65
Upstream string
66
66
Channel string
67
67
68
- At time.Time
68
+ // LastAttempt records the time of the most recent attempt at update
69
+ // retrieval, regardless of whether it was successful.
70
+ LastAttempt time.Time
71
+
72
+ // LastSyncOrConfigChange records the most recent time when any of
73
+ // the following events occurred:
74
+ //
75
+ // * Upstream changed, reflecting a new authority, and obsoleting
76
+ // any information retrieved from (or failures // retrieving from) the
77
+ // previous authority.
78
+ // * Channel changes. Same reasoning as for Upstream.
79
+ // * A slice of Updates was successfully retrieved, even if that
80
+ // slice was empty.
81
+ LastSyncOrConfigChange time.Time
69
82
70
83
Updates []configv1.Update
71
84
Condition configv1.ClusterOperatorStatusCondition
72
85
}
73
86
74
87
func (u * availableUpdates ) RecentlyChanged (interval time.Duration ) bool {
75
- return u .At .After (time .Now ().Add (- interval ))
88
+ return u .LastAttempt .After (time .Now ().Add (- interval ))
76
89
}
77
90
78
91
func (u * availableUpdates ) NeedsUpdate (original * configv1.ClusterVersion ) * configv1.ClusterVersion {
@@ -95,12 +108,26 @@ func (u *availableUpdates) NeedsUpdate(original *configv1.ClusterVersion) *confi
95
108
96
109
// setAvailableUpdates updates the currently calculated version of updates.
97
110
func (optr * Operator ) setAvailableUpdates (u * availableUpdates ) {
111
+ success := false
98
112
if u != nil {
99
- u .At = time .Now ()
113
+ u .LastAttempt = time .Now ()
114
+ if u .Condition .Type == configv1 .RetrievedUpdates {
115
+ success = u .Condition .Status == configv1 .ConditionTrue
116
+ } else {
117
+ klog .Warningf ("Unrecognized condition %s=%s (%s: %s): cannot judge update retrieval success" , u .Condition .Type , u .Condition .Status , u .Condition .Reason , u .Condition .Message )
118
+ }
100
119
}
101
120
102
121
optr .statusLock .Lock ()
103
122
defer optr .statusLock .Unlock ()
123
+ if u != nil && (optr .availableUpdates == nil ||
124
+ optr .availableUpdates .Upstream != u .Upstream ||
125
+ optr .availableUpdates .Channel != u .Channel ||
126
+ success ) {
127
+ u .LastSyncOrConfigChange = u .LastAttempt
128
+ } else if optr .availableUpdates != nil {
129
+ u .LastSyncOrConfigChange = optr .availableUpdates .LastSyncOrConfigChange
130
+ }
104
131
optr .availableUpdates = u
105
132
}
106
133
0 commit comments