diff --git a/controllers/datasciencecluster/datasciencecluster_controller.go b/controllers/datasciencecluster/datasciencecluster_controller.go index 67c6727b6e0..db58b77bf18 100644 --- a/controllers/datasciencecluster/datasciencecluster_controller.go +++ b/controllers/datasciencecluster/datasciencecluster_controller.go @@ -304,12 +304,8 @@ func (r *DataScienceClusterReconciler) reconcileSubComponent(ctx context.Context } // Reconcile component // Get platform - platform, err := cluster.GetPlatform(ctx, r.Client) - if err != nil { - r.Log.Error(err, "Failed to determine platform") - return instance, err - } - err = component.ReconcileComponent(ctx, r.Client, r.Log, instance, r.DataScienceCluster.DSCISpec, platform, installedComponentValue) + platform := cluster.GetPlatform() + err := component.ReconcileComponent(ctx, r.Client, r.Log, instance, r.DataScienceCluster.DSCISpec, platform, installedComponentValue) if err != nil { // reconciliation failed: log errors, raise event and update status accordingly diff --git a/controllers/dscinitialization/dscinitialization_controller.go b/controllers/dscinitialization/dscinitialization_controller.go index d8f9c2453b2..7eab2f1b017 100644 --- a/controllers/dscinitialization/dscinitialization_controller.go +++ b/controllers/dscinitialization/dscinitialization_controller.go @@ -151,13 +151,7 @@ func (r *DSCInitializationReconciler) Reconcile(ctx context.Context, req ctrl.Re managementStateChangeTrustedCA = false // Get platform - platform, err := cluster.GetPlatform(ctx, r.Client) - if err != nil { - r.Log.Error(err, "Failed to determine platform (managed vs self-managed)") - - return reconcile.Result{}, err - } - + platform := cluster.GetPlatform() switch req.Name { case "prometheus": // prometheus configmap if instance.Spec.Monitoring.ManagementState == operatorv1.Managed && platform == cluster.ManagedRhods { diff --git a/controllers/dscinitialization/utils.go b/controllers/dscinitialization/utils.go index 97cb307eee7..530847f7bd3 100644 --- a/controllers/dscinitialization/utils.go +++ b/controllers/dscinitialization/utils.go @@ -191,10 +191,8 @@ func (r *DSCInitializationReconciler) createDefaultRoleBinding(ctx context.Conte } func (r *DSCInitializationReconciler) reconcileDefaultNetworkPolicy(ctx context.Context, name string, dscInit *dsciv1.DSCInitialization) error { - platform, err := cluster.GetPlatform(ctx, r.Client) - if err != nil { - return err - } + var err error + platform := cluster.GetPlatform() if platform == cluster.ManagedRhods || platform == cluster.SelfManagedRhods { // Deploy networkpolicy for operator namespace err = deploy.DeployManifestsFromPath(ctx, r.Client, dscInit, networkpolicyPath+"/operator", "redhat-ods-operator", "networkpolicy", true) diff --git a/main.go b/main.go index b1dbf69f4e4..f5e20048f83 100644 --- a/main.go +++ b/main.go @@ -145,12 +145,7 @@ func main() { //nolint:funlen } // Get operator platform - platform, err := cluster.GetPlatform(ctx, setupClient) - if err != nil { - setupLog.Error(err, "error getting platform") - os.Exit(1) - } - + platform := cluster.GetPlatform() mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ // single pod does not need to have LeaderElection Scheme: scheme, MetricsBindAddress: metricsAddr, diff --git a/pkg/cluster/cluster_config.go b/pkg/cluster/cluster_config.go index 1978a70cc9e..79e38ce27b6 100644 --- a/pkg/cluster/cluster_config.go +++ b/pkg/cluster/cluster_config.go @@ -76,8 +76,8 @@ func GetOperatorNamespace() (string, error) { return clusterConfig.Namespace, nil } -func GetPlatform(_ context.Context, _ client.Client) (Platform, error) { - return clusterConfig.Platform, nil +func GetPlatform() Platform { + return clusterConfig.Platform } func GetRelease() Release { @@ -191,12 +191,7 @@ func getRelease(ctx context.Context, cli client.Client) (Release, error) { Version: semver.Version{}, }, } - // Set platform - platform, err := GetPlatform(ctx, cli) - if err != nil { - return initRelease, err - } - initRelease.Name = platform + initRelease.Name = clusterConfig.Platform // For unit-tests if os.Getenv("CI") == "true" { diff --git a/pkg/upgrade/uninstallation.go b/pkg/upgrade/uninstallation.go index a45152a94c6..9c76728e985 100644 --- a/pkg/upgrade/uninstallation.go +++ b/pkg/upgrade/uninstallation.go @@ -24,11 +24,7 @@ const ( // OperatorUninstall deletes all the externally generated resources. This includes monitoring resources and applications // installed by KfDef. func OperatorUninstall(ctx context.Context, cli client.Client) error { - platform, err := cluster.GetPlatform(ctx, cli) - if err != nil { - return err - } - + platform := cluster.GetPlatform() if err := RemoveKfDefInstances(ctx, cli); err != nil { return err }