Skip to content

Commit

Permalink
controllers: update subscription handling
Browse files Browse the repository at this point in the history
- Set catalog source name same as odf-operator sub for odf-depedencies
  sub while creating it.
- Skip creation of subscriptions other than odf-depedencies.

Signed-off-by: Nitin Goyal <[email protected]>
  • Loading branch information
iamniting committed Nov 14, 2024
1 parent fdc2dcc commit d4728e6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions controllers/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ func CheckExistingSubscriptions(cli client.Client, desiredSubscription *operator
actualSub.Spec.Channel = desiredSubscription.Spec.Channel
}

// Set the catalog source for the odf-dependencies subscription to match that of the odf-operator subscription
// This ensures that the odf-dependencies subscription uses the same catalog source across all environments,
// including offline and test environments where the catalog name may vary.
if actualSub.Spec.Package == OdfDepsSubscriptionPackage && actualSub.CreationTimestamp.IsZero() {
actualSub.Spec.CatalogSource = odfSub.Spec.CatalogSource
actualSub.Spec.CatalogSourceNamespace = odfSub.Spec.CatalogSourceNamespace
}

if actualSub.Spec.Config == nil && desiredSubscription.Spec.Config == nil {
actualSub.Spec.Config = &operatorv1alpha1.SubscriptionConfig{}
actualSub.Spec.Config.Tolerations = odfSub.Spec.Config.Tolerations
Expand Down Expand Up @@ -210,6 +218,12 @@ func EnsureDesiredSubscription(cli client.Client, desiredSubscription *operatorv
return err
}

// Skip creating (only update) subscriptions other than odf-dependencies
// It will allow OLM to manage their creation via dependency resolution
if desiredSubscription.Spec.Package != OdfDepsSubscriptionPackage && desiredSubscription.CreationTimestamp.IsZero() {
return nil
}

// create/update subscription
sub := &operatorv1alpha1.Subscription{}
sub.ObjectMeta = desiredSubscription.ObjectMeta
Expand Down

0 comments on commit d4728e6

Please sign in to comment.