Bug 967781

Summary: oslo-config overwrites cli argument values by values from config file
Product: Red Hat OpenStack Reporter: Attila Fazekas <afazekas>
Component: python-oslo-configAssignee: Jakub Libosvar <jlibosva>
Status: CLOSED DUPLICATE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0CC: afazekas, chrisw, fpercoco, hateya, jhenner, jkt, jlibosva, lpeer, markmc, ndipanov, rohara, rvaknin, yeylon
Target Milestone: Upstream M3   
Target Release: 4.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-12-09 15:58:40 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:
Bug Depends On: 989661    
Bug Blocks:    

Description Attila Fazekas 2013-05-28 10:34:25 UTC
As quantum user the following command logs to the stdout and to the quantum/ server.log, but does not logs to specified logfile.
=====
python /usr/bin/quantum-lbaas-agent --log-file /var/log/quantum/lbaas-agent.log --config-file /etc/quantum/quantum.conf --config-file /etc/quantum/lbaas_agent.ini --debug --verbose
2013-05-28 10:28:29  WARNING [quantum.agent.common.config] Deprecated: DEFAULT.root_helper is deprecated! Please move root_helper configuration to [AGENT] section.
2013-05-28 10:28:29  WARNING [quantum.agent.common.config] Deprecated: DEFAULT.root_helper is deprecated! Please move root_helper configuration to [AGENT] section.

I do not have any other log file in the /var/log/quantum/.
=====
$ ls /var/log/quantum/
server.log


The init scripts are using similar commands for starting the services.
I have the same issue with all other agents.

Comment 2 Jaroslav Henner 2013-05-28 22:02:16 UTC
Well if I start it by init script, it does log to
/var/log/quantum/lbaas-agent.log

Comment 3 Ryan O'Hara 2013-07-19 15:17:06 UTC
Is log_file being set in quantum.conf? It seems that --log-file will be ignored if log_file is set in quantum.conf.

# egrep ^log_file /etc/quantum/quantum.conf 
log_file=/tmp/quantum.log

# quantum-lbaas-agent --log-file /var/log/quantum/lbaas-agent.log --config-file /etc/quantum/quantum.conf --config-file /etc/quantum/lbaas_agent.ini --debug --verbose
2013-07-19 10:14:48     INFO [quantum.common.config] Logging enabled!
2013-07-19 10:14:48     INFO [quantum.openstack.common.rpc.impl_qpid] Connected to AMQP server on 10.15.85.141:5672
2013-07-19 10:14:48     INFO [quantum.openstack.common.rpc.impl_qpid] Connected to AMQP server on 10.15.85.141:5672

# cat /var/log/quantum/lbaas-agent.log
cat: /var/log/quantum/lbaas-agent.log: No such file or directory

# cat /tmp/quantum.log 
2013-07-19 10:14:48     INFO [quantum.common.config] Logging enabled!
2013-07-19 10:14:48     INFO [quantum.openstack.common.rpc.impl_qpid] Connected to AMQP server on 10.15.85.141:5672
2013-07-19 10:14:48     INFO [quantum.openstack.common.rpc.impl_qpid] Connected to AMQP server on 10.15.85.141:5672
2013-07-19 10:15:21     INFO [quantum.openstack.common.service] Caught SIGINT, exiting

Note that if log_file is *not* set in quantum.conf, quantum-lbaas-agent will log to the file given via --log-file.

Comment 6 Ryan O'Hara 2013-07-29 17:27:20 UTC
This is only a bug if the command-line option "--log-file" is expected to take precedence over the "log_file" parameter in the config file.

Comment 7 Attila Fazekas 2013-08-09 05:23:55 UTC
Yes my expectation is the command-line options always takes precedence to anything else.

1. CLI options
2. Environment variables
3. Configuration file
(4. distribution defaults)
5. Application defaults

Comment 8 Rami Vaknin 2013-11-06 10:54:22 UTC
I've tested this scenario in rhos 4.0 on rhel 6.5 (puddle 2013-10-28.2), I've installed the env using packstack and my neutron.conf be default mentions only the log_dir (which is /var/log/neutron) so by default all the agents logs are written well and in the right location:

# ll /var/log/neutron/
total 116
-rw-r--r--. 1 neutron neutron  9392 Nov  6 12:21 l3-agent.log
-rw-r--r--. 1 neutron neutron  2977 Nov  6 12:50 lbaas-agent.log
-rw-r--r--. 1 neutron neutron   154 Nov  6 12:11 metadata-agent.log
-rw-r--r--. 1 root    root       77 Nov  6 12:12 neutron-ns-metadata-proxy-e6e9549f-e6a9-4070-9df1-6a1f332aecb0.log
-rw-r--r--. 1 neutron neutron 15686 Nov  6 12:21 openvswitch-agent.log
-rw-r--r--. 1 neutron neutron   266 Nov  6 12:11 ovs-cleanup.log
-rw-r--r--. 1 neutron neutron 66489 Nov  6 12:50 server.log


I tried to add log_file to the neutron.conf, it indeed looks like a bug - the process' "--config-file" is ignored and the logging are written to the location specified in neutron.conf.

Comment 9 Jakub Libosvar 2013-11-18 17:57:37 UTC
This issue is more severe, it's not related to lbaas but to config that's used by all agents.

Comment 10 Jakub Libosvar 2013-11-19 15:03:23 UTC
According https://bugs.launchpad.net/oslo/+bug/1176817/comments/2 this is expected behavior. 

If you pass arguments --foo bar --config-file baz.conf and in baz.conf is defined foo=baz, then bar value will be overwritten by baz.

If you pass arguments in different order: --config-file baz.conf --foo bar, then foo will have value bar.

Changing component to oslo to decide whether this is bug or not.

Comment 12 Flavio Percoco 2013-12-09 15:58:40 UTC

*** This bug has been marked as a duplicate of bug 960670 ***