Skip to content

Commit

Permalink
add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Milica-Cvrkota-IBM committed Aug 8, 2024
1 parent 99daf22 commit bf58b7a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions controllers/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func (r *InstanaAgentReconciler) getIstioOutboundConfigAndNodeIps(ctx context.Co
log := logf.FromContext(ctx)
var nodeIPs []string

log.Info("Check if REGISTRY_ONLY is enabled")
isIstioRegistryOnlyEnabled := r.checkRegistryOnlyMode(ctx, namespace, configmap)

if isIstioRegistryOnlyEnabled {
Expand All @@ -75,11 +76,14 @@ func (r *InstanaAgentReconciler) getIstioOutboundConfigAndNodeIps(ctx context.Co

func (r *InstanaAgentReconciler) checkRegistryOnlyMode(ctx context.Context, namespace string, configmap string) bool {
istioConfigMap := &corev1.ConfigMap{}
log := logf.FromContext(ctx)
log.Info("Checking Istio configmap %s in namespace %s for outbound traffic policy", configmap, namespace)
err := r.client.Get(ctx, types.NamespacedName{Name: configmap, Namespace: namespace}, istioConfigMap)
if err != nil {
return false
}
if istioConfigMap.Data == nil {
log.Info("Istio configmap %s in namespace %s data in nil", configmap, namespace)
return false
}
meshConfigData, ok := istioConfigMap.Data["mesh"]
Expand All @@ -88,10 +92,13 @@ func (r *InstanaAgentReconciler) checkRegistryOnlyMode(ctx context.Context, name
}

var meshConfig IstioMeshConfig
log.Info("Unmarshalling config data")
err = yaml.Unmarshal([]byte(meshConfigData), &meshConfig)
if err != nil {
log.Info("Unmarshalling config data ERROR")
return false
}
log.Info("Checking if policy is REGISTRY_ONLY")

return strings.EqualFold(meshConfig.OutboundTrafficPolicy.Mode, "REGISTRY_ONLY")
}
Expand Down

0 comments on commit bf58b7a

Please sign in to comment.