-
Notifications
You must be signed in to change notification settings - Fork 11
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
Cleanup after lbaas management script #30
base: neutron-ha-tool-maintenance
Are you sure you want to change the base?
Cleanup after lbaas management script #30
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit message of c0f5110 seem wrong: "Move the responsibility of connection to delete_remote_namespace" should be "... to delete_router_namespace"
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.
should be fixed now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
We agreed to clean up after the lbaasv2 management script has been merged, so that's the goal of this PR.
TODOS
RemoteRouterNSCleanup
andRemoteLbaasV2Cleanup
's public functions look alike, refactor them so to re-use network namespace cleanup methods.Remaining issues
exec_command
is the one we need. That needs to be tested separately.