Skip to content

Commit

Permalink
cluster: do not return error from GetPlatform
Browse files Browse the repository at this point in the history
Same as for GetRelease.

Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com>
  • Loading branch information
ykaliuta committed Jun 26, 2024
1 parent d7ad2ef commit 996c598
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 2 additions & 4 deletions controllers/dscinitialization/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 1 addition & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 3 additions & 8 deletions pkg/cluster/cluster_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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" {
Expand Down
6 changes: 1 addition & 5 deletions pkg/upgrade/uninstallation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 996c598

Please sign in to comment.