Bug 2172413
| Summary: | Logs were duplicated after calling netinfo.show_running_config() | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 9 | Reporter: | Karthik Sundaravel <ksundara> |
| Component: | nmstate | Assignee: | Gris Ge <fge> |
| Status: | CLOSED MIGRATED | QA Contact: | Mingyu Shi <mshi> |
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 9.1 | CC: | ferferna, jiji, jishi, network-qe, sfaye, till |
| Target Milestone: | rc | Keywords: | MigratedToJIRA, Triaged |
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2023-08-17 09:23:10 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
Description of problem: Run the below python code from libnmstate import netapplier from libnmstate import netinfo from libnmstate.schema import Interface import logging import sys import yaml def logger_level(logger, verbose=False, debug=False): log_level = logging.DEBUG if debug: log_level = logging.DEBUG elif verbose: log_level = logging.INFO logger.setLevel(log_level) def configure_logger(log_file=False, verbose=False, debug=False): LOG_FORMAT = ('%(asctime)s.%(msecs)03d %(levelname)s ' '%(name)s.%(funcName)s %(message)s') DATE_FORMAT = '%Y-%m-%d %H:%M:%S' logger = logging.getLogger("os_net_config") logger.handlers.clear() logger_level(logger, verbose, debug) logger.propagate = True formatter = logging.Formatter(fmt=LOG_FORMAT, datefmt=DATE_FORMAT) if log_file: file_handler = logging.handlers.RotatingFileHandler( _LOG_FILE, maxBytes=10485760, backupCount=7 ) file_handler.setFormatter(formatter) logger.addHandler(file_handler) stream_handler = logging.StreamHandler(sys.stdout) stream_handler.setFormatter(formatter) logger.addHandler(stream_handler) return logger logger = configure_logger() logger.debug("---------PRE_NETINFO LOG-----------------") ifaces = netinfo.show_running_config()[Interface.KEY] ifaces_dmp = yaml.dump(ifaces, default_flow_style = False, allow_unicode = True, encoding = None) logger.debug("-------POST_NETINFO_LOG------------------") logger.debug("Running info: \n %s" % ifaces_dmp) Its found that after invoking netinfo.show_running_config(), the logs are duplicated. Version-Release number of selected component (if applicable): nmstatectl 2.2.6 Actual results: [root@dell-r640-oss-14 ~]# python nmstate_test.py 2023-02-14 16:53:59.240 DEBUG os_net_config.<module> ---------PRE_NETINFO LOG----------------- 2023-02-14 16:53:59.360 DEBUG os_net_config.<module> -------POST_NETINFO_LOG------------------ DEBUG:os_net_config:-------POST_NETINFO_LOG------------------ 2023-02-14 16:53:59.360 DEBUG os_net_config.<module> Running info: ..... Expected results: 2023-02-14 16:53:59.240 DEBUG os_net_config.<module> ---------PRE_NETINFO LOG----------------- 2023-02-14 16:53:59.360 DEBUG os_net_config.<module> -------POST_NETINFO_LOG------------------ 2023-02-14 16:53:59.360 DEBUG os_net_config.<module> Running info: ....