@@ -25,16 +25,25 @@ import (
25
25
26
26
const noArchitecture string = "NoArchitecture"
27
27
const noChannel string = "NoChannel"
28
+ const defaultUpdateService string = "https://api.openshift.com/api/upgrades_info/v1/graph"
28
29
29
30
// syncAvailableUpdates attempts to retrieve the latest updates and update the status of the ClusterVersion
30
31
// object. It will set the RetrievedUpdates condition. Updates are only checked if it has been more than
31
32
// the minimumUpdateCheckInterval since the last check.
32
33
func (optr * Operator ) syncAvailableUpdates (ctx context.Context , config * configv1.ClusterVersion ) error {
33
- usedDefaultUpstream := false
34
- upstream := string (config .Spec .Upstream )
35
- if len (upstream ) == 0 {
36
- usedDefaultUpstream = true
37
- upstream = optr .defaultUpstreamServer
34
+ usedDefaultUpdateService := false
35
+
36
+ updateService := optr .updateService
37
+ var updateServiceSource string
38
+ if len (updateService ) > 0 {
39
+ updateServiceSource = "the --update-service command line option"
40
+ } else if len (config .Spec .Upstream ) > 0 {
41
+ updateService = string (config .Spec .Upstream )
42
+ updateServiceSource = "ClusterVersion spec.upstream"
43
+ } else {
44
+ usedDefaultUpdateService = true
45
+ updateService = defaultUpdateService
46
+ updateServiceSource = "the operator's default update service"
38
47
}
39
48
40
49
channel := config .Spec .Channel
@@ -63,7 +72,7 @@ func (optr *Operator) syncAvailableUpdates(ctx context.Context, config *configv1
63
72
klog .V (2 ).Infof ("Retrieving available updates again, because the channel has changed from %q to %q" , optrAvailableUpdates .Channel , channel )
64
73
} else if desiredArch != optrAvailableUpdates .Architecture {
65
74
klog .V (2 ).Infof ("Retrieving available updates again, because the architecture has changed from %q to %q" , optrAvailableUpdates .Architecture , desiredArch )
66
- } else if upstream == optrAvailableUpdates .Upstream || (upstream == optr . defaultUpstreamServer && optrAvailableUpdates .Upstream == "" ) {
75
+ } else if updateService == optrAvailableUpdates .UpdateService || (updateService == defaultUpdateService && optrAvailableUpdates .UpdateService == "" ) {
67
76
needsConditionalUpdateEval := false
68
77
for _ , conditionalUpdate := range optrAvailableUpdates .ConditionalUpdates {
69
78
if recommended := findRecommendedCondition (conditionalUpdate .Conditions ); recommended == nil {
@@ -80,7 +89,7 @@ func (optr *Operator) syncAvailableUpdates(ctx context.Context, config *configv1
80
89
}
81
90
needFreshFetch = false
82
91
} else {
83
- klog .V (2 ).Infof ("Retrieving available updates again, because the upstream has changed from %q to %q" , optrAvailableUpdates .Upstream , config . Spec . Upstream )
92
+ klog .V (2 ).Infof ("Retrieving available updates again, because the update service has changed from %q to %q from %s " , optrAvailableUpdates .UpdateService , updateService , updateServiceSource )
84
93
}
85
94
86
95
if needFreshFetch {
@@ -93,7 +102,7 @@ func (optr *Operator) syncAvailableUpdates(ctx context.Context, config *configv1
93
102
clusterId := string (config .Spec .ClusterID )
94
103
95
104
current , updates , conditionalUpdates , condition := calculateAvailableUpdatesStatus (ctx , clusterId ,
96
- transport , userAgent , upstream , desiredArch , currentArch , channel , optr .release .Version , optr .conditionRegistry )
105
+ transport , userAgent , updateService , desiredArch , currentArch , channel , optr .release .Version , optr .conditionRegistry )
97
106
98
107
// Populate conditions on conditional updates from operator state
99
108
for i := range optrAvailableUpdates .ConditionalUpdates {
@@ -109,12 +118,12 @@ func (optr *Operator) syncAvailableUpdates(ctx context.Context, config *configv1
109
118
conditionalUpdates = injectClusterIdIntoConditionalUpdates (clusterId , conditionalUpdates )
110
119
}
111
120
112
- if usedDefaultUpstream {
113
- upstream = ""
121
+ if usedDefaultUpdateService {
122
+ updateService = ""
114
123
}
115
124
116
125
optrAvailableUpdates .LastAttempt = time .Now ()
117
- optrAvailableUpdates .Upstream = upstream
126
+ optrAvailableUpdates .UpdateService = updateService
118
127
optrAvailableUpdates .Channel = channel
119
128
optrAvailableUpdates .Architecture = desiredArch
120
129
optrAvailableUpdates .Current = current
@@ -147,9 +156,9 @@ func (optr *Operator) syncAvailableUpdates(ctx context.Context, config *configv1
147
156
}
148
157
149
158
type availableUpdates struct {
150
- Upstream string
151
- Channel string
152
- Architecture string
159
+ UpdateService string
160
+ Channel string
161
+ Architecture string
153
162
154
163
// LastAttempt records the time of the most recent attempt at update
155
164
// retrieval, regardless of whether it was successful.
@@ -158,10 +167,10 @@ type availableUpdates struct {
158
167
// LastSyncOrConfigChange records the most recent time when any of
159
168
// the following events occurred:
160
169
//
161
- // * Upstream changed, reflecting a new authority, and obsoleting
170
+ // * UpdateService changed, reflecting a new authority, and obsoleting
162
171
// any information retrieved from (or failures // retrieving from) the
163
172
// previous authority.
164
- // * Channel changes. Same reasoning as for Upstream .
173
+ // * Channel changes. Same reasoning as for UpdateService .
165
174
// * A slice of Updates was successfully retrieved, even if that
166
175
// slice was empty.
167
176
LastSyncOrConfigChange time.Time
@@ -183,7 +192,7 @@ func (u *availableUpdates) NeedsUpdate(original *configv1.ClusterVersion) *confi
183
192
return nil
184
193
}
185
194
// Architecture could change but does not reside in ClusterVersion
186
- if u .Upstream != string (original .Spec .Upstream ) || u .Channel != original .Spec .Channel {
195
+ if u .UpdateService != string (original .Spec .Upstream ) || u .Channel != original .Spec .Channel {
187
196
return nil
188
197
}
189
198
if equality .Semantic .DeepEqual (u .Updates , original .Status .AvailableUpdates ) &&
@@ -225,7 +234,7 @@ func (optr *Operator) setAvailableUpdates(u *availableUpdates) {
225
234
optr .statusLock .Lock ()
226
235
defer optr .statusLock .Unlock ()
227
236
if u != nil && (optr .availableUpdates == nil ||
228
- optr .availableUpdates .Upstream != u .Upstream ||
237
+ optr .availableUpdates .UpdateService != u .UpdateService ||
229
238
optr .availableUpdates .Channel != u .Channel ||
230
239
optr .availableUpdates .Architecture != u .Architecture ||
231
240
success ) {
@@ -247,7 +256,7 @@ func (optr *Operator) getAvailableUpdates() *availableUpdates {
247
256
}
248
257
249
258
u := & availableUpdates {
250
- Upstream : optr .availableUpdates .Upstream ,
259
+ UpdateService : optr .availableUpdates .UpdateService ,
251
260
Channel : optr .availableUpdates .Channel ,
252
261
Architecture : optr .availableUpdates .Architecture ,
253
262
LastAttempt : optr .availableUpdates .LastAttempt ,
@@ -295,23 +304,23 @@ func (optr *Operator) getDesiredArchitecture(update *configv1.Update) string {
295
304
return ""
296
305
}
297
306
298
- func calculateAvailableUpdatesStatus (ctx context.Context , clusterID string , transport * http.Transport , userAgent , upstream , desiredArch ,
307
+ func calculateAvailableUpdatesStatus (ctx context.Context , clusterID string , transport * http.Transport , userAgent , updateService , desiredArch ,
299
308
currentArch , channel , version string , conditionRegistry clusterconditions.ConditionRegistry ) (configv1.Release , []configv1.Release , []configv1.ConditionalUpdate ,
300
309
configv1.ClusterOperatorStatusCondition ) {
301
310
302
311
var cvoCurrent configv1.Release
303
- if len (upstream ) == 0 {
312
+ if len (updateService ) == 0 {
304
313
return cvoCurrent , nil , nil , configv1.ClusterOperatorStatusCondition {
305
314
Type : configv1 .RetrievedUpdates , Status : configv1 .ConditionFalse , Reason : "NoUpstream" ,
306
- Message : "No upstream server has been set to retrieve updates." ,
315
+ Message : "No updateService server has been set to retrieve updates." ,
307
316
}
308
317
}
309
318
310
- upstreamURI , err := url .Parse (upstream )
319
+ updateServiceURI , err := url .Parse (updateService )
311
320
if err != nil {
312
321
return cvoCurrent , nil , nil , configv1.ClusterOperatorStatusCondition {
313
322
Type : configv1 .RetrievedUpdates , Status : configv1 .ConditionFalse , Reason : "InvalidURI" ,
314
- Message : fmt .Sprintf ("failed to parse upstream URL: %s" , err ),
323
+ Message : fmt .Sprintf ("failed to parse update service URL: %s" , err ),
315
324
}
316
325
}
317
326
@@ -353,11 +362,11 @@ func calculateAvailableUpdatesStatus(ctx context.Context, clusterID string, tran
353
362
}
354
363
}
355
364
356
- current , updates , conditionalUpdates , err := cincinnati .NewClient (uuid , transport , userAgent , conditionRegistry ).GetUpdates (ctx , upstreamURI , desiredArch ,
365
+ current , updates , conditionalUpdates , err := cincinnati .NewClient (uuid , transport , userAgent , conditionRegistry ).GetUpdates (ctx , updateServiceURI , desiredArch ,
357
366
currentArch , channel , currentVersion )
358
367
359
368
if err != nil {
360
- klog .V (2 ).Infof ("Upstream server %s could not return available updates: %v" , upstream , err )
369
+ klog .V (2 ).Infof ("Update service %s could not return available updates: %v" , updateService , err )
361
370
if updateError , ok := err .(* cincinnati.Error ); ok {
362
371
return cvoCurrent , nil , nil , configv1.ClusterOperatorStatusCondition {
363
372
Type : configv1 .RetrievedUpdates , Status : configv1 .ConditionFalse , Reason : updateError .Reason ,
0 commit comments