Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
rkthtrifork committed May 31, 2024
1 parent daff215 commit 1d485a8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
11 changes: 8 additions & 3 deletions opensearch-operator/opensearch-gateway/services/http_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package services

import (
"context"
"github.com/opensearch-project/opensearch-go"
"github.com/opensearch-project/opensearch-go/opensearchapi"
"io"
"net/http"
"strings"

"github.com/go-logr/logr"
"github.com/opensearch-project/opensearch-go"
"github.com/opensearch-project/opensearch-go/opensearchapi"
)

// doHTTPGet performs a HTTP GET request
Expand Down Expand Up @@ -48,9 +50,11 @@ func doHTTPHead(ctx context.Context, client *opensearch.Client, path strings.Bui
}

// doHTTPPut performs a HTTP PUT request
func doHTTPPut(ctx context.Context, client *opensearch.Client, path strings.Builder, body io.Reader) (*opensearchapi.Response, error) {
func doHTTPPut(ctx context.Context, client *opensearch.Client, path strings.Builder, body io.Reader, logger *logr.Logger) (*opensearchapi.Response, error) {
req, err := http.NewRequest(http.MethodPut, path.String(), body)
logger.Info("rkth doHTTPPut")
if err != nil {
logger.Info("rkth hej4")
return nil, err
}

Expand All @@ -61,6 +65,7 @@ func doHTTPPut(ctx context.Context, client *opensearch.Client, path strings.Buil

res, err := client.Perform(req)
if err != nil {
logger.Info("rkth hej5")
return nil, err
}

Expand Down
6 changes: 4 additions & 2 deletions opensearch-operator/opensearch-gateway/services/os_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/Opster/opensearch-k8s-operator/opensearch-operator/opensearch-gateway/responses"
"github.com/go-logr/logr"
"github.com/opensearch-project/opensearch-go"
"github.com/opensearch-project/opensearch-go/opensearchapi"
"github.com/opensearch-project/opensearch-go/opensearchutil"
Expand Down Expand Up @@ -315,9 +316,10 @@ func (client *OsClusterClient) GetISMConfig(ctx context.Context, name string) (*
}

// PutISMConfig performs an HTTP PUT request to OS to create the ISM policy resource specified by name
func (client *OsClusterClient) PutISMConfig(ctx context.Context, name string, body io.Reader) (*opensearchapi.Response, error) {
func (client *OsClusterClient) PutISMConfig(ctx context.Context, name string, body io.Reader, logger *logr.Logger) (*opensearchapi.Response, error) {
path := generateAPIPathISM(ismResource, name)
return doHTTPPut(ctx, client.client, path, body)
logger.Info("rkth path: "+path.String())
return doHTTPPut(ctx, client.client, path, body, logger)
}

// UpdateISMConfig performs an HTTP PUT request to OS to update the ISM policy resource specified by name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func GetPolicy(ctx context.Context, service *OsClusterClient, policyName string)
// CreateISMPolicy creates the passed policy
func CreateISMPolicy(ctx context.Context, service *OsClusterClient, ismpolicy requests.Policy, policyId string, logger *logr.Logger) error {
spec := opensearchutil.NewJSONReader(ismpolicy)
resp, err := service.PutISMConfig(ctx, policyId, spec)
resp, err := service.PutISMConfig(ctx, policyId, spec, logger)
logger.Info("rkth hej1")
if err != nil {
logger.Info("rkth hej2")
Expand Down

0 comments on commit 1d485a8

Please sign in to comment.