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

Feature/usi OVS switch #521

Merged
merged 20 commits into from
Jul 7, 2020
Merged

Feature/usi OVS switch #521

merged 20 commits into from
Jul 7, 2020

Conversation

henry54809
Copy link
Collaborator

No description provided.

@henry54809 henry54809 requested a review from grafnu July 2, 2020 13:20
@codecov
Copy link

codecov bot commented Jul 2, 2020

Codecov Report

Merging #521 into master will decrease coverage by 0.55%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #521      +/-   ##
==========================================
- Coverage   80.36%   79.81%   -0.56%     
==========================================
  Files          21       21              
  Lines        3621     3621              
==========================================
- Hits         2910     2890      -20     
- Misses        711      731      +20     
Flag Coverage Δ
#aux 75.12% <ø> (+0.14%) ⬆️
#base 76.34% <ø> (-0.75%) ⬇️
#dhcp 71.30% <ø> (-0.26%) ⬇️
#many ?
#modules 23.44% <ø> (ø)
#topo 73.29% <ø> (-0.12%) ⬇️
Impacted Files Coverage Δ
daq/gateway.py 90.76% <0.00%> (-3.81%) ⬇️
daq/runner.py 86.38% <0.00%> (-1.85%) ⬇️
daq/host.py 90.63% <0.00%> (-0.71%) ⬇️
daq/topology.py 96.72% <0.00%> (+0.20%) ⬆️
daq/stream_monitor.py 88.33% <0.00%> (+0.83%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 970c9d6...4126cbf. Read the comment docs.

@henry54809
Copy link
Collaborator Author

Renamed things. PTAL

@grafnu
Copy link
Collaborator

grafnu commented Jul 2, 2020 via email

@grafnu
Copy link
Collaborator

grafnu commented Jul 2, 2020 via email

@henry54809
Copy link
Collaborator Author

henry54809 commented Jul 2, 2020

grpc call in DAQ in my other PR: the proto has changed in this PR so the implementation won't match proto 100%.
https://github.com/faucetsdn/daq/pull/520/files#r449149359
My thinking was, since DAQ needs to explicitly pass faux_interface for OVS switch, the abstraction for faux switch was not going to work. Another thing I could do, which I was hesitant of, was reusing device_port to send the faux_interface instead of the device_port. That will keep the original SwitchInfo proto and original abstraction.

If they aren't at all similar then this abstraction is broken and not the right one. Either way, bleeding the faux in the abstraction is a massive code smell (stink even), so I want to get to the bottom of it. I'm not at all worried about performance.

On Thu, Jul 2, 2020 at 9:05 AM henry54809 @.> wrote: @.* commented on this pull request. ------------------------------ In usi/src/main/java/daq/usi/UsiImpl.java <#521 (comment)>: > @@ -19,7 +21,11 @@ public UsiImpl() { switchControllers = new HashMap<>(); } - private SwitchController getSwitchController(SwitchInfo switchInfo) { + private ISwitchController getSwitchController(SwitchInput switchInput) { + if (!switchInput.hasSwitchInfo()) { The 2 cases (with a physical switch and ovs) aren't at all similar which was why I had to make so many changes for ovs case to work. Only is faux interface is needed to be passed for the port connect and disconnect. As faux interface is a string(and not a device port), it doesn't match the existing signatures for all of the service functions. I decided to just pass the faux interface separately from the existing switchInfo and pass that information during object instantiation(the class is completely static so it hurt performance). The faux interface should be coming from DAQ; usi shouldn't take up the responsibility of parsing the config file. — You are receiving this because your review was requested. Reply to this email directly, view it on GitHub <#521 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIEPD5VC7ZDLMN37DB54GDRZSV4RANCNFSM4OO4IKNQ .

@grafnu
Copy link
Collaborator

grafnu commented Jul 2, 2020 via email

@henry54809
Copy link
Collaborator Author

PTAL

protected boolean commandPending = false;

public BaseSwitchController(String remoteIpAddress, int telnetPort, String username,
String password) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

check your style settings -- this should be hanging indent 4. Did it pass stickler/lint?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It passes stickler.mostly likely it means that rule is not configured.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually intellij won't even let me move this line to a less indented position. Is this a java syntax issue?

if (!switchInput.hasSwitchInfo()) {
return new OpenVSwitch(switchInput.getFauxInterface());
private SwitchController getSwitchController(SwitchInfo switchInfo) {
if (switchInfo.getModel().equals(OVS_SWITCH)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Still don't understand why OVS is special cased -- why isn't it just a generic drop-in replacement? (If we discussed, can you please summarize the reason)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OVS doesn’t need to be stored, doesn’t implement the runnable interface, so it needs to be handled first.

@@ -74,12 +66,15 @@ message SwitchInfo {
// Telnet Port
int32 telnet_port = 2;

// Device Port
Copy link
Collaborator

Choose a reason for hiding this comment

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

for above -- telnet_port should be changed to cmd_port... ?

@grafnu
Copy link
Collaborator

grafnu commented Jul 7, 2020 via email

@henry54809
Copy link
Collaborator Author

I initially tried what you're proposing but I didn't like the end result. The OVS class has mostly empty override methods which makes the inheritance model a pretty bad fit in my opinion. This is why I created the current switchcontroller interface to mitigate this even though it adds the specific ovs model check. PTAL of telnet_port renaming

Is there a reason OVS can't be handled the same way as the others? It doesn't need to store anything, I'm sure it can implement the runnable interface as a no-op. I don't get why it needs to be handled "first" because there's only one at a time. A generic implementation w/ no special case will be better overall even if it means a little bit extra in the implementing class. You're answering the question of if it can be special cased, rather than if it needs to be special cased.

On Mon, Jul 6, 2020 at 7:04 PM henry54809 @.> wrote: @.* commented on this pull request. ------------------------------ In usi/src/main/java/daq/usi/UsiImpl.java <#521 (comment)>: > public UsiImpl() { super(); switchControllers = new HashMap<>(); } - private ISwitchController getSwitchController(SwitchInput switchInput) { - if (!switchInput.hasSwitchInfo()) { - return new OpenVSwitch(switchInput.getFauxInterface()); + private SwitchController getSwitchController(SwitchInfo switchInfo) { + if (switchInfo.getModel().equals(OVS_SWITCH)) { OVS doesn’t need to be stored, doesn’t implement the runnable interface, so it needs to be handled first. — You are receiving this because your review was requested. Reply to this email directly, view it on GitHub <#521 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIEPD4VDVDGCUD6YDN3RVTR2J7C5ANCNFSM4OO4IKNQ .

@grafnu
Copy link
Collaborator

grafnu commented Jul 7, 2020 via email

@grafnu
Copy link
Collaborator

grafnu commented Jul 7, 2020 via email

@@ -63,8 +63,8 @@ message SwitchInfo {
// IP address of external switch.
string ip_addr = 1;

// Telnet Port
int32 telnet_port = 2;
// telnet port for sending switch commands.
Copy link
Collaborator

Choose a reason for hiding this comment

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

drop the "telnet" -- just cmd_port -- no need to specify the protocol here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Puneet and I both think cmd_port is too ambiguous. cmd_port can be construed as the openflow port or the switch control port. Too many things are named ports in the current configuration where some ports are for physical ports and others are for tcp ports.

@grafnu
Copy link
Collaborator

grafnu commented Jul 7, 2020 via email

@henry54809
Copy link
Collaborator Author

I still don't understand why protocol should not be stated in the config. There are multiple ways of accessing the switch, telnet, ssh or serial. What if we need to support ssh in the future? Any generic cmd_port (or any other name) will still cause confusion.

If you think cmd_port is too ambiguous then adding telnet isn't the right solution.

On Tue, Jul 7, 2020 at 7:53 AM henry54809 @.> wrote: @.* commented on this pull request. ------------------------------ In usi/src/main/proto/usi.proto <#521 (comment)>: > @@ -63,8 +63,8 @@ message SwitchInfo { // IP address of external switch. string ip_addr = 1; - // Telnet Port - int32 telnet_port = 2; + // telnet port for sending switch commands. Puneet and I both think cmd_port is too ambiguous. cmd_port can be construed as the openflow port or the switch control port. Too many things are named ports in the current configuration where some ports are for physical ports and others are for tcp ports. — You are receiving this because your review was requested. Reply to this email directly, view it on GitHub <#521 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIEPD6EOVQRIOIHTINTU4TR2MZFJANCNFSM4OO4IKNQ .

@grafnu
Copy link
Collaborator

grafnu commented Jul 7, 2020 via email

@henry54809
Copy link
Collaborator Author

removed telnet port configuration. PTAL.

BaseSwitchController sc = switchControllers.get(repr);
if (sc == null) {
SwitchController sc = switchControllers.computeIfAbsent(repr, key -> {
final SwitchController newController;
Copy link
Collaborator

Choose a reason for hiding this comment

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

extract switch statement to function (createNewController or something like that) - lengthy embedded functions aren't very readable...

switchInfo.getPassword());
BaseSwitchController sc = switchControllers.get(repr);
if (sc == null) {
SwitchController sc = switchControllers.computeIfAbsent(repr, key -> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't abbreviate sc, or just remove entirely (can just return directly)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Addressed. PTAL

throw new IllegalArgumentException("Unrecognized switch model "
+ switchInfo.getModel());
}
newController.start();
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit -- start should not be in create. They're typically two separate phases... first you create but don't really "do" anything, then there's a start after. This allows, for example, changing options or other things before actually activating it. It's fine as is, just something to ponder. Conceptually, the "create" function is the same as the class constructor, only difference is it redirects off of the switch type (aka the factory pattern).

@henry54809 henry54809 merged commit 499bff9 into faucetsdn:master Jul 7, 2020
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