scheduler _create_snapshot filter_function fails when filtering on user_id or project_id

Bug #1928400 reported by Adrian Smith
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Cinder
In Progress
Medium
Unassigned

Bug Description

We have an issue with the cinder scheduler in ussuri when specifying a filter_function in a backend such as:

filter_function=volume.project_id != "<uuid>"

Change https://github.com/openstack/cinder/commit/87a7e80a2cbc4c8abcf4394242a02fcc5140e44b enabled string evaluations in the filter function, so using project_id should work. It works correctly for volume creation but creating volume snapshots for any volumes in that backend results in a scheduling error. The backend is excluded and so the snapshot fails.

It looks like it’s because the _create_snapshot function (https://github.com/openstack/cinder/blob/master/cinder/volume/api.py#L847-L866 is only passing the size attribute from the original volume request spec and we need other properties (user_id/project_id) to be evaluated by the filter.

example failing log in test:

May 10 15:47:37 schedule-host cinder-scheduler[363623]: 2021-05-10 15:47:37.753 363623 DEBUG cinder.scheduler.filters.driver_filter [req-d5d66e86-6fae-434d-b982-4d282dfeba59 e9e24472e3634e45b5dbb5318b2bae2d ee7cc086d
3464e59bd07c9db4b866bef - default default] Running evaluator: extra_specs: {}
                                                     stats: {'host': '<backend>', 'cluster_name': None, 'backend_id': '<backend>', 'volume_backend_name': 'RBD',
'vendor_name': 'Open Source', 'driver_version': '1.2.0', 'storage_protocol': 'ceph', 'QoS_support': False, 'total_capacity_gb': 259510.89, 'allocated_capacity_gb': 764, 'free_capacity_gb': 259233.56, 'reserved_per
centage': 0, 'updated': datetime.datetime(2021, 5, 10, 5, 47, 10, 470929)}
                                                     capabilities: ReadOnlyDict({'vendor_name': 'Open Source', 'driver_version': '1.2.0', 'storage_protocol': 'ceph', 'total_capacity_gb': 259510.89, 'free_capacity_
gb': 259233.56, 'reserved_percentage': 0, 'multiattach': True, 'thin_provisioning_support': True, 'max_over_subscription_ratio': '20.0', 'location_info': 'ceph:/etc/ceph/ceph.conf:<location>',
 'backend_state': 'up', 'volume_backend_name': 'RBD', 'replication_enabled': False, 'provisioned_capacity_gb': 2836, 'allocated_capacity_gb': 764, 'filter_function': 'volume.project_id
 != "1c9c2224355ab6654ed7985c6242470c"', 'goodness_function': '100', 'timestamp': datetime.datetime(2021, 5, 10, 5, 47, 10, 470929)})
                                                     volume: {'size': 1}
                                                     qos: None _run_evaluator /usr/lib/python3/dist-packages/cinder/scheduler/filters/driver_filter.py:78
May 10 15:47:37 schedule-host cinder-scheduler[363623]: 2021-05-10 15:47:37.758 363623 WARNING cinder.scheduler.filters.driver_filter [req-d5d66e86-6fae-434d-b982-4d282dfeba59 e9e24472e3634e45b5dbb5318b2bae2d ee7cc08
6d3464e59bd07c9db4b866bef - default default] Error in filtering function 'volume.project_id != "1c9c2224355ab6654ed7985c6242470c"' : 'KeyError evaluating string' :: failing backend: cinder.exception.EvaluatorParse
Exception: KeyError evaluating string

This seems to work if I add "user_id=volume.user_id, project_id=volume.project_id" to kwargs in "'volume_properties': objects.VolumeProperties(size=volume.size)" in volume/api.py at line 862
and logs show:

volume: {'project_id': '39b67ce4412345678ca46ab4674db379', 'size': 1, 'user_id': '32dbd0cbbab3477458465460a73ed2f1'}

I'm not sure if this is missing some other factors though ?

tags: added: scheduler ussuri
Changed in cinder:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/cinder/+/793885

Changed in cinder:
status: New → In Progress
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.