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

dhcp class + using usi in daq #520

Merged
merged 15 commits into from
Jul 10, 2020

Conversation

henry54809
Copy link
Collaborator

No description provided.

@henry54809 henry54809 requested a review from grafnu June 30, 2020 23:02
@codecov
Copy link

codecov bot commented Jun 30, 2020

Codecov Report

Merging #520 into master will decrease coverage by 0.31%.
The diff coverage is 51.51%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #520      +/-   ##
==========================================
- Coverage   79.89%   79.58%   -0.32%     
==========================================
  Files          21       21              
  Lines        3621     3649      +28     
==========================================
+ Hits         2893     2904      +11     
- Misses        728      745      +17     
Flag Coverage Δ
#aux 74.78% <51.51%> (-0.20%) ⬇️
#base 76.08% <51.51%> (-0.27%) ⬇️
#dhcp 71.13% <51.51%> (-0.23%) ⬇️
#many 71.25% <51.51%> (-0.23%) ⬇️
#modules 23.51% <21.21%> (+0.06%) ⬆️
#topo 73.11% <51.51%> (-0.19%) ⬇️
Impacted Files Coverage Δ
daq/host.py 88.77% <30.43%> (-2.57%) ⬇️
daq/gateway.py 90.95% <100.00%> (+0.19%) ⬆️
daq/runner.py 86.55% <100.00%> (ø)
daq/topology.py 96.53% <0.00%> (+0.01%) ⬆️

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 499bff9...ae716aa. Read the comment docs.

Copy link
Collaborator

@grafnu grafnu left a comment

Choose a reason for hiding this comment

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

Something's not right with the refactoring -- it doesn't match what was in the design proposal and I'm really not convinced there should be multiple dhcp containers.

bin/usi Outdated
@@ -1,6 +1,6 @@
#!/bin/bash -e

echo Starting USI
docker run -d --network=host --name daq-usi daqf/usi
docker run -d --network=host --name daq-usi daqf/usi || true
Copy link
Collaborator

Choose a reason for hiding this comment

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

under what condition is failure here ok?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

topo integration test doesn't need it so the image wasn't build for that test. I could either build this image for topo for ignore the failure.

Something's not right with the refactoring -- it doesn't match what was in the design proposal and I'm really not convinced there should be multiple dhcp containers.
The refactoring wasn't covered in the design proposal so which part were you referring to?

@@ -37,3 +37,6 @@ long_dhcp_response_sec: 105

# finish hook: executed at the end of every test
finish_hook: bin/dump_network

# usi
Copy link
Collaborator

Choose a reason for hiding this comment

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

Either make comment longer or remove

@@ -37,3 +37,6 @@ long_dhcp_response_sec: 105

# finish hook: executed at the end of every test
finish_hook: bin/dump_network

# usi
usi_url: localhost:5000
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: newline at end of line/file

self._initialize()
except Exception as e:
LOGGER.error(
'Gateway initialization failed, terminating: %s', str(e))
Copy link
Collaborator

Choose a reason for hiding this comment

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

!Gateway

def _initialize(self):
LOGGER.info('Initializing DHCP server on port %d', self._host_port)
cls = docker_host.make_docker_host(
'daqf/networking', prefix='daq', network='bridge')
Copy link
Collaborator

Choose a reason for hiding this comment

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

why networking for dhcp server?

daq/host.py Outdated
@@ -602,6 +641,7 @@ def _get_switch_config(self):
return {
'ip': self.switch_setup.get('ip_addr'),
'model': self.switch_setup.get('model'),
'telnet_port': int(self.switch_setup.get('telnet_port', self._DEFAULT_TELNET_PORT)),
Copy link
Collaborator

Choose a reason for hiding this comment

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

'telnet_port' isn't right -- what is it used for? usi_port?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the telnet port for usi to talk to the switch. usi port is defined in the usi_url config

Copy link
Collaborator

Choose a reason for hiding this comment

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

as I mentioned elsewhere "telnet_port" is way to generic and not all that interesting (telnet is a protocol) -- the name should indicate more the use not the protocol.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I understand that the _DEFAULT_TELNET_PORT should be more descriptive but the telnet_port is already under the switch_setup config so isn't saying switch_telnet_port redundant? same with username, password, model etc.

daq/host.py Outdated
@@ -59,6 +64,7 @@ class ConnectedHost:
"""Class managing a device-under-test"""

_STARTUP_MIN_TIME_SEC = 5
_DEFAULT_TELNET_PORT = 23
Copy link
Collaborator

Choose a reason for hiding this comment

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

needs more qualifiers... maybe add switch in there?

@@ -114,6 +114,9 @@ message DaqConfig {

// Set time between port disconnect and host tests shutdown
int32 port_flap_timeout_sec = 48;

// USI url
string usi_url = 49;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would encapsulate this in a message -- it has a feeling that eventually it might have more parameters.

@@ -139,6 +142,9 @@ message SwitchSetup {

// IP address template and subnet for module ip addresses
string mods_addr = 16;

// Switch connect Telnet port
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this needs a slightly better name "telnet_port" is very generic... maybe cmd_port? Talk about what it's use is, not the underlying protocol.

@grafnu
Copy link
Collaborator

grafnu commented Jul 1, 2020 via email

@henry54809
Copy link
Collaborator Author

You mentioned that we should limit to 1 DHCP server per container so I thought the diagram was clear in that the DHCP servers are part of a gateway but are different containers; plus I don't think it's possible to run multiple dnsmasq on the same container since they will attempt to listen on the same port. Original intention was for gateway to be its own container with multiple DHCP servers attached but I realized the gateway would be doing nothing at the point so I just made the first DHCP server the gateway container.

In the proposal diagrams all the DHCP servers are inside the Gateway container, not separate containers. I would build the container for the topo tests. I'd rather keep the hard failure in case of an error.

On Tue, Jun 30, 2020 at 8:27 PM henry54809 @.> wrote: @.* commented on this pull request. ------------------------------ In bin/usi <#520 (comment)>: > @@ -1,6 +1,6 @@ #!/bin/bash -e echo Starting USI -docker run -d --network=host --name daq-usi daqf/usi +docker run -d --network=host --name daq-usi daqf/usi || true topo integration test doesn't need it so the image wasn't build for that test. I could either build this image for topo for ignore the failure. Something's not right with the refactoring -- it doesn't match what was in the design proposal and I'm really not convinced there should be multiple dhcp containers. The refactoring wasn't covered in the design proposal so which part were you referring to? — You are receiving this because your review was requested. Reply to this email directly, view it on GitHub <#520 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIEPD3KFGCTR7FMUNKVXETRZKUKTANCNFSM4OM2T7IQ .

@grafnu
Copy link
Collaborator

grafnu commented Jul 1, 2020 via email

@grafnu
Copy link
Collaborator

grafnu commented Jul 1, 2020

I don't think that's a safe assumption to make about the diagram. The proposal/diagram should be a very clear description of the relevant aspect. The gateway is a container, and the diagram shows DHCP servers in that container as the simplest explanation. This is the kind of complexity I was talking about when I said that I don't think we should be considering the multiple-DHCP servers if it complicates the architecture at all. You're complicating the (conceptual) architecture for something that's not needed.

The "gateway" is the higher-order concept than the DHCP server, since it's a container that does a bunch of different things one of which is being a DHCP server, so it does not make sense to invert the relationship. If we need multiple servers in the future then we can cross that bridge when we come to it but for now, the basic structure of "the gateway" should remain constant. It's not a big structural difference over what you have now, it's just organized slightly differently.

I would recommend you convert your new DHCPServer class to a GatewayHost class and then we can deal with the ramifications of multiple of them later. It's essentially keeping the refactoring smaller, so not changing the significant semantics (e.g. the gateway construct remains unchanged), but it's setting the groundwork for a different change in the future (e.g. the re-introduction of a DHCPServer or something).

You mentioned that we should limit to 1 DHCP server per container so I thought the diagram was clear in that the DHCP servers are part of a gateway but are different containers; plus I don't think it's possible to run multiple dnsmasq on the same container since they will attempt to listen on the same port. Original intention was for gateway to be its own container with multiple DHCP servers attached but I realized the gateway would be doing nothing at the point so I just made the first DHCP server the gateway container.

In the proposal diagrams all the DHCP servers are inside the Gateway container, not separate containers. I would build the container for the topo tests. I'd rather keep the hard failure in case of an error.

On Tue, Jun 30, 2020 at 8:27 PM henry54809 @.> wrote: _@**.**_* commented on this pull request. ------------------------------ In bin/usi <#520 (comment)>: > @@ -1,6 +1,6 @@ #!/bin/bash -e echo Starting USI -docker run -d --network=host --name daq-usi daqf/usi +docker run -d --network=host --name daq-usi daqf/usi || true topo integration test doesn't need it so the image wasn't build for that test. I could either build this image for topo for ignore the failure. Something's not right with the refactoring -- it doesn't match what was in the design proposal and I'm really not convinced there should be multiple dhcp containers. The refactoring wasn't covered in the design proposal so which part were you referring to? — You are receiving this because your review was requested. Reply to this email directly, view it on GitHub <#520 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIEPD3KFGCTR7FMUNKVXETRZKUKTANCNFSM4OM2T7IQ .

@henry54809
Copy link
Collaborator Author

Updated to use USI OVS switch. PTAL.

bin/usi Outdated
@@ -0,0 +1,18 @@
#!/bin/bash -e
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know it's weird and a bit off, but for now I think this should go in cmd/ and not bin/ -- simply because it's most similar to things like cmd/faux which do the same thing (start container). At some point we have to clean everything up so it makes sense, but for now I'm going with consistency...

cmd/exrun Outdated
@@ -81,7 +82,8 @@ sudo rm -f $cleanup_file
function autostart {
tmp=`mktemp`
echo DAQ autostart $@
eval $@ | tee $tmp
eval $@ > $tmp #Don't use "eval $@ | tee $tmp" here. Doesn't work for bin/usi
Copy link
Collaborator

Choose a reason for hiding this comment

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

space after #, and period at end of sentence.

@@ -31,7 +33,7 @@ protected String getInterfaceByPort(int devicePort) throws FileNotFoundException
Matcher m = pattern.matcher(line);
return m.find();
}).findFirst().get();

bufferedReader.close();
Copy link
Collaborator

Choose a reason for hiding this comment

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

generall the java try-with-resources pattern is better than explicitly closing the object. https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html

daq/gateway.py Outdated
LOGGER.info('Initializing gateway %s as %s/%d',
self.name, host_name, host_port)
self.tmpdir = self._setup_tmpdir('inst', host_name)
self.host = self._start_dhcp_server(host_port).host
Copy link
Collaborator

Choose a reason for hiding this comment

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

As per previous discussion, the top-level primary construct here should be the gateway (or "networking" container if you prefer). For the simple case, DHCP should be a sub-component of that.

@henry54809
Copy link
Collaborator Author

Decided to try out a gateway container as the top level construct with separate dhcp server container(s). All changes related to that are contained in the last commit. I think the changes maintain the current structure but offer more flexibility without much complexity. There can be more optimization in terms of the starting of the DHCP server containers but I want to see what you think about this first.
PTAL

@grafnu
Copy link
Collaborator

grafnu commented Jul 10, 2020 via email

@henry54809
Copy link
Collaborator Author

I think it's best to keep the original gateway class for now. I've reverted changes related to gateway and dhcp server. Spawning more networking containers(separate from gateway or not) does bring more complexity with the current ntp setup which will take more time that we can afford right now to resolve. We can revisit this when we need to convert gateway for the orchestrated testing / support multiple dhcp servers. PTAL

Copy link
Collaborator

@grafnu grafnu left a comment

Choose a reason for hiding this comment

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

Just one very small comment about resource handling with BufferedReader

Matcher m = pattern.matcher(line);
return m.find();
}).findFirst().get();
bufferedReader.close();
Copy link
Collaborator

Choose a reason for hiding this comment

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

close is handled implicitly by the try clause, so you shouldn't do it explicitly here

@henry54809 henry54809 merged commit a0bc2b7 into faucetsdn:master Jul 10, 2020
@henry54809 henry54809 deleted the feature/dhcp-class branch January 12, 2021 00:00
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