Skip to content

Commit

Permalink
update: use namespace dyniamically from operator env than hardcode va…
Browse files Browse the repository at this point in the history
…lue (opendatahub-io#1298)

- thses are only needed when it is downstream speicific cases

Signed-off-by: Wen Zhou <[email protected]>
  • Loading branch information
zdtsw authored Oct 11, 2024
1 parent e8e266f commit fa63b4d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
8 changes: 7 additions & 1 deletion controllers/dscinitialization/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,14 @@ func (r *DSCInitializationReconciler) createDefaultRoleBinding(ctx context.Conte
func (r *DSCInitializationReconciler) reconcileDefaultNetworkPolicy(ctx context.Context, name string, dscInit *dsciv1.DSCInitialization, platform cluster.Platform) error {
log := r.Log
if platform == cluster.ManagedRhods || platform == cluster.SelfManagedRhods {
// Get operator namepsace
operatorNs, err := cluster.GetOperatorNamespace()
if err != nil {
log.Error(err, "error getting operator namespace for networkplicy creation")
return err
}
// Deploy networkpolicy for operator namespace
err := deploy.DeployManifestsFromPath(ctx, r.Client, dscInit, networkpolicyPath+"/operator", "redhat-ods-operator", "networkpolicy", true)
err = deploy.DeployManifestsFromPath(ctx, r.Client, dscInit, networkpolicyPath+"/operator", operatorNs, "networkpolicy", true)
if err != nil {
log.Error(err, "error to set networkpolicy in operator namespace", "path", networkpolicyPath)
return err
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,11 @@ func createSecretCacheConfig(platform cluster.Platform) map[string]cache.Config
case cluster.ManagedRhods:
namespaceConfigs["redhat-ods-monitoring"] = cache.Config{}
namespaceConfigs["redhat-ods-applications"] = cache.Config{}
namespaceConfigs["redhat-ods-operator"] = cache.Config{}
operatorNs, err := cluster.GetOperatorNamespace()
if err != nil {
operatorNs = "redhat-ods-operator" // fall back case
}
namespaceConfigs[operatorNs] = cache.Config{}
case cluster.SelfManagedRhods:
namespaceConfigs["redhat-ods-applications"] = cache.Config{}
default:
Expand Down
6 changes: 5 additions & 1 deletion pkg/cluster/cluster_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ func detectSelfManaged(ctx context.Context, cli client.Client) (Platform, error)
// detectManagedRHODS checks if catsrc CR add-on exists ManagedRhods.
func detectManagedRHODS(ctx context.Context, cli client.Client) (Platform, error) {
catalogSource := &ofapiv1alpha1.CatalogSource{}
err := cli.Get(ctx, client.ObjectKey{Name: "addon-managed-odh-catalog", Namespace: "redhat-ods-operator"}, catalogSource)
operatorNs, err := GetOperatorNamespace()
if err != nil {
operatorNs = "redhat-ods-operator"
}
err = cli.Get(ctx, client.ObjectKey{Name: "addon-managed-odh-catalog", Namespace: operatorNs}, catalogSource)
if err != nil {
return Unknown, client.IgnoreNotFound(err)
}
Expand Down

0 comments on commit fa63b4d

Please sign in to comment.