Skip to content

Commit

Permalink
Merge pull request #2890 from project-koku/rc-2021.05.18
Browse files Browse the repository at this point in the history
Rc 2021.05.18
  • Loading branch information
myersCody authored May 18, 2021
2 parents 2f46647 + c2df5c1 commit a23ba58
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
9 changes: 7 additions & 2 deletions koku/sources/kafka_message_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,15 @@ def msg_for_cost_mgmt(self):
"""Filter messages not intended for cost management."""
if self.event_type in (KAFKA_APPLICATION_DESTROY, KAFKA_SOURCE_DESTROY):
return True
if self.event_type in (KAFKA_AUTHENTICATION_CREATE, KAFKA_APPLICATION_UPDATE, KAFKA_AUTHENTICATION_UPDATE):
if self.event_type in (
KAFKA_APPLICATION_CREATE,
KAFKA_AUTHENTICATION_CREATE,
KAFKA_APPLICATION_UPDATE,
KAFKA_AUTHENTICATION_UPDATE,
):
sources_network = self.get_sources_client()
return sources_network.get_application_type_is_cost_management(self.cost_mgmt_id)
return True # TODO: I wonder if this should be false?
return False

def get_sources_client(self):
return SourcesHTTPClient(self.auth_header, self.source_id)
Expand Down
2 changes: 1 addition & 1 deletion koku/sources/test/test_kafka_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def test_listen_for_messages_aws_create_update_delete(self):
def test_message_not_associated_with_cost_mgmt(self):
"""Test that messages not associated with cost-mgmt are not processed."""
table = [
{"processor": ApplicationMsgProcessor, "event": KAFKA_APPLICATION_CREATE, "called": True},
{"processor": ApplicationMsgProcessor, "event": KAFKA_APPLICATION_CREATE},
{"processor": ApplicationMsgProcessor, "event": KAFKA_APPLICATION_UPDATE},
{"processor": ApplicationMsgProcessor, "event": KAFKA_APPLICATION_DESTROY, "called": True},
{"processor": AuthenticationMsgProcessor, "event": KAFKA_AUTHENTICATION_CREATE},
Expand Down
3 changes: 3 additions & 0 deletions koku/sources/test/test_kafka_message_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,14 @@ def test_create_msg_processor_missing_header(self):
def test_msg_for_cost_mgmt(self):
"""Test msg_for_cost_mgmt true or false."""
table = [
{"event-type": "Source.create", "expected": False},
{"event-type": KAFKA_APPLICATION_DESTROY, "expected": True},
{"event-type": KAFKA_SOURCE_DESTROY, "expected": True},
{"event-type": KAFKA_APPLICATION_CREATE, "expected": True, "patch": True},
{"event-type": KAFKA_AUTHENTICATION_CREATE, "expected": True, "patch": True},
{"event-type": KAFKA_APPLICATION_UPDATE, "expected": True, "patch": True},
{"event-type": KAFKA_AUTHENTICATION_UPDATE, "expected": True, "patch": True},
{"event-type": KAFKA_APPLICATION_CREATE, "expected": False, "patch": False},
{"event-type": KAFKA_AUTHENTICATION_CREATE, "expected": False, "patch": False},
{"event-type": KAFKA_APPLICATION_UPDATE, "expected": False, "patch": False},
{"event-type": KAFKA_AUTHENTICATION_UPDATE, "expected": False, "patch": False},
Expand Down

0 comments on commit a23ba58

Please sign in to comment.