AppArmor Config Status column has incorrect migration version

Bug #2045965 reported by Jagatguru Prasad Mishra
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
StarlingX
Fix Released
Medium
Jagatguru Prasad Mishra

Bug Description

Brief Description
-----------------

During upgrade migrations are run using sysinv-dbsync.

There is a new column i_host.apparmor_config_status, that does not get created during migration because it was not added to migration versions properly.

The migration for this new column was added to https://opendev.org/starlingx/config/src/commit/dade970c8a64e2ca0d9dbe297d98e428dc817cf2/sysinv/sysinv/sysinv/sysinv/db/sqlalchemy/migrate_repo/versions/126_apparmor.py#L17. the migration version for it being 126.

However, the migration version of the system is already at 127. So the column never gets created.

sysinv=# select * from migrate_version;
 repository_id | repository_path | version
---------------+----------------------------------------------------------------------+---------
 sysinv | /usr/lib64/python2.7/site-packages/sysinv/db/sqlalchemy/migrate_repo | 127
(1 row)

Severity
-----------------

Critical

Steps to Reproduce
-----------------

AIO-SX upgrade from stx6 to stx8 to stx9

Expected Behavior
-----------------

Migration works

Actual Behavior
-----------------
Migration does not work

Reproducibility
-----------------
100%

System Configuration
-----------------
AIO-SX

Example:
Load info (eg: 2022-03-10_20-00-07)

2022-12-06

Last Pass

N/A

Timestamp/Logs

sysadmin@localhost:~$ sudo /usr/bin/sysinv-upgrade update_controller_state
sysinv 2023-12-06 20:56:40.945 10711 INFO sysinv.cmd.upgrade [-] Called 'update_controller_state'
sysinv 2023-12-06 20:56:40.946 10711 INFO sysinv.cmd.upgrade [-] Updating upgrades data in sysinv database
sysinv 2023-12-06 20:56:45.440 10711 WARNING oslo_config.cfg [-] Deprecated: Option "sql_connection" from group "DEFAULT" is deprecated. Use option "connection" from group "database".
sysinv 2023-12-06 20:56:45.442 10711 WARNING oslo_db.sqlalchemy.engines [-] URL postgresql://admin-sysinv:***@127.0.0.1/sysinv does not contain a '+drivername' portion, and will make use of a default driver. A full dbname+drivername:// protocol is recommended.
sysinv 2023-12-06 20:56:45.610 10711 WARNING oslo_db.sqlalchemy.exc_filters [-] DBAPIError exception wrapped.: psycopg2.errors.UndefinedColumn: column i_host.apparmor_config_status does not exist
LINE 1: ...onfig_target, i_host.apparmor AS i_host_apparmor, i_host.app...
                                                             ^
2023-12-06 20:56:45.610 10711 ERROR oslo_db.sqlalchemy.exc_filters Traceback (most recent call last):
2023-12-06 20:56:45.610 10711 ERROR oslo_db.sqlalchemy.exc_filters File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1276, in _execute_context
2023-12-06 20:56:45.610 10711 ERROR oslo_db.sqlalchemy.exc_filters self.dialect.do_execute(
2023-12-06 20:56:45.610 10711 ERROR oslo_db.sqlalchemy.exc_filters File "/usr/lib/python3/dist-packages/sqlalchemy/engine/default.py", line 609, in do_execute
2023-12-06 20:56:45.610 10711 ERROR oslo_db.sqlalchemy.exc_filters cursor.execute(statement, parameters)
2023-12-06 20:56:45.610 10711 ERROR oslo_db.sqlalchemy.exc_filters psycopg2.errors.UndefinedColumn: column i_host.apparmor_config_status does not exist
2023-12-06 20:56:45.610 10711 ERROR oslo_db.sqlalchemy.exc_filters LINE 1: ...onfig_target, i_host.apparmor AS i_host_apparmor, i_host.app...
2023-12-06 20:56:45.610 10711 ERROR oslo_db.sqlalchemy.exc_filters ^
2023-12-06 20:56:45.610 10711 ERROR oslo_db.sqlalchemy.exc_filters
2023-12-06 20:56:45.610 10711 ERROR oslo_db.sqlalchemy.exc_filters
sysinv 2023-12-06 20:56:45.612 10711 CRITICAL sysinv [-] Unhandled error: oslo_db.exception.DBError: (psycopg2.errors.UndefinedColumn) column i_host.apparmor_config_status does not exist
LINE 1: ...onfig_target, i_host.apparmor AS i_host_apparmor, i_host.app...
sysadmin@controller-0:~$ sudo sudo -u postgres psql sysinv -c '\d i_host' | grep apparmor
 apparmor | character varying(64) | | |

sysadmin@controller-0:~$ sudo sysinv-dbsync
sysinv 2023-12-06 21:19:13.035 12269 WARNING oslo_config.cfg [-] Deprecated: Option "sql_connection" from group "DEFAULT" is deprecated. Use option "connection" from group "database".
sysinv 2023-12-06 21:19:13.036 12269 WARNING oslo_db.sqlalchemy.engines [-] URL postgresql://admin-sysinv:***@127.0.0.1/sysinv does not contain a '+drivername' portion, and will make use of a default driver. A full dbname+drivername:// protocol is recommended.

sysadmin@controller-0:~$ sudo sudo -u postgres psql sysinv -c '\d i_host' | grep apparmor
 apparmor | character varying(64) | | |
Alarms

N/A

Test Activity
-----------------
Developer Testing

Workaround
-----------------
Move new column into new version file so it can be migrated.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to config (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/starlingx/config/+/903170

Changed in starlingx:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to config (master)

Reviewed: https://review.opendev.org/c/starlingx/config/+/903170
Committed: https://opendev.org/starlingx/config/commit/24ab6eb106d2c013b8dd6861da16d6da0fd6f22d
Submitter: "Zuul (22348)"
Branch: master

commit 24ab6eb106d2c013b8dd6861da16d6da0fd6f22d
Author: Jagatguru Prasad Mishra <email address hidden>
Date: Fri Dec 8 06:27:25 2023 -0500

    Moving apparmor_config_status to latest migration script

    A new column apparmor_config_status was added to the i_host table
    to track the runtime apparmor config application status. The
    column creation was done in existing script 126 which is causing
    the issue in upgrade migration. Moved this column creation to the
    new migration script.

    Closes-Bug: 2045965

    Test plan:
    PASS: AIO-SX: Install AIO-SX and verify if apparmor_config_status
          column is created in i_host table

    Change-Id: I34d617ef084dacbad0b7153bd186a00e9482b38b
    Signed-off-by: Jagatguru Prasad Mishra <email address hidden>

Changed in starlingx:
status: In Progress → Fix Released
Ghada Khalil (gkhalil)
Changed in starlingx:
importance: Undecided → Medium
assignee: nobody → Jagatguru Prasad Mishra (jmishra)
summary: - Incorrect migration version for AppArmor Config Status column in i_host
+ AppArmor Config Status column has incorrect migration version
tags: added: stx.9.0 stx.update
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.