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 fed5696 commit 08fba70
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 @@ -111,6 +111,14 @@ func CheckExistingSubscriptions(cli client.Client, desiredSubscription *operator
}

if !subExsist {
// 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 desiredSubscription.Spec.Package == OdfDepsSubscriptionPackage {
desiredSubscription.Spec.CatalogSource = odfSub.Spec.CatalogSource
desiredSubscription.Spec.CatalogSourceNamespace = odfSub.Spec.CatalogSourceNamespace
}

if desiredSubscription.Spec.Config == nil {
desiredSubscription.Spec.Config = &operatorv1alpha1.SubscriptionConfig{
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 08fba70

Please sign in to comment.