Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
rkthtrifork committed Jun 14, 2024
1 parent cf76308 commit 38ca744
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions opensearch-operator/pkg/reconcilers/ismpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (r *IsmPolicyReconciler) Reconcile() (retResult ctrl.Result, retErr error)
policyId = r.instance.Name
}

newPolicy, err := r.CreateISMPolicyRequest()
newPolicy, err := r.CreateISMPolicy()
if err != nil {
reason = "failed to get create the ism policy request"
r.logger.Error(err, reason)
Expand All @@ -170,12 +170,6 @@ func (r *IsmPolicyReconciler) Reconcile() (retResult ctrl.Result, retErr error)
r.logger.Info("rkth ismpolicy existing policyId: " + existingPolicy.PolicyID)
// If not exists, create
if errors.Is(err, services.ErrNotFound) {
if err != nil {
reason = "failed to get create the ism policy request"
r.logger.Error(err, reason)
r.recorder.Event(r.instance, "Warning", opensearchAPIError, reason)
return
}
request := requests.ISMPolicy{
Policy: *newPolicy,
}
Expand All @@ -191,20 +185,21 @@ func (r *IsmPolicyReconciler) Reconcile() (retResult ctrl.Result, retErr error)
RequeueAfter: 30 * time.Second,
}, nil
}

// If some other error
// If other error, report
if err != nil {
reason = "failed to get policy from Opensearch API"
reason = "failed to get create the ism policy request"
r.logger.Error(err, reason)
r.recorder.Event(r.instance, "Warning", opensearchAPIError, reason)
return
}

// Return if there are no changes
if r.instance.Spec.PolicyID == existingPolicy.PolicyID && cmp.Equal(newPolicy, existingPolicy.Policy, cmpopts.EquateEmpty()) {
r.logger.Info("rkth they are equal")
reason = opensearchIsmPolicyExists
return
}
r.logger.Info("rkth they are not equal")

request := requests.ISMPolicy{
Policy: *newPolicy,
Expand All @@ -224,7 +219,7 @@ func (r *IsmPolicyReconciler) Reconcile() (retResult ctrl.Result, retErr error)
}, nil
}

func (r *IsmPolicyReconciler) CreateISMPolicyRequest() (*requests.ISMPolicySpec, error) {
func (r *IsmPolicyReconciler) CreateISMPolicy() (*requests.ISMPolicySpec, error) {
policy := requests.ISMPolicySpec{
DefaultState: r.instance.Spec.DefaultState,
Description: r.instance.Spec.Description,
Expand Down

0 comments on commit 38ca744

Please sign in to comment.