Skip to content

Commit

Permalink
Add debug logs to monitor retry in waitForEmptyEsNode
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoosein Safdari committed Jun 11, 2024
1 parent 54dc371 commit 5df8231
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion operator/es_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,13 @@ func (c *ESClient) waitForEmptyEsNode(ctx context.Context, pod *v1.Pod) error {
default:
// Process response as normal if context is not done.
var shards []ESShard
err := json.Unmarshal(r.Body(), &shards)
body := r.Body()
c.logger().Debugf("Request to %s/_cat/shards?h=index,ip&format=json status code %d - %s on %s/%s (%s)",
c.Endpoint.String(), r.StatusCode(), string(body[:]), pod.Namespace, pod.Name, podIP)
err := json.Unmarshal(body, &shards)
if err != nil {
c.logger().Debugf("Error unmarshalling ES shards on %s/%s (%s) - %v",
pod.Namespace, pod.Name, podIP, err)
return true, err
}
// shardIP := make(map[string]bool)
Expand All @@ -382,6 +387,8 @@ func (c *ESClient) waitForEmptyEsNode(ctx context.Context, pod *v1.Pod) error {
if remainingShards > 0 {
err = c.excludePodIP(pod)
if err != nil {
c.logger().Debugf("Error with excluding pod ip on %s/%s (%s) - %v",
pod.Namespace, pod.Name, podIP, err)
return true, err
}
}
Expand Down

0 comments on commit 5df8231

Please sign in to comment.