Skip to content

Commit

Permalink
Cleanup paasta logs from tmp configs (#3993)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaroliakh authored Jan 7, 2025
1 parent b733ba4 commit 8ec1f6b
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 90 deletions.
16 changes: 1 addition & 15 deletions paasta_tools/cli/cmds/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,6 @@ def list_log_readers() -> Iterable[str]:
return _log_reader_classes.keys()


def get_default_log_reader() -> "LogReader":
log_reader_config = load_system_paasta_config().get_log_reader()
log_reader_class = get_log_reader_class(log_reader_config["driver"])
return log_reader_class(**log_reader_config.get("options", {}))


def get_log_reader(components: Set[str]) -> "LogReader":
log_readers_config = load_system_paasta_config().get_log_readers()
# ideally we should use a single "driver" for all components, but in cases where more than one is used for different components,
Expand Down Expand Up @@ -1483,14 +1477,6 @@ def pick_default_log_mode(
return 1


def pick_log_reader(cluster: str, components: Set[str]) -> LogReader:
uses_log_readers = load_system_paasta_config().use_multiple_log_readers()
if uses_log_readers and cluster in uses_log_readers:
return get_log_reader(components)
else:
return get_default_log_reader()


def paasta_logs(args: argparse.Namespace) -> int:
"""Print the logs for as Paasta service.
:param args: argparse.Namespace obj created from sys.args by cli"""
Expand Down Expand Up @@ -1535,7 +1521,7 @@ def paasta_logs(args: argparse.Namespace) -> int:

log.debug(f"Going to get logs for {service} on cluster {clusters}")

log_reader = pick_log_reader(clusters[0], components)
log_reader = get_log_reader(components)

if not validate_filtering_args(args, log_reader):
return 1
Expand Down
7 changes: 0 additions & 7 deletions paasta_tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2039,7 +2039,6 @@ class SystemPaastaConfigDict(TypedDict, total=False):
sidecar_requirements_config: Dict[str, KubeContainerResourceRequest]
eks_cluster_aliases: Dict[str, str]
secret_sync_delay_seconds: float
use_multiple_log_readers: Optional[List[str]]
service_auth_token_settings: ProjectedSAVolume
service_auth_vault_role: str
service_auth_sso_oidc_client_id: str
Expand Down Expand Up @@ -2364,12 +2363,6 @@ def get_log_readers(self) -> List[LogReaderConfig]:
% self.directory
)

def use_multiple_log_readers(self) -> Optional[List[str]]:
"""
Get the list of clusters that are using multiple log readers
"""
return self.config_dict.get("use_multiple_log_readers")

def get_metrics_provider(self) -> Optional[str]:
"""Get the metrics_provider configuration out of global paasta config
Expand Down
68 changes: 0 additions & 68 deletions tests/cli/test_cmds_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,74 +964,6 @@ def test_prefix():
assert "TEST STRING" in actual


def test_pick_log_reader():
components = {"stdout", "stderr"}
cluster = "fake_cluster"
mock_system_paasta_config = mock.Mock(
autospec="paasta_tools.utils.SystemPaastaConfig"
)
mock_system_paasta_config.use_multiple_log_readers.return_value = [
"fake_cluster",
"fake_cluster2",
]
with mock.patch(
"paasta_tools.cli.cmds.logs.load_system_paasta_config", autospec=True
) as mock_load_system_paasta_config, mock.patch(
"paasta_tools.cli.cmds.logs.get_log_reader", autospec=True
) as mock_get_log_reader, mock.patch(
"paasta_tools.cli.cmds.logs.get_default_log_reader", autospec=True
) as mock_default_reader:
mock_load_system_paasta_config.return_value = mock_system_paasta_config

logs.pick_log_reader(cluster, components)
assert mock_default_reader.call_count == 0
assert mock_get_log_reader.call_count == 1


def test_pick_log_reader_default():
components = {"stdout", "stderr"}
cluster = "fake_cluster"
mock_system_paasta_config = mock.Mock(
autospec="paasta_tools.utils.SystemPaastaConfig"
)
mock_system_paasta_config.use_multiple_log_readers.return_value = None

with mock.patch(
"paasta_tools.cli.cmds.logs.load_system_paasta_config", autospec=True
) as mock_load_system_paasta_config, mock.patch(
"paasta_tools.cli.cmds.logs.get_log_reader", autospec=True
) as mock_get_log_reader, mock.patch(
"paasta_tools.cli.cmds.logs.get_default_log_reader", autospec=True
) as mock_default_reader:
mock_load_system_paasta_config.return_value = mock_system_paasta_config

logs.pick_log_reader(cluster, components)
assert mock_default_reader.call_count == 1
assert mock_get_log_reader.call_count == 0


def test_pick_log_reader_still_default():
components = {"stdout", "stderr"}
cluster = "fake_cluster"
mock_system_paasta_config = mock.Mock(
autospec="paasta_tools.utils.SystemPaastaConfig"
)
mock_system_paasta_config.use_multiple_log_readers.return_value = ["fake_cluster2"]

with mock.patch(
"paasta_tools.cli.cmds.logs.load_system_paasta_config", autospec=True
) as mock_load_system_paasta_config, mock.patch(
"paasta_tools.cli.cmds.logs.get_log_reader", autospec=True
) as mock_get_log_reader, mock.patch(
"paasta_tools.cli.cmds.logs.get_default_log_reader", autospec=True
) as mock_default_reader:
mock_load_system_paasta_config.return_value = mock_system_paasta_config

logs.pick_log_reader(cluster, components)
assert mock_default_reader.call_count == 1
assert mock_get_log_reader.call_count == 0


def test_get_log_reader():
components = {"stdout", "stderr"}
mock_system_paasta_config = mock.Mock(
Expand Down

0 comments on commit 8ec1f6b

Please sign in to comment.