add_is_default_to_subnetpool migration not postgresql-compliant

Bug #1557757 reported by Cedric Brandily
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Critical
Cedric Brandily

Bug Description

add_is_default_to_subnetpool migration[1] is not working on PostgreSQL with a non empty table because it adds a new column non-nullable with no default value and PostgreSQL cannot deduce it.

It doesn't affect MySQL which uses False as default value (wtf)

[1] neutron/db/migration/alembic_migrations/versions/mitaka/expand/13cfb89f881a_add_is_default_to_subnetpool.py
[2] stacktrace

user@host:/opt/stack/neutron$ neutron-db-manage --config-file ~/a upgrade head
No handlers could be found for logger "oslo_config.cfg"
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
  Running upgrade for neutron ...
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
INFO [alembic.runtime.migration] Running upgrade 34af2b5c5a59 -> 59cb5b6cf4d, Add availability zone
INFO [alembic.runtime.migration] Running upgrade 59cb5b6cf4d -> 13cfb89f881a, add is_default to subnetpool
Traceback (most recent call last):
  File "/opt/stack/neutron/.tox/py27/bin/neutron-db-manage", line 10, in <module>
    sys.exit(main())
  File "/opt/stack/neutron/neutron/db/migration/cli.py", line 749, in main
    return_val |= bool(CONF.command.func(config, CONF.command.name))
  File "/opt/stack/neutron/neutron/db/migration/cli.py", line 225, in do_upgrade
    desc=branch, sql=CONF.command.sql)
  File "/opt/stack/neutron/neutron/db/migration/cli.py", line 127, in do_alembic_command
    getattr(alembic_command, cmd)(config, *args, **kwargs)
  File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/command.py", line 174, in upgrade
    script.run_env()
  File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/script/base.py", line 397, in run_env
    util.load_python_file(self.dir, 'env.py')
  File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/util/pyfiles.py", line 81, in load_python_file
    module = load_module_py(module_id, path)
  File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/util/compat.py", line 79, in load_module_py
    mod = imp.load_source(module_id, path, fp)
  File "/opt/stack/neutron/neutron/db/migration/alembic_migrations/env.py", line 126, in <module>
    run_migrations_online()
  File "/opt/stack/neutron/neutron/db/migration/alembic_migrations/env.py", line 120, in run_migrations_online
    context.run_migrations()
  File "<string>", line 8, in run_migrations
  File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/runtime/environment.py", line 797, in run_migrations
    self.get_context().run_migrations(**kw)
  File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/runtime/migration.py", line 312, in run_migrations
    step.migration_fn(**kw)
  File "/opt/stack/neutron/neutron/db/migration/alembic_migrations/versions/mitaka/expand/13cfb89f881a_add_is_default_to_subnetpool.py", line 36, in upgrade
    nullable=False))
  File "<string>", line 8, in add_column
  File "<string>", line 3, in add_column
  File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/operations/ops.py", line 1535, in add_column
    return operations.invoke(op)
  File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/operations/base.py", line 318, in invoke
    return fn(self, operation)
  File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/operations/toimpl.py", line 123, in add_column
    schema=schema
  File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/ddl/impl.py", line 172, in add_column
    self._exec(base.AddColumn(table_name, column, schema=schema))
  File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/ddl/impl.py", line 118, in _exec
    return conn.execute(construct, *multiparams, **params)
  File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 914, in execute
    return meth(self, multiparams, params)
  File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
    return connection._execute_ddl(self, multiparams, params)
  File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 968, in _execute_ddl
    compiled
  File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context
    context)
  File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1337, in _handle_dbapi_exception
    util.raise_from_cause(newraise, exc_info)
  File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 200, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
    context)
  File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 450, in do_execute
    cursor.execute(statement, parameters)
oslo_db.exception.DBError: (psycopg2.IntegrityError) column "is_default" contains null values
 [SQL: 'ALTER TABLE subnetpools ADD COLUMN is_default BOOLEAN NOT NULL']

tags: added: mitaka-rc-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

Fix proposed to branch: master
Review: https://review.openstack.org/293152

Changed in neutron:
status: New → In Progress
summary: - Fix add_is_default_to_subnetpool migration in PostgreSQL
+ Invalid add_is_default_to_subnetpool migration in PostgreSQL
summary: - Invalid add_is_default_to_subnetpool migration in PostgreSQL
+ add_is_default_to_subnetpool migration not working with non-empty
+ subnetpool table
description: updated
summary: - add_is_default_to_subnetpool migration not working with non-empty
- subnetpool table
+ add_is_default_to_subnetpool migration not postgresql-compliant
description: updated
Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

Well done!

Changed in neutron:
milestone: none → mitaka-rc1
importance: Undecided → Critical
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/293152
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=79bc54a2d83e05d863dc836d651710859394e25c
Submitter: Jenkins
Branch: master

commit 79bc54a2d83e05d863dc836d651710859394e25c
Author: Cedric Brandily <email address hidden>
Date: Tue Mar 15 22:50:19 2016 +0100

    Fix add_is_default_to_subnetpool migration

    add_is_default_to_subnetpool migration[1] is not working with a
    non-empty subnetpool table because it adds a new non-nullable column
    (is_default) to subnetpool table without a default value.

    This change adds a server_default value to is_default column in
    subnetpool table and updates associated db migration.

    [1] neutron/db/migration/alembic_migrations/versions/mitaka/expand/\
         13cfb89f881a_add_is_default_to_subnetpool.py

    Closes-Bug: #1557757
    Change-Id: Ib0b2ac061d21a7d908f14b399b0bba06d94b7241

Changed in neutron:
status: In Progress → Fix Released
Revision history for this message
Thierry Carrez (ttx) wrote : Fix included in openstack/neutron 8.0.0.0rc1

This issue was fixed in the openstack/neutron 8.0.0.0rc1 release candidate.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.