Skip to content

Commit ad4b892

Browse files
authored
Tolerate both opt.channel and opt.FallbackChannels for one operator (IBM#1098)
* Reconciliation will tolerate both opt.channel and opt.FallbackChannels for one operator Signed-off-by: Daniel Fan <[email protected]> * trigger reconciliation when subscription annotation is updated Signed-off-by: Daniel Fan <[email protected]> --------- Signed-off-by: Daniel Fan <[email protected]>
1 parent bb44e65 commit ad4b892

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

controllers/operandrequest/operandrequest_controller.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,9 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
399399
oldObject := e.ObjectOld.(*olmv1alpha1.Subscription)
400400
newObject := e.ObjectNew.(*olmv1alpha1.Subscription)
401401
if oldObject.Labels != nil && oldObject.Labels[constant.OpreqLabel] == "true" {
402-
return (oldObject.Status.InstalledCSV != "" && newObject.Status.InstalledCSV != "" && oldObject.Status.InstalledCSV != newObject.Status.InstalledCSV)
402+
statusToggle := (oldObject.Status.InstalledCSV != "" && newObject.Status.InstalledCSV != "" && oldObject.Status.InstalledCSV != newObject.Status.InstalledCSV)
403+
metadataToggle := !reflect.DeepEqual(oldObject.Annotations, newObject.Annotations)
404+
return statusToggle || metadataToggle
403405
}
404406
return false
405407
},

controllers/operandrequest/reconcile_operator.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,12 @@ func (r *Reconciler) reconcileSubscription(ctx context.Context, requestInstance
254254
sub.Spec.Channel = minChannel
255255
}
256256

257+
channels := []string{opt.Channel}
258+
if channels = append(channels, opt.FallbackChannels...); util.Contains(channels, sub.Spec.Channel) {
259+
isMatchedChannel = true
260+
}
257261
// update the spec iff channel in sub matches channel
258262
if sub.Spec.Channel == opt.Channel {
259-
isMatchedChannel = true
260263
sub.Spec.CatalogSource = opt.SourceName
261264
sub.Spec.CatalogSourceNamespace = opt.SourceNamespace
262265
sub.Spec.Package = opt.PackageName

0 commit comments

Comments
 (0)