Skip to content

Conversation

@dkropachev
Copy link
Contributor

It could fail with following error:

    def parse_cluster_status(self, stdout):
        """
            Output:

            Cluster: 'CCMCluster-reloc'
            ---------------------------
            node1: UP

            return:
            [(node1, UP)]
        """
        nodes_status = []
        for line in stdout.split("\n")[2:]:
>           node, status = line.split(":")
E           ValueError: not enough values to unpack (expected 2, got 1)

@dkropachev
Copy link
Contributor Author

@fruch , @tchaikov , one more please.

@dkropachev dkropachev force-pushed the dk/fix-cluster-status-parser branch from ee206b2 to 902a029 Compare September 8, 2024 12:39
Copy link
Contributor

@tchaikov tchaikov left a comment

Choose a reason for hiding this comment

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

could improve the title a little bit:

tests/ccmcluster.py: ignore empty lines in parse_cluster_status()

EDIT: s/ccmlib/tests/.

for line in stdout.split("\n")[2:]:
node, status = line.split(":")
chunks = line.split(":")
if len(chunks) != 2:
Copy link
Contributor

@tchaikov tchaikov Sep 8, 2024

Choose a reason for hiding this comment

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

presumably it was an empty line which broke the test. an alternative is:

if not line:
    # ignore empty lines
    continue
node, status = line.split(":", 1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

presumably it was an empty line which broke the test. an alternative is:

tbh, I have no idea which line broke it, but it is better to make it as resiliant as possible.

if not line:
    # ignore empty lines
    continue
node, status = line.split(":", 1)

This code will still fail if line does not contain ':'.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, by looking at the error message, i think the offending line was empty.

as resiliant as possible.

i disagree. we program with a contract. "as resilient as possible" without a contract is error-prune, because we don't have a standard or contract for "as resilient as possible".

anyway, this is not that important in this context.

Copy link
Contributor

@tchaikov tchaikov left a comment

Choose a reason for hiding this comment

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

just two nits. lgtm.

Copy link
Contributor

@fruch fruch left a comment

Choose a reason for hiding this comment

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

LGTM

@fruch
Copy link
Contributor

fruch commented Sep 8, 2024

could improve the title a little bit:

ccmlib/ccmcluster.py: ignore empty lines in parse_cluster_status()

also it's tests/ccmcluster.py, which is kind of important context

@dkropachev dkropachev changed the title ccmlib/ccmcluster.py: make parse_cluster_status ignore lines that does not match test/ccmcluster.py: make parse_cluster_status ignore lines that does not match Sep 8, 2024
@dkropachev dkropachev changed the title test/ccmcluster.py: make parse_cluster_status ignore lines that does not match tests/ccmcluster.py: make parse_cluster_status ignore lines that does not match Sep 8, 2024
not match

It could fail with following error:
```
    def parse_cluster_status(self, stdout):
        """
            Output:

            Cluster: 'CCMCluster-reloc'
            ---------------------------
            node1: UP

            return:
            [(node1, UP)]
        """
        nodes_status = []
        for line in stdout.split("\n")[2:]:
>           node, status = line.split(":")
E           ValueError: not enough values to unpack (expected 2, got 1)
```
@dkropachev dkropachev force-pushed the dk/fix-cluster-status-parser branch from 902a029 to b849bb2 Compare September 8, 2024 13:37
@dkropachev
Copy link
Contributor Author

could improve the title a little bit:

ccmlib/ccmcluster.py: ignore empty lines in parse_cluster_status()

also it's tests/ccmcluster.py, which is kind of important context

Updated.

@fruch fruch merged commit b69d30f into scylladb:next Sep 10, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants