Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update new elastic search request #105

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion opl/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


session = requests.Session()

session.verify=False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Sarath. This is a generic library. Do not do changes like this here.


def disable_insecure_request_warnings(disable_it):
if disable_it:
Expand Down
7 changes: 6 additions & 1 deletion opl/investigator/elasticsearch_loader.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import json
import logging
import tempfile
from requests.auth import HTTPBasicAuth

import opl.http
import opl.status_data

# Environment variables for OpenSearch credentials
open_search_username = "insights_perf"
Copy link
Contributor

@jhutar jhutar Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not hardcode stuff here. This should come from investigator config.

open_search_password = os.environ.get('OPEN_SEARCH_PASSWORD')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add name of the variable to investigator config just to force user to understand it is needed.



def load(server, index, query, paths):
out = {}
Expand All @@ -21,7 +26,7 @@ def load(server, index, query, paths):
f"Querying ES with url={url}, headers={headers} and json={json.dumps(data)}"
)

response = opl.http.get(url, headers=headers, json=data)
response = opl.http.get(url, auth=HTTPBasicAuth(open_search_username, open_search_password), headers=headers, json=data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not backwards compatible. We will not be able to migrate all our tests at one moment. We need the change that will not break current setup.


for item in response["hits"]["hits"]:
logging.debug(
Expand Down