Use 'last_error' and 'maintenance_reason' as the sort key in node list will error with db2
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Ironic |
Won't Fix
|
Low
|
Unassigned |
Bug Description
Use DB2 as the database service in openstack, find some errors when using specific sort key in ironic list command.
For example, use 'last_error' as the sort key in the node list command:
[root@kan-
(ProgrammingError) ibm_db_
The data type in mysql:
mysql> desc nodes;
+------
| Field | Type | Null | Key | Default | Extra |
+------
| created_at | datetime | YES | | NULL | |
| updated_at | datetime | YES | | NULL | |
| id | int(11) | NO | PRI | NULL | auto_increment |
| uuid | varchar(36) | YES | UNI | NULL | |
| instance_uuid | varchar(36) | YES | UNI | NULL | |
| chassis_id | int(11) | YES | MUL | NULL | |
| power_state | varchar(15) | YES | | NULL | |
| target_power_state | varchar(15) | YES | | NULL | |
| provision_state | varchar(15) | YES | | NULL | |
| target_
| last_error | text | YES | | NULL | |
| properties | text | YES | | NULL | |
| driver | varchar(15) | YES | | NULL | |
| driver_info | text | YES | | NULL | |
| reservation | varchar(255) | YES | | NULL | |
| maintenance | tinyint(1) | YES | | NULL | |
| extra | text | YES | | NULL | |
| provision_
| console_enabled | tinyint(1) | YES | | NULL | |
| instance_info | text | YES | | NULL | |
| conductor_affinity | int(11) | YES | MUL | NULL | |
| maintenance_reason | text | YES | | NULL | |
| driver_
| name | varchar(255) | YES | UNI | NULL | |
| inspection_
| inspection_
| clean_step | text | YES | | NULL | |
+------
27 rows in set (0.00 sec)
The data type in db2:
db2 => describe table nodes
Column name schema Data type name Length Scale Nulls
-------
CREATED_AT SYSIBM TIMESTAMP 10 6 Yes
UPDATED_AT SYSIBM TIMESTAMP 10 6 Yes
ID SYSIBM INTEGER 4 0 No
UUID SYSIBM VARCHAR 36 0 Yes
INSTANCE_UUID SYSIBM VARCHAR 36 0 Yes
CHASSIS_ID SYSIBM INTEGER 4 0 Yes
POWER_STATE SYSIBM VARCHAR 15 0 Yes
TARGET_POWER_STATE SYSIBM VARCHAR 15 0 Yes
PROVISION_STATE SYSIBM VARCHAR 15 0 Yes
TARGET_
LAST_ERROR SYSIBM CLOB 1048576 0 Yes
PROPERTIES SYSIBM CLOB 1048576 0 Yes
DRIVER SYSIBM VARCHAR 15 0 Yes
DRIVER_INFO SYSIBM CLOB 1048576 0 Yes
RESERVATION SYSIBM VARCHAR 255 0 Yes
MAINTENANCE SYSIBM SMALLINT 2 0 Yes
EXTRA SYSIBM CLOB 1048576 0 Yes
PROVISION_
CONSOLE_ENABLED SYSIBM SMALLINT 2 0 Yes
INSTANCE_INFO SYSIBM CLOB 1048576 0 Yes
CONDUCTOR_AFFINITY SYSIBM INTEGER 4 0 Yes
MAINTENANCE_REASON SYSIBM CLOB 1048576 0 Yes
DRIVER_
NAME SYSIBM VARCHAR 63 0 Yes
INSPECTION_
INSPECTION_
CLEAN_STEP SYSIBM CLOB 1048576 0 Yes
27 record(s) selected.
The 'text' format is transferred to 'clob' in DB2, and it can not be used in 'order by' sql command.
There are some solutions that might solve this:
1. Change the 'text' format to 'varchar' format using the max length.
2. Change "ORDER BY nodes.last_error ASC" to "ORDER BY cast(nodes.
Changed in ironic: | |
assignee: | nobody → Kan (kansks) |
status: | Triaged → In Progress |
Changed in ironic: | |
status: | In Progress → Triaged |
assignee: | Kan (kansks) → nobody |
Does Ironic supports DB2 database?