Skip to content
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

wip: Rename configmap for sail #392

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions controllers/kuadrant_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package controllers
import (
"context"
"encoding/json"
"fmt"

corev1 "k8s.io/api/core/v1"
"k8s.io/utils/env"
Expand Down Expand Up @@ -320,11 +321,12 @@ func (r *KuadrantReconciler) registerExternalAuthorizerOSSM(ctx context.Context,

func (r *KuadrantReconciler) getIstioConfigObjects(ctx context.Context, logger logr.Logger) ([]common.ConfigWrapper, error) {
var configsToUpdate []common.ConfigWrapper

configMapName := ""
iop := &iopv1alpha1.IstioOperator{}
istKey := client.ObjectKey{Name: controlPlaneProviderName(), Namespace: controlPlaneProviderNamespace()}
err := r.GetResource(ctx, istKey, iop)
if err == nil || apierrors.IsNotFound(err) {
configMapName = controlPlaneConfigMapName(false)
configsToUpdate = append(configsToUpdate, istio.NewOperatorWrapper(iop))
} else if !apimeta.IsNoMatchError(err) {
logger.V(1).Info("failed to get istiooperator object", "key", istKey, "err", err)
Expand All @@ -342,11 +344,12 @@ func (r *KuadrantReconciler) getIstioConfigObjects(ctx context.Context, logger l
return nil, err
}
}
configMapName = controlPlaneConfigMapName(true)
configsToUpdate = append(configsToUpdate, istio.NewSailWrapper(ist))
}

istioConfigMap := &corev1.ConfigMap{}
if err := r.GetResource(ctx, client.ObjectKey{Name: controlPlaneConfigMapName(), Namespace: controlPlaneProviderNamespace()}, istioConfigMap); err != nil {
if err := r.GetResource(ctx, client.ObjectKey{Name: configMapName, Namespace: controlPlaneProviderNamespace()}, istioConfigMap); err != nil {
logger.V(1).Info("failed to get istio configMap", "key", istKey, "err", err)
return configsToUpdate, err
}
Expand Down Expand Up @@ -380,7 +383,10 @@ func controlPlaneProviderName() string {
return env.GetString("ISTIOOPERATOR_NAME", "istiocontrolplane")
}

func controlPlaneConfigMapName() string {
func controlPlaneConfigMapName(isSail bool) string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this function doesn't belong to pkg/istio/mesh_config.go. It looks like the name of the ConfigMap is an implementation detail of each kind of Istio operator.

If this is indeed the direction we want to go, WDYT about something like the following?

func (r *KuadrantReconciler) getIstioConfigObjects(ctx context.Context, logger logr.Logger) ([]common.ConfigWrapper, error) {
	// ...
	if err == nil || apierrors.IsNotFound(err) {
		opw := istio.NewOperatorWrapper(iop)
		configMapName = opw.ConfigMapName()
		configsToUpdate = append(configsToUpdate, opw)
	} else if !apimeta.IsNoMatchError(err) {
		// ...
	} else {
		// ...
		opw := istio.NewSailWrapper(ist)
		configMapName = opw.ConfigMapName()
		configsToUpdate = append(configsToUpdate, opw)
	}
	// ...
}

Of course, OperatorWrapper and SailWrapper structs would implement ConfigMapName() string as well (apart from ConfigWrapper).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep that's along the lines of what I was thinking. Unfortunately these changes aren't enough though to solve the install issue, still investigating.

if isSail {
return env.GetString("ISTIOCONFIGMAP_NAME", fmt.Sprintf("istio-%s", controlPlaneProviderName()))
}
return env.GetString("ISTIOCONFIGMAP_NAME", "istio")
}

Expand Down
Loading