08.存储Cinder→5.场景学习→02.Create Volume→2.cinder-scheduler调度工作

贺高飞
2023-12-01
描述详细
  1. 查看cinder-scheduler日志
    1. cinder-scheduler 执行调度算法,通过 Filter 和 Weigher 挑选最优的存储节点。cinder-scheduler 通过 Flow volume_create_scheduler 执行调度工作。
1
2
3
4
5
Jun 11 16:51:14 controller cinder-scheduler[29282]: 
DEBUG cinder.scheduler.manager [None req-4111af2f-99a8-4166-8647-569b038786d9 admin None] 
 (22955515-20d0-4af4-8890-df981d8bbe8d) 
transitioned into state  from state 'PENDING' 
{{(pid=29282) _flow_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:145

  1. 该 Flow 依次执行 ExtractSchedulerSpecTask 和 ScheduleCreateVolumeTask,它们在源码中就是两个类,在源码/opt/stack/cinder/cinder/scheduler/flows/create_volume.py上。ExtractSchedulerSpecTask作用是Extracts a spec object from a partial and/or incomplete request spec 从部分和/或不完整的请求spec中提取spec对象(spec:说明、规范)
1
2
3
4
5
Jun 11 16:51:14 controller cinder-scheduler[29282]: 
DEBUG cinder.scheduler.manager [None req-4111af2f-99a8-4166-8647-569b038786d9 admin None] 
Task 'cinder.scheduler.flows.create_volume.;volume:create' 
(2639d26d-a289-4fa6-8e47-096b35b77015) transitioned into state  from state 'PENDING' 
{{(pid=29282) _task_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:194

1
2
3
4
5
Jun 11 16:51:14 controller cinder-scheduler[29282]: 
DEBUG cinder.scheduler.manager [None req-4111af2f-99a8-4166-8647-569b038786d9 admin None] 
Task 'cinder.scheduler.flows.create_volume.;volume:create' 
(2639d26d-a289-4fa6-8e47-096b35b77015) transitioned into state  from state 'RUNNING' ...
 {{(pid=29282) _task_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:183
  1. 主要的 filter 和 weighting 工作由 ScheduleCreateVolumeTask Activates a scheduler driver and handles any subsequent failures 完成
    1. 经过 AvailabilityZoneFilter, CapacityFilter, CapabilitiesFilter 和 CapacityWeigher 的层层筛选,最终选择了存储节点 devstack-controller@lvmdriver-1#lvmdriver-1。
    2. 过滤器源码位置:\opt\stack\cinder\cinder\scheduler\filters
1
2
3
4
5
Jun 11 16:51:14 controller cinder-scheduler[29282]: 
DEBUG cinder.scheduler.manager [None req-4111af2f-99a8-4166-8647-569b038786d9 admin None] 
Task 'cinder.scheduler.flows.create_volume.;volume:create' 
(f7f99d55-3903-4f0d-bf47-b269e1204775) transitioned into state  from state 'PENDING' 
{{(pid=29282) _task_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:194
1
2
3
Jun 11 16:51:15 controller cinder-scheduler[29282]: 
DEBUG cinder.scheduler.base_filter [None req-4111af2f-99a8-4166-8647-569b038786d9 admin None] 
 {{(pid=29282) get_filtered_objects /opt/stack/cinder/cinder/scheduler/base_filter.py:95
因为只有一个存储节点
1
2
3
4
Jun 11 16:51:15 controller cinder-scheduler[29282]: 
DEBUG cinder.scheduler.base_filter [None req-4111af2f-99a8-4166-8647-569b038786d9 admin None] 
 
{{(pid=29282) get_filtered_objects /opt/stack/cinder/cinder/scheduler/base_filter.py:125
1
2
3
4
Jun 11 16:51:15 controller cinder-scheduler[29282]: 
DEBUG cinder.scheduler.base_filter [None req-4111af2f-99a8-4166-8647-569b038786d9 admin None] 

{{(pid=29282) get_filtered_objects /opt/stack/cinder/cinder/scheduler/base_filter.py:125
1
2
3
4
Jun 11 16:51:15 controller cinder-scheduler[29282]: 
DEBUG cinder.scheduler.base_filter [None req-4111af2f-99a8-4166-8647-569b038786d9 admin None] 

{{(pid=29282) get_filtered_objects /opt/stack/cinder/cinder/scheduler/base_filter.py:125
1
2
3
4
Jun 11 16:51:15 controller cinder-scheduler[29282]: 
DEBUG cinder.scheduler.filter_scheduler [None req-4111af2f-99a8-4166-8647-569b038786d9 admin None] 
:free_capacity_gb: 22.8, total_capacity_gb:  
{{(pid=29282)  /opt/stack/cinder/cinder/scheduler/filter_scheduler.py:339
1
2
3
4
Jun 11 16:51:15 controller cinder-scheduler[29282]: 
DEBUG cinder.scheduler.filter_scheduler [None req-4111af2f-99a8-4166-8647-569b038786d9 admin None] 

{{(pid=29282) _choose_top_backend /opt/stack/cinder/cinder/scheduler/filter_scheduler.py:560
1
2
3
4
5
Jun 11 16:51:15 controller cinder-scheduler[29282]: 
DEBUG cinder.scheduler.manager [None req-a6c9fadb-0364-43da-bbf0-d333c549aa74 admin None] 
Task 'cinder.scheduler.flows.create_volume.;volume:create' 
(37386aa6-d742-46cb-9ff2-c842dbc7e159) transitioned into state  from state 'RUNNING' with result 'None' 
{{(pid=29282) _task_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:183
  1. Flow volume_create_scheduler 完成调度,状态变为 SUCCESS。
1
2
3
4
Jun 11 16:51:15 controller cinder-scheduler[29282]: 
DEBUG cinder.scheduler.manager [None req-a6c9fadb-0364-43da-bbf0-d333c549aa74 admin None] 
 ... transitioned into state  from state 'RUNNING' 
{{(pid=29282) _flow_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:145
  1. cinder-scheduler 发送消息
    1. cinder-scheduler 发送消息给 cinder-volume,让其创建 volume。源码 /opt/stack/cinder/cinder/scheduler/filter_scheduler.py,方法为 schedule_create_volume。
1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class FilterScheduler(driver.Scheduler):
    """Scheduler that can be used for filtering and weighing."""
    #...
    def schedule_create_volume(self, context, request_spec, filter_properties):
        backend = self._schedule(context, request_spec, filter_properties)

        if not backend:
            raise exception.NoValidBackend(reason=_("No weighed backends "
                                                    "available"))

        backend = backend.obj
        volume_id = request_spec['volume_id']

        updated_volume = driver.volume_update_db(context, volume_id,
                                                 backend.host,
                                                 backend.cluster_name)
        self._post_select_populate_filter_properties(filter_properties,
                                                     backend)

        # context is not serializable
        filter_properties.pop('context', None)

        self.(context, updated_volume, request_spec,
                                         filter_properties,
                                         allow_reschedule=True)
        #...
1
2
3
4
5
Jun 11 16:51:14 controller cinder-scheduler[29282]: 
DEBUG cinder.scheduler.manager [None req-4111af2f-99a8-4166-8647-569b038786d9 admin None] 
 (22955515-20d0-4af4-8890-df981d8bbe8d) 
transitioned into state  from state 'PENDING' 
{{(pid=29282) _flow_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:145
 类似资料: