metadata def namespace update CLI is not working as expected for parameter "protected"

Bug #1607317 reported by Mh Raies
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance Client
Fix Released
Wishlist
Unassigned

Bug Description

In v2 glance metadata def namespace update API, it is observed that when we are updating protected parameter with different invalid values, it updates this parameter inappropriately.

Following CLI update output shows this behavior -

##################### Create a v2 metadata def namespace using admin credentials -

stack@ubuntu-VirtualBox:/opt/stack/tempest$ glance --os-image-api-version 2 md-namespace-create test-ns
+------------+----------------------------------+
| Property | Value |
+------------+----------------------------------+
| created_at | 2016-07-28T10:51:25Z |
| namespace | test-ns |
| owner | 93efcc2b00164c61aafaa6f234b99bc3 |
| protected | False |
| schema | /v2/schemas/metadefs/namespace |
| updated_at | 2016-07-28T10:51:25Z |
| visibility | private |
+------------+----------------------------------+
stack@ubuntu-VirtualBox:/opt/stack/tempest$

#################### Now look at below different invalid protected parameters and behavior -

stack@ubuntu-VirtualBox:/opt/stack/tempest$ glance --debug --os-image-api-version 2 md-namespace-update test-ns --protected True
+------------+----------------------------------+
| Property | Value |
+------------+----------------------------------+
| created_at | 2016-07-28T10:51:25Z |
| namespace | test-ns |
| owner | 93efcc2b00164c61aafaa6f234b99bc3 |
| protected | True |
| schema | /v2/schemas/metadefs/namespace |
| updated_at | 2016-07-28T10:51:32Z |
| visibility | private |
+------------+----------------------------------+
stack@ubuntu-VirtualBox:/opt/stack/tempest$

+------------+----------------------------------+
| Property | Value |
+------------+----------------------------------+
| created_at | 2016-07-28T10:51:25Z |
| namespace | test-ns |
| owner | 93efcc2b00164c61aafaa6f234b99bc3 |
| protected | True |
| schema | /v2/schemas/metadefs/namespace |
| updated_at | 2016-07-28T10:51:32Z |
| visibility | private |
+------------+----------------------------------+
stack@ubuntu-VirtualBox:/opt/stack/tempest$ glance --os-image-api-version 2 md-namespace-update test-ns --protected True
+------------+----------------------------------+
| Property | Value |
+------------+----------------------------------+
| created_at | 2016-07-28T10:51:25Z |
| namespace | test-ns |
| owner | 93efcc2b00164c61aafaa6f234b99bc3 |
| protected | True |
| schema | /v2/schemas/metadefs/namespace |
| updated_at | 2016-07-28T10:51:32Z |
| visibility | private |
+------------+----------------------------------+
stack@ubuntu-VirtualBox:/opt/stack/tempest$ glance --os-image-api-version 2 md-namespace-update test-ns --protected False
+------------+----------------------------------+
| Property | Value |
+------------+----------------------------------+
| created_at | 2016-07-28T10:51:25Z |
| namespace | test-ns |
| owner | 93efcc2b00164c61aafaa6f234b99bc3 |
| protected | False |
| schema | /v2/schemas/metadefs/namespace |
| updated_at | 2016-07-28T10:53:04Z |
| visibility | private |
+------------+----------------------------------+
stack@ubuntu-VirtualBox:/opt/stack/tempest$ glance --os-image-api-version 2 md-namespace-update test-ns --protected "True"
+------------+----------------------------------+
| Property | Value |
+------------+----------------------------------+
| created_at | 2016-07-28T10:51:25Z |
| namespace | test-ns |
| owner | 93efcc2b00164c61aafaa6f234b99bc3 |
| protected | True |
| schema | /v2/schemas/metadefs/namespace |
| updated_at | 2016-07-28T10:53:12Z |
| visibility | private |
+------------+----------------------------------+
stack@ubuntu-VirtualBox:/opt/stack/tempest$ glance --os-image-api-version 2 md-namespace-update test-ns --protected "True_1"
+------------+----------------------------------+
| Property | Value |
+------------+----------------------------------+
| created_at | 2016-07-28T10:51:25Z |
| namespace | test-ns |
| owner | 93efcc2b00164c61aafaa6f234b99bc3 |
| protected | False |
| schema | /v2/schemas/metadefs/namespace |
| updated_at | 2016-07-28T10:53:23Z |
| visibility | private |
+------------+----------------------------------+
stack@ubuntu-VirtualBox:/opt/stack/tempest$

stack@ubuntu-VirtualBox:/opt/stack/tempest$ glance --os-image-api-version 2 md-namespace-update test-ns --protected "T"
+------------+----------------------------------+
| Property | Value |
+------------+----------------------------------+
| created_at | 2016-07-28T10:51:25Z |
| namespace | test-ns |
| owner | 93efcc2b00164c61aafaa6f234b99bc3 |
| protected | True |
| schema | /v2/schemas/metadefs/namespace |
| updated_at | 2016-07-28T10:53:58Z |
| visibility | private |
+------------+----------------------------------+
stack@ubuntu-VirtualBox:/opt/stack/tempest$

stack@ubuntu-VirtualBox:/opt/stack/tempest$ glance --os-image-api-version 2 md-namespace-update test-ns --protected 0
+------------+----------------------------------+
| Property | Value |
+------------+----------------------------------+
| created_at | 2016-07-28T10:51:25Z |
| namespace | test-ns |
| owner | 93efcc2b00164c61aafaa6f234b99bc3 |
| protected | False |
| schema | /v2/schemas/metadefs/namespace |
| updated_at | 2016-07-28T10:54:24Z |
| visibility | private |
+------------+----------------------------------+
stack@ubuntu-VirtualBox:/opt/stack/tempest$ glance --os-image-api-version 2 md-namespace-update test-ns --protected 2
+------------+----------------------------------+
| Property | Value |
+------------+----------------------------------+
| created_at | 2016-07-28T10:51:25Z |
| namespace | test-ns |
| owner | 93efcc2b00164c61aafaa6f234b99bc3 |
| protected | False |
| schema | /v2/schemas/metadefs/namespace |
| updated_at | 2016-07-28T10:54:24Z |
| visibility | private |
+------------+----------------------------------+
stack@ubuntu-VirtualBox:/opt/stack/tempest$ glance --os-image-api-version 2 md-namespace-update test-ns --protected 1
+------------+----------------------------------+
| Property | Value |
+------------+----------------------------------+
| created_at | 2016-07-28T10:51:25Z |
| namespace | test-ns |
| owner | 93efcc2b00164c61aafaa6f234b99bc3 |
| protected | True |
| schema | /v2/schemas/metadefs/namespace |
| updated_at | 2016-07-28T10:54:36Z |
| visibility | private |
+------------+----------------------------------+
stack@ubuntu-VirtualBox:/opt/stack/tempest$ glance --os-image-api-version 2 md-namespace-update test-ns --protected 11
+------------+----------------------------------+
| Property | Value |
+------------+----------------------------------+
| created_at | 2016-07-28T10:51:25Z |
| namespace | test-ns |
| owner | 93efcc2b00164c61aafaa6f234b99bc3 |
| protected | False |
| schema | /v2/schemas/metadefs/namespace |
| updated_at | 2016-07-28T10:54:39Z |
| visibility | private |
+------------+----------------------------------+
stack@ubuntu-VirtualBox:/opt/stack/tempest$

stack@ubuntu-VirtualBox:/opt/stack/tempest$ glance --os-image-api-version 2 md-namespace-update test-ns --protected T
+------------+----------------------------------+
| Property | Value |
+------------+----------------------------------+
| created_at | 2016-07-28T10:51:25Z |
| namespace | test-ns |
| owner | 93efcc2b00164c61aafaa6f234b99bc3 |
| protected | True |
| schema | /v2/schemas/metadefs/namespace |
| updated_at | 2016-07-28T10:55:22Z |
| visibility | private |
+------------+----------------------------------+
stack@ubuntu-VirtualBox:/opt/stack/tempest$ glance --os-image-api-version 2 md-namespace-update test-ns --protected F
+------------+----------------------------------+
| Property | Value |
+------------+----------------------------------+
| created_at | 2016-07-28T10:51:25Z |
| namespace | test-ns |
| owner | 93efcc2b00164c61aafaa6f234b99bc3 |
| protected | False |
| schema | /v2/schemas/metadefs/namespace |
| updated_at | 2016-07-28T10:55:25Z |
| visibility | private |
+------------+----------------------------------+
stack@ubuntu-VirtualBox:/opt/stack/tempest$

stack@ubuntu-VirtualBox:/opt/stack/tempest$ glance --os-image-api-version 2 md-namespace-update test-ns --protected "T"
+------------+----------------------------------+
| Property | Value |
+------------+----------------------------------+
| created_at | 2016-07-28T10:51:25Z |
| namespace | test-ns |
| owner | 93efcc2b00164c61aafaa6f234b99bc3 |
| protected | True |
| schema | /v2/schemas/metadefs/namespace |
| updated_at | 2016-07-28T10:56:21Z |
| visibility | private |
+------------+----------------------------------+
stack@ubuntu-VirtualBox:/opt/stack/tempest$ glance --os-image-api-version 2 md-namespace-update test-ns --protected "?"
+------------+----------------------------------+
| Property | Value |
+------------+----------------------------------+
| created_at | 2016-07-28T10:51:25Z |
| namespace | test-ns |
| owner | 93efcc2b00164c61aafaa6f234b99bc3 |
| protected | False |
| schema | /v2/schemas/metadefs/namespace |
| updated_at | 2016-07-28T10:56:24Z |
| visibility | private |
+------------+----------------------------------+
stack@ubuntu-VirtualBox:/opt/stack/tempest$

From above, we can see that for --protected in ["?". "#", "T", "F", "True_1", 0, 1, 11 etc..] namespace is updated inappropriately.
for example - if we put "?" --> it is changed to "False" (which was "True" before update )automatically without any error.

and many i

Revision history for this message
wangxiyuan (wangxiyuan) wrote :

not only this command but also others has this problem, you can take a try with "glance image-update --protectd".
The reason is that glance client analyze this kind of parameter to "False" when it's not boolean.

affects: glance → python-glanceclient
Ian Cordasco (icordasc)
Changed in python-glanceclient:
status: New → Triaged
importance: Undecided → Wishlist
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-glanceclient (master)
Changed in python-glanceclient:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-glanceclient (master)

Reviewed: https://review.opendev.org/c/openstack/python-glanceclient/+/858785
Committed: https://opendev.org/openstack/python-glanceclient/commit/88e3b0ad984797ec1f856429698949e4781dff3a
Submitter: "Zuul (22348)"
Branch: master

commit 88e3b0ad984797ec1f856429698949e4781dff3a
Author: Cyril Roelandt <email address hidden>
Date: Wed Sep 21 19:38:24 2022 +0200

    Boolean options: use strict checking

    Boolean options (such as "--protected" for glance md-namespace-update)
    should accept a limited amount of valid values, rather than assuming an
    "invalid" value means "False".

    The following values (no matter the case) will now be interpreted as
    True: ‘t’,’true’, ‘on’, ‘y’, ‘yes’, or ‘1’.

    The following values (no matter the case) will now be interpreted as
    False: ‘f’, ‘false’, ‘off’, ‘n’, ‘no’, or ‘0’.

    Change-Id: I0e7942045d883ac398bab4a7a85f2b4ac9b1ed8c
    Closes-Bug: #1607317

Changed in python-glanceclient:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-glanceclient 4.3.0

This issue was fixed in the openstack/python-glanceclient 4.3.0 release.

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.