Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into hbi-utils-display-c…
Browse files Browse the repository at this point in the history
…learer-host-count-on-failure
  • Loading branch information
Smejky338 committed Oct 15, 2024
2 parents cb56db4 + 7d7c71b commit 4f04f92
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 4 deletions.
18 changes: 18 additions & 0 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
title: OPL
name: opl
namespace: perfscale
description: MBU products perf&scale library
spec:
type: library
lifecycle: production
domain: domain:perfscale/perf-dept
owner: group:redhat/hce-perfscale
system: system:perfscale/consoledot-testing
dependencyOf:
- component:perfscale/iperf
tags:
- consoledot
17 changes: 15 additions & 2 deletions core/opl/cluster_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,27 @@ def execute(command):
return result


def redact_sensitive_headers(data: dict):
# Lower-case list of sensitive data in header
sensitive_headers = ["authorization", "set-cookie", "x-api-key", "cookie"]

redacted_headers = {}
for header, value in data.items():
if header.lower() in sensitive_headers:
redacted_headers[header] = "<REDACTED>"
else:
redacted_headers[header] = value
return redacted_headers


def _debug_response(r):
"""
Print various info about the requests response. Should be called when
request failed
"""
logging.error("URL = %s" % r.url)
logging.error("Request headers = %s" % r.request.headers)
logging.error("Response headers = %s" % r.headers)
logging.error("Request headers = %s" % redact_sensitive_headers(r.request.headers))
logging.error("Response headers = %s" % redact_sensitive_headers(r.headers))
logging.error("Response status code = %s" % r.status_code)
logging.error("Response content = %s" % r.content[:500])
raise Exception("Request failed")
Expand Down
4 changes: 4 additions & 0 deletions opl/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def add_ros_db_opts(parser):
_add_generic_db_opts(parser, "ros")


def add_export_db_opts(parser):
_add_generic_db_opts(parser, "export")


def add_kafka_opts(parser):
parser.add_argument(
"--kafka-host",
Expand Down
17 changes: 15 additions & 2 deletions opl/cluster_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,27 @@ def execute(command):
return result


def redact_sensitive_headers(data: dict):
# Lower-case list of sensitive data in header
sensitive_headers = ["authorization", "set-cookie", "x-api-key", "cookie"]

redacted_headers = {}
for header, value in data.items():
if header.lower() in sensitive_headers:
redacted_headers[header] = "<REDACTED>"
else:
redacted_headers[header] = value
return redacted_headers


def _debug_response(r):
"""
Print various info about the requests response. Should be called when
request failed
"""
logging.error("URL = %s" % r.url)
logging.error("Request headers = %s" % r.request.headers)
logging.error("Response headers = %s" % r.headers)
logging.error("Request headers = %s" % redact_sensitive_headers(r.request.headers))
logging.error("Response headers = %s" % redact_sensitive_headers(r.headers))
logging.error("Response status code = %s" % r.status_code)
logging.error("Response content = %s" % r.content[:500])
raise Exception("Request failed")
Expand Down

0 comments on commit 4f04f92

Please sign in to comment.