Skip to content

Commit

Permalink
[COST-4230] - add cluster-id to basic auth log message (#4827)
Browse files Browse the repository at this point in the history
  • Loading branch information
maskarb committed Dec 12, 2023
1 parent 9999949 commit d758158
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions koku/masu/external/kafka_msg_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,12 @@ def process_cr(report_meta):

auth_type = cr_status.get("authentication", {}).get("type")
if auth_type == "basic":
ctx = {"schema": report_meta.get("schema_name"), "provider_uuid": report_meta.get("provider_uuid")}
LOG.warning(log_json(report_meta.get("tracing_id"), msg="cluster is using basic auth", context=ctx))
ctx = {
"schema": report_meta.get("schema_name"),
"provider_uuid": report_meta.get("provider_uuid"),
"cluster_id": report_meta.get("cluster_id"),
}
LOG.info(log_json(report_meta.get("tracing_id"), msg="cluster is using basic auth", context=ctx))

return manifest_info

Expand Down
4 changes: 3 additions & 1 deletion koku/masu/test/external/test_kafka_msg_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,8 +895,10 @@ def test_extract_payload_content_and_process_cr(self):

# test that we warn when basic auth is being used:
report_meta["cr_status"]["authentication"]["type"] = "basic"
with self.assertLogs(logger="masu.external.kafka_msg_handler", level=logging.WARNING):
with self.assertLogs(logger="masu.external.kafka_msg_handler", level=logging.INFO) as log:
msg_handler.process_cr(report_meta)
self.assertEqual(len(log.output), 2)
self.assertIn("cluster is using basic auth", log.output[1])

def test_create_cost_and_usage_report_manifest(self):
manifest = Path("koku/masu/test/data/ocp/payload2/manifest.json")
Expand Down

0 comments on commit d758158

Please sign in to comment.