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

[WORK IN PROGRESS] Add support to manage multiple switches #50

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

davidgengenbach
Copy link
Contributor

@davidgengenbach davidgengenbach commented Nov 8, 2020

@antoninbas I started de-coupling the client/context fields. Here is my current approach which should not break the current prompt.

However, there are breaking changes for people who use scripting:

  • p4runtime_sh.shell.client was renamed to p4runtime_sh.shell.global_client
  • p4_runtime_sh.shell.context was moved into the context field on P4RuntimeClient

So, if library users use p4_runtime_sh.shell.client and p4_runtime_sh.shell.context directly (which is not documented in the README), they will get undefined-errors.
While this is a breaking change, I am convinced that moving the Context into the P4RuntimeClient is the right way since the context is closely coupled to the client. For example, when setting the forwarding config via the P4RuntimeClient, the Context should be adapted as well.

To make clear that we introduce "breaking" changes, we can introduce versioning, e.g., by tagging the repo in the current state as v1 and directly moving to v2 with my changes.

🚧 Important: these changes were only tested manually. I will add unit tests as soon as the general approach is approved!

@davidgengenbach
Copy link
Contributor Author

By the way, Travis does not build the PR because

Owner p4lang does not have enough credits.

https://travis-ci.com/github/p4lang/p4runtime-shell/requests

The tests passed locally.

@davidgengenbach davidgengenbach force-pushed the master branch 4 times, most recently from ced0253 to 1e3aada Compare November 10, 2020 12:09
Copy link
Member

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

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

sorry for the delay

just one comment, otherwise LGTM.
not sure how you want to proceed for the unit tests: either 1) the current tests can be converted to stop relying on the global client (and we can add one simple test to make sure the global client still works), or 2) we can keep the current tests as they are and add a simple test for the "scripting" use case

@@ -2393,7 +2442,7 @@ def main():
if args.verbose:
logging.basicConfig(level=logging.DEBUG)

setup(args.device_id, args.grpc_addr, args.election_id, args.config)
setup(args.device_id, args.grpc_addr, args.election_id, args.config, set_global_client=True)
Copy link
Member

Choose a reason for hiding this comment

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

I feel like set_global_client is actually not needed in setup:

  • when using p4runtime_sh for scripts, there is no need for global client support IMO
  • when using p4runtime_sh as a CLI, setting the global client can be done here, in the main function

Base automatically changed from master to main March 24, 2021 02:53
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.

2 participants