Close some file descriptors that were left open

Before:
(undercloud) [stack@undercloud-0 ~]$ openstack overcloud generate fencing --output fencetest.yaml instackenv.json
/usr/lib/python3.6/site-packages/osc_lib/shell.py:176: ResourceWarning: unclosed file <_io.TextIOWrapper name='fencetest.yaml' mode='w' encoding='UTF-8'>
  ret_value = super(OpenStackShell, self).run_subcommand(argv)
/usr/lib/python3.6/site-packages/osc_lib/shell.py:176: ResourceWarning: unclosed file <_io.TextIOWrapper name='instackenv.json' mode='r' encoding='UTF-8'>
  ret_value = super(OpenStackShell, self).run_subcommand(argv)
sys:1: ResourceWarning: unclosed <ssl.SSLSocket fd=4, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('192.168.24.2', 56494), raddr=('192.168.24.2', 13000)>
sys:1: ResourceWarning: unclosed <ssl.SSLSocket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('192.168.24.2', 54102), raddr=('192.168.24.2', 13989)>

After:
(undercloud) [stack@undercloud-0 ~]$ openstack overcloud generate fencing --output fencetest.yaml instackenv.json
sys:1: ResourceWarning: unclosed <ssl.SSLSocket fd=4, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('192.168.24.2', 47694), raddr=('192.168.24.2', 13000)>
sys:1: ResourceWarning: unclosed <ssl.SSLSocket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('192.168.24.2', 45306), raddr=('192.168.24.2', 13989)>

Note that we also explicitly close an opened FileType in tripleoclient/v1/overcloud_execute.py
as it was spotted while writing this review.

NB: The SSL warnings will be investigated separately

Change-Id: Ic8122ad1982deed0434d797a3fb0fba8512b27ab
Closes-Bug: #1845927
This commit is contained in:
Michele Baldessari 2019-09-30 11:20:07 +02:00
parent d31fbf2e4c
commit 99a96ef416
2 changed files with 3 additions and 0 deletions

View File

@ -41,6 +41,7 @@ class RemoteExecute(command.Command):
self.log.debug("take_action(%s)" % parsed_args)
config = parsed_args.file_in.read()
parsed_args.file_in.close()
workflow_client = self.app.client_manager.workflow_engine
tripleoclients = self.app.client_manager.tripleoclient
messaging_websocket = tripleoclients.messaging_websocket()

View File

@ -100,6 +100,7 @@ class GenerateFencingParameters(command.Command):
def take_action(self, parsed_args):
nodes_config = utils.parse_env_file(parsed_args.instackenv)
parsed_args.instackenv.close()
workflow_input = {
'nodes_json': nodes_config,
@ -115,5 +116,6 @@ class GenerateFencingParameters(command.Command):
fencing_parameters = yaml.safe_dump(result, default_flow_style=False)
if parsed_args.output:
parsed_args.output.write(fencing_parameters)
parsed_args.output.close()
else:
print(fencing_parameters)