Bug 1045680

Summary: [Docs] [MariaDB] Documentation for stamping the DB is missing in case of manual installation
Product: Red Hat OpenStack Reporter: Fabio Massimo Di Nitto <fdinitto>
Component: documentationAssignee: Deepti Navale <dnavale>
Status: CLOSED CURRENTRELEASE QA Contact: Radek Bíba <rbiba>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.0CC: adahms, chrisw, dnavale, fdinitto, ihrachys, lpeer, majopela, sclewis, srevivo
Target Milestone: ---Keywords: Documentation, ZStream
Target Release: 5.0 (RHEL 7)   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1046087 (view as bug list) Environment:
Last Closed: 2016-06-29 13:26:38 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 Fabio Massimo Di Nitto 2013-12-21 06:31:09 UTC
After upgrading from Beta to GA of neutron-server:

[root@fab3 neutron]# /etc/init.d/neutron-server start
neutron-db-check: ERROR: neutron database does not have version information. You must run the "neutron-db-manage stamp" command before starting neutron services.

[root@fab3 neutron]# neutron-db-manage stamp 
usage: neutron-db-manage stamp [-h] [--sql] revision
neutron-db-manage stamp: error: too few arguments
You have mail in /var/spool/mail/root

[root@fab3 neutron]# neutron-db-manage stamp --sql 1
No handlers could be found for logger "neutron.common.legacy"
Traceback (most recent call last):
  File "/usr/bin/neutron-db-manage", line 10, in <module>
    sys.exit(main())
  File "/usr/lib/python2.6/site-packages/neutron/db/migration/cli.py", line 143, in main
    CONF.command.func(config, CONF.command.name)
  File "/usr/lib/python2.6/site-packages/neutron/db/migration/cli.py", line 86, in do_stamp
    sql=CONF.command.sql)
  File "/usr/lib/python2.6/site-packages/neutron/db/migration/cli.py", line 59, in do_alembic_command
    getattr(alembic_command, cmd)(config, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/alembic/command.py", line 214, in stamp
    script.run_env()
  File "/usr/lib/python2.6/site-packages/alembic/script.py", line 191, in run_env
    util.load_python_file(self.dir, 'env.py')
  File "/usr/lib/python2.6/site-packages/alembic/util.py", line 186, in load_python_file
    module = imp.load_source(module_id, path, open(path, 'rb'))
  File "/usr/lib/python2.6/site-packages/neutron/db/migration/alembic_migrations/env.py", line 44, in <module>
    importutils.import_class(class_path)
  File "/usr/lib/python2.6/site-packages/neutron/openstack/common/importutils.py", line 35, in import_class
    traceback.format_exception(*sys.exc_info())))
ImportError: Class  cannot be found (['Traceback (most recent call last):\n', '  File "/usr/lib/python2.6/site-packages/neutron/openstack/common/importutils.py", line 30, in import_class\n    __import__(mod_str)\n', 'ValueError: Empty module name\n'])

Comment 1 Fabio Massimo Di Nitto 2013-12-21 06:38:25 UTC
 neutron-db-manage --config-file /usr/share/neutron/neutron-dist.conf --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini stamp head

appears to solve the issue but:

1) it's all but obvious.
2) no this is not related to https://bugzilla.redhat.com/show_bug.cgi?id=1037675
   the installation was done manually.
3) I didn't notice any call to neutron-db-manage in the official docs either.
4) neutron-db-manage should seriously either be invoked automatically or
   provide a man page explaining how to invoke it.

Comment 2 lpeer 2013-12-23 09:42:41 UTC
>    the installation was done manually.
In case you installed it manually you need to stamp the data-base manually exactly as you did.

I think you are missing the documentation part so I'm changing this bug to documentation.
The documentation should say that if you install Neutron manually you should run 
neutron-db-manage manually to stamp the DB.

> 3) I didn't notice any call to neutron-db-manage in the official docs either.

I agree, that's why I'm moving it to documentation

> 4) neutron-db-manage should seriously either be invoked automatically or
>    provide a man page explaining how to invoke it.

I agree that a man page would be useful, Not sure about the automatic invocation, by which process? it is part of the installation process and we take care of that within packstack and foreman (should be in the puppet modules they are sharing)

Comment 3 Fabio Massimo Di Nitto 2013-12-23 15:34:45 UTC
(In reply to lpeer from comment #2)
> >    the installation was done manually.
> In case you installed it manually you need to stamp the data-base manually
> exactly as you did.
> 
> I think you are missing the documentation part so I'm changing this bug to
> documentation.
> The documentation should say that if you install Neutron manually you should
> run 
> neutron-db-manage manually to stamp the DB.
> 

That's not enough. You still need to fix the traceback and provide useful output from invoking neutron-db-manage.

> > 3) I didn't notice any call to neutron-db-manage in the official docs either.
> 
> I agree, that's why I'm moving it to documentation

If anything it needs to be cloned

> 
> > 4) neutron-db-manage should seriously either be invoked automatically or
> >    provide a man page explaining how to invoke it.
> 
> I agree that a man page would be useful, Not sure about the automatic
> invocation, by which process? it is part of the installation process and we
> take care of that within packstack and foreman (should be in the puppet
> modules they are sharing)

rpm %pre %post exists to fit this kind of situations. You can easily verify from what version to what version of the package you are upgrading and invoke neutron-db-manage with proper arguments.

Comment 5 Andrew Dahms 2015-04-20 04:21:47 UTC
Assigning to Deepti for review.

Deepti, this bug has been around for some time, and I am most interested in knowing whether the above steps are required for an upgrade from 5.0 to 6.0.

Would you be able to take a look and see if this is the case?

Comment 11 Ihar Hrachyshka 2016-01-12 14:46:50 UTC
I believe it is applicable for OSP4 to OSP5 upgrades only. In OSP5 to later upgrades, we can assume it's already stamped.

Traceback is also fixed at least in latest Mitaka:

-bash-4.2$ neutron-db-manage stamp --sql 1
No handlers could be found for logger "oslo_config.cfg"
  Running stamp for neutron ...
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Generating static SQL
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
ERROR [alembic.util.messaging] Can't locate revision identified by '1'
  FAILED: Can't locate revision identified by '1'

I suspect it may still affect some older code though. Not that the issue would require special attention since it's innocent.

The proper order of things is that documentation for OSP5 is checked for the inclusion of the stamp instructions, and then we are probably good to go for OSP.

Comment 14 Mike McCune 2016-03-28 22:30:10 UTC
This bug was accidentally moved from POST to MODIFIED via an error in automation, please see mmccune with any questions