-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
controllers: Do not update client operator in provider mode #393
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ import ( | |
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" | ||
|
||
operatorv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" | ||
ocsv1 "github.com/red-hat-storage/ocs-operator/api/v4/v1" | ||
odfv1alpha1 "github.com/red-hat-storage/odf-operator/api/v1alpha1" | ||
"github.com/red-hat-storage/odf-operator/pkg/util" | ||
) | ||
|
@@ -51,6 +52,14 @@ func CheckExistingSubscriptions(cli client.Client, desiredSubscription *operator | |
odfSub.Spec.Config = &operatorv1alpha1.SubscriptionConfig{} | ||
} | ||
|
||
var isProvider bool | ||
if desiredSubscription.Spec.Package == OcsClientSubscriptionPackage { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it is defined in the defaults.go |
||
isProvider, err = isProviderMode(cli) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
subsList := &operatorv1alpha1.SubscriptionList{} | ||
err = cli.List(context.TODO(), subsList, &client.ListOptions{Namespace: desiredSubscription.Namespace}) | ||
if err != nil { | ||
|
@@ -68,7 +77,10 @@ func CheckExistingSubscriptions(cli client.Client, desiredSubscription *operator | |
return nil, fmt.Errorf("multiple Subscriptions found for package '%s': %v", pkgName, foundSubs) | ||
} | ||
actualSub = &subsList.Items[i] | ||
actualSub.Spec.Channel = desiredSubscription.Spec.Channel | ||
|
||
if !isProvider { | ||
actualSub.Spec.Channel = desiredSubscription.Spec.Channel | ||
} | ||
Comment on lines
+81
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see only channel update is being skipped, no qualms w/ that, small question, does odf-operator overwrites any metadata in the subscription? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, it does not overwrite metadata. |
||
|
||
if actualSub.Spec.Config == nil && desiredSubscription.Spec.Config == nil { | ||
actualSub.Spec.Config = &operatorv1alpha1.SubscriptionConfig{} | ||
|
@@ -102,6 +114,23 @@ func CheckExistingSubscriptions(cli client.Client, desiredSubscription *operator | |
return desiredSubscription, nil | ||
} | ||
|
||
func isProviderMode(cli client.Client) (bool, error) { | ||
|
||
storageclusters := &ocsv1.StorageClusterList{} | ||
err := cli.List(context.TODO(), storageclusters) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
for _, storagecluster := range storageclusters.Items { | ||
if storagecluster.Spec.AllowRemoteStorageConsumers { | ||
return true, nil | ||
} | ||
} | ||
|
||
return false, nil | ||
Comment on lines
+119
to
+131
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sry, this seems a lot of work to find the fields values, not mandatory and here's what I'm thinking, It might be good to limit the result to operator ns and taken an index into Items? again, only a suggestion. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would say let it be. We may extend the func later on. |
||
} | ||
|
||
func getMergedTolerations(tol1, tol2 []corev1.Toleration) []corev1.Toleration { | ||
|
||
if len(tol1) == 0 { | ||
|
@@ -216,18 +245,24 @@ func GetOdfSubscription(cli client.Client) (*operatorv1alpha1.Subscription, erro | |
return nil, fmt.Errorf("odf-operator subscription not found") | ||
} | ||
|
||
func GetVendorCsvNames(kind odfv1alpha1.StorageKind) []string { | ||
func GetVendorCsvNames(cli client.Client, kind odfv1alpha1.StorageKind) ([]string, error) { | ||
|
||
var csvNames []string | ||
var err error | ||
var isProvider bool | ||
|
||
if kind == VendorFlashSystemCluster() { | ||
csvNames = []string{IbmSubscriptionStartingCSV} | ||
} else if kind == VendorStorageCluster() { | ||
csvNames = []string{OcsSubscriptionStartingCSV, RookSubscriptionStartingCSV, NoobaaSubscriptionStartingCSV, | ||
CSIAddonsSubscriptionStartingCSV, OcsClientSubscriptionStartingCSV, PrometheusSubscriptionStartingCSV} | ||
CSIAddonsSubscriptionStartingCSV, PrometheusSubscriptionStartingCSV} | ||
|
||
if isProvider, err = isProviderMode(cli); !isProvider { | ||
csvNames = append(csvNames, OcsClientSubscriptionStartingCSV) | ||
} | ||
} | ||
|
||
return csvNames | ||
return csvNames, err | ||
} | ||
|
||
func EnsureVendorCsv(cli client.Client, csvName string) (*operatorv1alpha1.ClusterServiceVersion, error) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in existing code, is storagesystem being set as a controller owner for storagecluster?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes