Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2172413

Summary: Logs were duplicated after calling netinfo.show_running_config()
Product: Red Hat Enterprise Linux 9 Reporter: Karthik Sundaravel <ksundara>
Component: nmstateAssignee: Gris Ge <fge>
Status: CLOSED MIGRATED QA Contact: Mingyu Shi <mshi>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.1CC: ferferna, jiji, jishi, network-qe, sfaye, till
Target Milestone: rcKeywords: MigratedToJIRA, Triaged
Target Release: ---Flags: pm-rhel: mirror+
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 Karthik Sundaravel 2023-02-22 10:30:15 UTC
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:
....