Cleanup after lbaas management script#30
Open
matelakat wants to merge 11 commits intoSUSE-Cloud:neutron-ha-tool-maintenancefrom
matelakat:refactoring-after-lbaas-tool
Open
Cleanup after lbaas management script#30matelakat wants to merge 11 commits intoSUSE-Cloud:neutron-ha-tool-maintenancefrom matelakat:refactoring-after-lbaas-tool
matelakat wants to merge 11 commits intoSUSE-Cloud:neutron-ha-tool-maintenancefrom
matelakat:refactoring-after-lbaas-tool
Conversation
Given that now we have multiple scripts, it makes sense to introduce a test runner. nosetests seems to support our weird file namings, so using that. It picked up signal_tester as a testcase, so that has been renamed. Also amended travis, and added noqa for some flake8 violations.
added 10 commits
May 8, 2017 16:37
Move the responsibility of connection to delete_router_namespace thus making delete_remote_namespace re-usable by the lbaasv2 cleanup classes.
The LbaasV2 cleanup was performing the same operations as RemoteNodeCleanup, so let's call that instead of repeating the lines. Also changing the log level to info. This means that info messages will be generated on router movement.
Separate out the responsibilities for connecting to a remote host, and create the Host abstraction that could run commands on a host. Also add some test helpers to ease creating a mock ssh connection instance. With this change, the responsibilites of RemoteNodeCleanup became smaller, and ssh related code could be re-used later. Also the internal ssh_client is hidden, so RemoteLbaasV2Cleanup does not need to know how the connection happens
As the existing logging statements all print out host, being able to
stringify SSHHost makes sense - this way logging statements can say
something like:
with connect_to_host('localhost', timeout=10) as host:
LOG.info('connected to %s', host)
connected_to_host sets the timeout for the run operation, thus it is not needed to specify it on each call. This makes _simple_ssh_command obsolete, thus removing it.
Since host implements str, we don't need to refer to target_host anymore in log messages.
Make it easier for mocking out an exec_command call of the ssh_client by providing a helper to make tests more readable.
Each uses were doing the same thing, instantiating a class and then calling a single method. Extracting it to one single method instead so that the internals could be refactored for a cleaner design and easier testability.
Introduce a Namespace class for managing namespaces and move methods from RemoteNodeCleanup to it. This eliminates the need for classes, and the class hierarchy as well.
Author
should be fixed now. |
rhafer
approved these changes
May 8, 2017
rhafer
left a comment
There was a problem hiding this comment.
Nice refactoring! Thanks a lot for taking the time to walk me through it on mumble. I really appreciate it.
As for the open questions, you raised in the initial comment. I think it's ok to address these things later. And I especially agree about the one about more testing.
As discussed in mumble, I don't think the socket.timeout thing is much of an issue though.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We agreed to clean up after the lbaasv2 management script has been merged, so that's the goal of this PR.
TODOS
RemoteRouterNSCleanupandRemoteLbaasV2Cleanup's public functions look alike, refactor them so to re-use network namespace cleanup methods.Remaining issues
exec_commandis the one we need. That needs to be tested separately.