Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output of breeze kvstore nodes is broken #14

Closed
tamihiro opened this issue Dec 4, 2017 · 2 comments
Closed

Output of breeze kvstore nodes is broken #14

tamihiro opened this issue Dec 4, 2017 · 2 comments

Comments

@tamihiro
Copy link
Contributor

tamihiro commented Dec 4, 2017

Issue Description

Breeze CLI returns nodes information in KvStore, but the output is pretty much broken.

Environment

  • latest commit 54566cc
  • OS version: ubuntu-16.04

Minimal test code / Steps to reproduce the issue

  1. Follow build instruction and install OpenR.
  2. Configure and run OpenR.
    sudo run_openr.sh
  3. Execute command.
    breeze kvstore nodes

What's the actual result?

                                                                                                                                                                                                                                                                                                                                                                                                                 Node    V6-Loopback    V4-Loopback
---------------  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  ------  -------------  -------------
* ubuntu-opnr-1  P   r   e   f   i   x                                               T   y   p   e       -   -   -   -   -   -   -   -   -   -   -   -   -   -   -           -   -   -   -   -   -   -   -        1   0  .    0  .    0  .    1  /    3   2                          L   O   O   P   B   A   C   K        2   0   0   1  :   d   b    8  :   :    1  /    1   2   8          L   O   O   P   B   A       C              K
> ubuntu-opnr-2  P   r   e   f   i   x                                               T   y   p   e       -   -   -   -   -   -   -   -   -   -   -   -   -   -   -           -   -   -   -   -   -   -   -        1   0  .    0  .    0  .    2  /    3   2                          L   O   O   P   B   A   C   K        2   0   0   1  :   d   b    8  :   :    2  /    1   2   8          L   O   O   P   B   A       C              K
> ubuntu-opnr-3  P   r   e   f   i   x                                               T   y   p   e       -   -   -   -   -   -   -   -   -   -   -   -   -   -   -           -   -   -   -   -   -   -   -        1   0  .    0  .    0  .    3  /    3   2                          L   O   O   P   B   A   C   K        2   0   0   1  :   d   b    8  :   :    3  /    1   2   8          L   O   O   P   B   A       C              K

What's the expected result?

Node             V6-Loopback      V4-Loopback
---------------  ---------------  -------------
* ubuntu-opnr-1  2001:db8::1/128  10.0.0.1/32
> ubuntu-opnr-2  2001:db8::2/128  10.0.0.2/32
> ubuntu-opnr-3  2001:db8::3/128  10.0.0.3/32

Solution suggested

Pull request #12

@saifhhasan
Copy link
Contributor

saifhhasan commented Dec 4, 2017

Thanks @tamihiro for updating request, it is much clear now that what was broken and how it is fixed. I am initiating pull, once it passes all tests in our internal CI build, it will automatically get pushed to Github and will be closed.

Cheers,
Saif

@tamihiro
Copy link
Contributor Author

tamihiro commented Dec 5, 2017

Thanks @saifhhasan for the follow up!

@tamihiro tamihiro closed this as completed Dec 5, 2017
facebook-github-bot pushed a commit that referenced this issue May 5, 2021
Summary:
Fix error in breeze decision:
```
# pyre-fixme[14]: `_run` overrides method defined in `OpenrCtrlCmd` inconsistently.
```
Reference: https://www.internalfb.com/intern/staticdocs/pyre/docs/errors/#1415-behavioral-subtyping

NOTE: Parameter types can't be more restrictive and return types can't be more permissive in overridden methods. The overriding function need to accept all arguments that the overridden function can.

 ---

The error happens because the superclass defines this _run() method like:
```
# The overriding function in superclass

def _run(self, client: OpenrCtrl.Client, *args, **kwargs) -> None:
   """
   To be implemented by sub-command
   """
   raise NotImplementedError
```

`*args, **kwargs` allows you to write functions with arbitrary number of arguments. When the subclass overrides this, it cannot be more restrictive than the superclass which means the subclass needs to allow the same arbitrary number of arguments.

 ---

So we have two ways to fix this:
1: As this diff, add the `*args,**kwargs,` as the parameters for overridden methods in the subclass.

2: Add all potential parameters and delete the `*args,**kwargs,` in the superclass. For the current codebase of this case, we need to add the parameters including but not limited to:
```
# The overriding function in superclass

def _run(self, client: OpenrCtrl.Client,
        nodes: set, # for DecisionPrefixesCmd, DecisionRoutesComputedCmd, DecisionAdjCmd
        json: bool, # for DecisionPrefixesCmd, DecisionRoutesComputedCmd, DecisionAdjCmd, KvStoreCmdBase (defined as `in_json`)...
        prefix: str, # for DecisionPrefixesCmd, DecisionRoutesComputedCmd (defined `Any` type)
        client_type: str, # for DecisionPrefixesCmd
        labels: Any, # for DecisionRoutesComputedCmd
        areas: set, # for DecisionAdjCmd, PathCmd, DecisionValidateCmd...
        bidir: bool, # for DecisionAdjCmd, AdjCmd
        src: str, # for PathCmd
        dst: str,  # for PathCmd
        max_hop: int, # for PathCmd
        file: str, # for ConfigDryRunCmd
        key: str, # for ConfigEraseCmd, ConfigStoreCmd
        keys: List[str], # for KvKeyValsCmd
        value: str, # for ConfigStoreCmd
        detailed: bool, # for ReceivedRoutesCmd
        prefix_or_ip:  List[str] # for FibUnicastRoutesCmd
        duration: int, # for FibSnoopCmd
        initial_dump: bool, # for FibSnoopCmd
        prefixes: List[str], # for FibSnoopCmd
        originator: Any = None, # for KvKeysCmd
        ttl: bool = False,  # for KvKeysCmd
        interface: Any, # for KvShowAdjNodeCmd
        ...... # more to come~~
) -> None:
   """
   To be implemented by sub-command
   """
   raise NotImplementedError

```
but everytime the overridden function has a new parameter, we need to modify the overriding function.

{emoji:1f61b} If #1 (this diff) is good, I will make the similar changes in other modules.

Reviewed By: xiangxu1121

Differential Revision: D28204319

fbshipit-source-id: 4c07be177040fb31ae3d449ce29961b0e933696c
facebook-github-bot pushed a commit that referenced this issue May 7, 2021
Summary: Fix all overriding signature errors in breeze. Check D28204319 (b00fc6e) for more details.

Reviewed By: saumitrp, xiangxu1121

Differential Revision: D28239072

fbshipit-source-id: 1ba9b6b9a0e631823196c71638d93118b9717f16
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

No branches or pull requests

2 participants