From definition of mkstemp , this function creates a temp file and opens a file descriptor referring to that, where the user calling is responsible to close after usage.
In faulty above code, the file descriptor is saved to unused variable "_" and never being closed later within the function.
Following fix was tested and verified to solve the issue:
Create a json file that applies multiple changes so that to have multiple calls of _get_running_config().
For example I tried below file which resulted to 730 changes.
Failed to apply patch due to: Failed to apply patch on the following scopes:
-asic1: [Errno 24] Too many open files
Usage: config apply-patch [OPTIONS] PATCH_FILE_PATH
Try "config apply-patch -h" for help.
Error: Failed to apply patch on the following scopes:
-asic1: [Errno 24] Too many open files
Describe the results you expected:
Cli commad/code should not hit open file limit.
Patch Applier: asic1: verifying patch updates are reflected on ConfigDB.
Patch Applier: asic1 patch application completed.
Patch applied successfully.
Description
When the GCU apply-patch command results to many changes, it is noticed that the limit of open-files is hitted.
The issue has been identified with extra debug logging to exist in file "sonic-buildimage/src/sonic-utilities/generic_config_updater/change_applier.py", inside function _get_running_config.
From definition of mkstemp , this function creates a temp file and opens a file descriptor referring to that, where the user calling is responsible to close after usage.
In faulty above code, the file descriptor is saved to unused variable "_" and never being closed later within the function.
Following fix was tested and verified to solve the issue:
Steps to reproduce the issue:
Describe the results you received:
Cli commad failed with output::
Describe the results you expected:
Cli commad/code should not hit open file limit.
Output of
show version
:Output of
show techsupport
:Additional information you deem important (e.g. issue happens only occasionally):