Skip to content

Commit

Permalink
debug operator
Browse files Browse the repository at this point in the history
  • Loading branch information
rkthtrifork committed Aug 28, 2024
1 parent 768c0d0 commit 913ea75
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion opensearch-operator/pkg/reconcilers/indextemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package reconcilers

import (
"context"
"encoding/json"
"errors"
"fmt"
"time"
Expand Down Expand Up @@ -280,6 +281,14 @@ func (r *IndexTemplateReconciler) Reconcile() (retResult ctrl.Result, retErr err
}

func (r *IndexTemplateReconciler) equal(request *requests.IndexTemplate, response *responses.IndexTemplate) (bool, error) {
logger := r.logger.WithName("comparing index templates")

m := make(map[string]interface{})
if err := json.Unmarshal(response.IndexTemplate.Template.Mappings.Raw, &m); err != nil {
return false, err
}
logger.Info("mappings before sort: " + spew.Sdump(m))

var err error
if response.IndexTemplate.Template.Settings != nil {
response.IndexTemplate.Template.Settings, err = helpers.SortedJsonKeys(response.IndexTemplate.Template.Settings)
Expand All @@ -294,6 +303,11 @@ func (r *IndexTemplateReconciler) equal(request *requests.IndexTemplate, respons
return false, err
}
}
m = make(map[string]interface{})
if err := json.Unmarshal(response.IndexTemplate.Template.Mappings.Raw, &m); err != nil {
return false, err
}
logger.Info("mappings after sort: " + spew.Sdump(m))

if request.Template.Settings != nil {
request.Template.Settings, err = helpers.SortedJsonKeys(request.Template.Settings)
Expand All @@ -309,7 +323,6 @@ func (r *IndexTemplateReconciler) equal(request *requests.IndexTemplate, respons
}
}

logger := r.logger.WithName("comparing index templates")
logger.Info("new: " + spew.Sdump(request))
logger.Info("existing: " + spew.Sdump(response.IndexTemplate))
logger.Info(fmt.Sprintf("name: %v", r.instance.Spec.Name == response.Name))
Expand Down

0 comments on commit 913ea75

Please sign in to comment.