Coverage for nova/conf/scheduler.py: 94%

17 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-04-17 15:08 +0000

1# Copyright 2015 OpenStack Foundation 

2# All Rights Reserved. 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); you may 

5# not use this file except in compliance with the License. You may obtain 

6# a copy of the License at 

7# 

8# http://www.apache.org/licenses/LICENSE-2.0 

9# 

10# Unless required by applicable law or agreed to in writing, software 

11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 

12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

13# License for the specific language governing permissions and limitations 

14# under the License. 

15 

16from oslo_config import cfg 

17 

18from nova.virt import arch 

19 

20 

21scheduler_group = cfg.OptGroup( 

22 name="scheduler", title="Scheduler configuration") 

23 

24scheduler_opts = [ 

25 cfg.IntOpt("max_attempts", 

26 default=3, 

27 min=1, 

28 help=""" 

29The maximum number of schedule attempts. 

30 

31This is the maximum number of attempts that will be made for a given instance 

32build/move operation. It limits the number of alternate hosts returned by the 

33scheduler. When that list of hosts is exhausted, a ``MaxRetriesExceeded`` 

34exception is raised and the instance is set to an error state. 

35 

36Possible values: 

37 

38* A positive integer, where the integer corresponds to the max number of 

39 attempts that can be made when building or moving an instance. 

40"""), 

41 cfg.IntOpt("discover_hosts_in_cells_interval", 

42 default=-1, 

43 min=-1, 

44 help=""" 

45Periodic task interval. 

46 

47This value controls how often (in seconds) the scheduler should attempt 

48to discover new hosts that have been added to cells. If negative (the 

49default), no automatic discovery will occur. 

50 

51Deployments where compute nodes come and go frequently may want this 

52enabled, where others may prefer to manually discover hosts when one 

53is added to avoid any overhead from constantly checking. If enabled, 

54every time this runs, we will select any unmapped hosts out of each 

55cell database on every run. 

56 

57Possible values: 

58 

59* An integer, where the integer corresponds to periodic task interval in 

60 seconds. 0 uses the default interval (60 seconds). A negative value disables 

61 periodic tasks. 

62"""), 

63 cfg.IntOpt("max_placement_results", 

64 default=1000, 

65 min=1, 

66 help=""" 

67The maximum number of placement results to request. 

68 

69This setting determines the maximum limit on results received from the 

70placement service during a scheduling operation. It effectively limits 

71the number of hosts that may be considered for scheduling requests that 

72match a large number of candidates. 

73 

74A value of 1 (the minimum) will effectively defer scheduling to the placement 

75service strictly on "will it fit" grounds. A higher value will put an upper 

76cap on the number of results the scheduler will consider during the filtering 

77and weighing process. Large deployments may need to set this lower than the 

78total number of hosts available to limit memory consumption, network traffic, 

79etc. of the scheduler. 

80 

81Possible values: 

82 

83* An integer, where the integer corresponds to the number of placement results 

84 to return. 

85"""), 

86 cfg.IntOpt("workers", 

87 min=0, 

88 help=""" 

89Number of workers for the nova-scheduler service. 

90 

91Defaults to the number of CPUs available. 

92 

93Possible values: 

94 

95* An integer, where the integer corresponds to the number of worker processes. 

96"""), 

97 cfg.BoolOpt("query_placement_for_routed_network_aggregates", 

98 default=False, 

99 help=""" 

100Enable the scheduler to filter compute hosts affined to routed network segment 

101aggregates. 

102 

103See https://docs.openstack.org/neutron/latest/admin/config-routed-networks.html 

104for details. 

105"""), 

106 cfg.BoolOpt("limit_tenants_to_placement_aggregate", 

107 default=False, 

108 help=""" 

109Restrict tenants to specific placement aggregates. 

110 

111This setting causes the scheduler to look up a host aggregate with the 

112metadata key of ``filter_tenant_id`` set to the project of an incoming 

113request, and request results from placement be limited to that aggregate. 

114Multiple tenants may be added to a single aggregate by appending a serial 

115number to the key, such as ``filter_tenant_id:123``. 

116 

117The matching aggregate UUID must be mirrored in placement for proper operation. 

118If the aggregate does not match one in placement, the result will be the same 

119as not finding any suitable hosts for the request. 

120 

121If no host aggregate with the tenant id is found and ``[scheduler] 

122placement_aggregate_required_for_tenants = False``, the request will not be 

123restricted to only aggregates matching the tenant. If no host aggregate with 

124the tenant id is found and ``[scheduler] 

125placement_aggregate_required_for_tenants = True``, the result will be the same 

126as not finding any suitable hosts for the request. 

127 

128Possible values: 

129 

130- A boolean value. 

131 

132Related options: 

133 

134- ``[scheduler] placement_aggregate_required_for_tenants`` 

135"""), 

136 cfg.BoolOpt("placement_aggregate_required_for_tenants", 

137 default=False, 

138 help=""" 

139Require a placement aggregate association for all tenants. 

140 

141This setting, when limit_tenants_to_placement_aggregate=True, will control 

142whether or not a tenant with no aggregate affinity will be allowed to schedule 

143to any available node. If aggregates are used to limit some tenants but 

144not all, then this should be False. If all tenants should be confined via 

145aggregate, then this should be True to prevent them from receiving unrestricted 

146scheduling to any available node. 

147 

148Possible values: 

149 

150- A boolean value. 

151 

152Related options: 

153 

154- ``[scheduler] placement_aggregate_required_for_tenants`` 

155"""), 

156 cfg.BoolOpt("query_placement_for_image_type_support", 

157 default=False, 

158 help=""" 

159Use placement to determine host support for the instance's image type. 

160 

161This setting causes the scheduler to ask placement only for compute 

162hosts that support the ``disk_format`` of the image used in the request. 

163 

164Possible values: 

165 

166- A boolean value. 

167"""), 

168 cfg.BoolOpt("enable_isolated_aggregate_filtering", 

169 default=False, 

170 help=""" 

171Restrict use of aggregates to instances with matching metadata. 

172 

173This setting allows the scheduler to restrict hosts in aggregates based on 

174matching required traits in the aggregate metadata and the instance 

175flavor/image. If an aggregate is configured with a property with key 

176``trait:$TRAIT_NAME`` and value ``required``, the instance flavor extra_specs 

177and/or image metadata must also contain ``trait:$TRAIT_NAME=required`` to be 

178eligible to be scheduled to hosts in that aggregate. More technical details 

179at https://docs.openstack.org/nova/latest/reference/isolate-aggregates.html 

180 

181Possible values: 

182 

183- A boolean value. 

184"""), 

185 cfg.BoolOpt("image_metadata_prefilter", 

186 default=False, 

187 help=""" 

188Use placement to filter hosts based on image metadata. 

189 

190This setting causes the scheduler to transform well known image metadata 

191properties into placement required traits to filter host based on image 

192metadata. This feature requires host support and is currently supported by the 

193following compute drivers: 

194 

195- ``libvirt.LibvirtDriver`` (since Ussuri (21.0.0)) 

196 

197Possible values: 

198 

199- A boolean value. 

200 

201Related options: 

202 

203- ``[compute] compute_driver`` 

204"""), 

205] 

206 

207filter_scheduler_group = cfg.OptGroup( 

208 name="filter_scheduler", title="Filter scheduler options") 

209 

210filter_scheduler_opts = [ 

211 cfg.IntOpt("host_subset_size", 

212 default=1, 

213 min=1, 

214 help=""" 

215Size of subset of best hosts selected by scheduler. 

216 

217New instances will be scheduled on a host chosen randomly from a subset of the 

218N best hosts, where N is the value set by this option. 

219 

220Setting this to a value greater than 1 will reduce the chance that multiple 

221scheduler processes handling similar requests will select the same host, 

222creating a potential race condition. By selecting a host randomly from the N 

223hosts that best fit the request, the chance of a conflict is reduced. However, 

224the higher you set this value, the less optimal the chosen host may be for a 

225given request. 

226 

227Possible values: 

228 

229* An integer, where the integer corresponds to the size of a host subset. 

230"""), 

231 cfg.IntOpt("max_io_ops_per_host", 

232 default=8, 

233 min=0, 

234 help=""" 

235The number of instances that can be actively performing IO on a host. 

236 

237Instances performing IO includes those in the following states: build, resize, 

238snapshot, migrate, rescue, unshelve. 

239 

240Note that this setting only affects scheduling if the ``IoOpsFilter`` filter is 

241enabled. 

242 

243Possible values: 

244 

245* An integer, where the integer corresponds to the max number of instances 

246 that can be actively performing IO on any given host. 

247 

248Related options: 

249 

250- ``[filter_scheduler] enabled_filters`` 

251"""), 

252 cfg.IntOpt("max_instances_per_host", 

253 default=50, 

254 min=1, 

255 help=""" 

256Maximum number of instances that can exist on a host. 

257 

258If you need to limit the number of instances on any given host, set this option 

259to the maximum number of instances you want to allow. The NumInstancesFilter 

260and AggregateNumInstancesFilter will reject any host that has at least as many 

261instances as this option's value. 

262 

263Note that this setting only affects scheduling if the ``NumInstancesFilter`` or 

264``AggregateNumInstancesFilter`` filter is enabled. 

265 

266Possible values: 

267 

268* An integer, where the integer corresponds to the max instances that can be 

269 scheduled on a host. 

270 

271Related options: 

272 

273- ``[filter_scheduler] enabled_filters`` 

274"""), 

275 cfg.BoolOpt("track_instance_changes", 

276 default=True, 

277 help=""" 

278Enable querying of individual hosts for instance information. 

279 

280The scheduler may need information about the instances on a host in order to 

281evaluate its filters and weighers. The most common need for this information is 

282for the (anti-)affinity filters, which need to choose a host based on the 

283instances already running on a host. 

284 

285If the configured filters and weighers do not need this information, disabling 

286this option will improve performance. It may also be disabled when the tracking 

287overhead proves too heavy, although this will cause classes requiring host 

288usage data to query the database on each request instead. 

289 

290.. note:: 

291 

292 In a multi-cell (v2) setup where the cell MQ is separated from the 

293 top-level, computes cannot directly communicate with the scheduler. Thus, 

294 this option cannot be enabled in that scenario. See also the 

295 ``[workarounds] disable_group_policy_check_upcall`` option. 

296 

297Related options: 

298 

299- ``[filter_scheduler] enabled_filters`` 

300- ``[workarounds] disable_group_policy_check_upcall`` 

301"""), 

302 cfg.MultiStrOpt("available_filters", 

303 default=["nova.scheduler.filters.all_filters"], 

304 help=""" 

305Filters that the scheduler can use. 

306 

307An unordered list of the filter classes the nova scheduler may apply. Only the 

308filters specified in the ``[filter_scheduler] enabled_filters`` option will be 

309used, but any filter appearing in that option must also be included in this 

310list. 

311 

312By default, this is set to all filters that are included with nova. 

313 

314Possible values: 

315 

316* A list of zero or more strings, where each string corresponds to the name of 

317 a filter that may be used for selecting a host 

318 

319Related options: 

320 

321* ``[filter_scheduler] enabled_filters`` 

322"""), 

323 cfg.ListOpt("enabled_filters", 

324 # NOTE(artom) If we change the defaults here, we should also update 

325 # Tempest's scheduler_enabled_filters to keep the default values in 

326 # sync. 

327 default=[ 

328 "ComputeFilter", 

329 "ComputeCapabilitiesFilter", 

330 "ImagePropertiesFilter", 

331 "ServerGroupAntiAffinityFilter", 

332 "ServerGroupAffinityFilter", 

333 ], 

334 help=""" 

335Filters that the scheduler will use. 

336 

337An ordered list of filter class names that will be used for filtering 

338hosts. These filters will be applied in the order they are listed so 

339place your most restrictive filters first to make the filtering process more 

340efficient. 

341 

342All of the filters in this option *must* be present in the ``[scheduler_filter] 

343available_filter`` option, or a ``SchedulerHostFilterNotFound`` exception will 

344be raised. 

345 

346Possible values: 

347 

348* A list of zero or more strings, where each string corresponds to the name of 

349 a filter to be used for selecting a host 

350 

351Related options: 

352 

353- ``[filter_scheduler] available_filters`` 

354"""), 

355 cfg.ListOpt("weight_classes", 

356 default=["nova.scheduler.weights.all_weighers"], 

357 help=""" 

358Weighers that the scheduler will use. 

359 

360Only hosts which pass the filters are weighed. The weight for any host starts 

361at 0, and the weighers order these hosts by adding to or subtracting from the 

362weight assigned by the previous weigher. Weights may become negative. An 

363instance will be scheduled to one of the N most-weighted hosts, where N is 

364``[filter_scheduler] host_subset_size``. 

365 

366By default, this is set to all weighers that are included with Nova. 

367 

368Possible values: 

369 

370* A list of zero or more strings, where each string corresponds to the name of 

371 a weigher that will be used for selecting a host 

372"""), 

373 cfg.FloatOpt("ram_weight_multiplier", 

374 default=1.0, 

375 help=""" 

376RAM weight multiplier ratio. 

377 

378This option determines how hosts with more or less available RAM are weighed. A 

379positive value will result in the scheduler preferring hosts with more 

380available RAM, and a negative number will result in the scheduler preferring 

381hosts with less available RAM. Another way to look at it is that positive 

382values for this option will tend to spread instances across many hosts, while 

383negative values will tend to fill up (stack) hosts as much as possible before 

384scheduling to a less-used host. The absolute value, whether positive or 

385negative, controls how strong the RAM weigher is relative to other weighers. 

386 

387Note that this setting only affects scheduling if the ``RAMWeigher`` weigher is 

388enabled. 

389 

390Possible values: 

391 

392* An integer or float value, where the value corresponds to the multiplier 

393 ratio for this weigher. 

394 

395Related options: 

396 

397* ``[filter_scheduler] weight_classes`` 

398"""), 

399 cfg.FloatOpt("cpu_weight_multiplier", 

400 default=1.0, 

401 help=""" 

402CPU weight multiplier ratio. 

403 

404Multiplier used for weighting free vCPUs. Negative numbers indicate stacking 

405rather than spreading. 

406 

407Note that this setting only affects scheduling if the ``CPUWeigher`` weigher is 

408enabled. 

409 

410Possible values: 

411 

412* An integer or float value, where the value corresponds to the multiplier 

413 ratio for this weigher. 

414 

415Related options: 

416 

417* ``[filter_scheduler] weight_classes`` 

418"""), 

419 cfg.FloatOpt("disk_weight_multiplier", 

420 default=1.0, 

421 help=""" 

422Disk weight multiplier ratio. 

423 

424Multiplier used for weighing free disk space. Negative numbers mean to 

425stack vs spread. 

426 

427Note that this setting only affects scheduling if the ``DiskWeigher`` weigher 

428is enabled. 

429 

430Possible values: 

431 

432* An integer or float value, where the value corresponds to the multiplier 

433 ratio for this weigher. 

434"""), 

435 cfg.FloatOpt("hypervisor_version_weight_multiplier", 

436 default=1.0, 

437 help=""" 

438Hypervisor Version weight multiplier ratio. 

439 

440The multiplier is used for weighting hosts based on the reported 

441hypervisor version. 

442Negative numbers indicate preferring older hosts, 

443the default is to prefer newer hosts to aid with upgrades. 

444 

445Possible values: 

446 

447* An integer or float value, where the value corresponds to the multiplier 

448 ratio for this weigher. 

449 

450Example: 

451 

452* Strongly prefer older hosts 

453 

454 .. code-block:: ini 

455 

456 [filter_scheduler] 

457 hypervisor_version_weight_multiplier=-1000 

458 

459 

460* Moderately prefer new hosts 

461 

462 .. code-block:: ini 

463 

464 [filter_scheduler] 

465 hypervisor_version_weight_multiplier=2.5 

466 

467* Disable weigher influence 

468 

469 .. code-block:: ini 

470 

471 [filter_scheduler] 

472 hypervisor_version_weight_multiplier=0 

473 

474Related options: 

475 

476* ``[filter_scheduler] weight_classes`` 

477"""), 

478 cfg.FloatOpt("num_instances_weight_multiplier", 

479 default=0.0, 

480 help=""" 

481Number of instances weight multiplier ratio. 

482 

483The multiplier is used for weighting hosts based on the reported 

484number of instances they have. 

485Negative numbers indicate preferring hosts with fewer instances (i.e. choosing 

486to spread instances), while positive numbers mean preferring hosts with more 

487hosts (ie. choosing to pack). 

488The default is 0.0 which means that you have to choose a strategy if you want 

489to use it. 

490 

491Possible values: 

492 

493* An integer or float value, where the value corresponds to the multiplier 

494 ratio for this weigher. 

495 

496Example: 

497 

498* Strongly prefer to pack instances to hosts. 

499 

500 .. code-block:: ini 

501 

502 [filter_scheduler] 

503 num_instances_weight_multiplier=1000 

504 

505* Softly prefer to spread instances between hosts. 

506 

507 .. code-block:: ini 

508 

509 [filter_scheduler] 

510 num_instances_weight_multiplier=1.0 

511 

512* Disable weigher influence 

513 

514 .. code-block:: ini 

515 

516 [filter_scheduler] 

517 num_instances_weight_multiplier=0 

518 

519Related options: 

520 

521* ``[filter_scheduler] weight_classes`` 

522"""), 

523 cfg.FloatOpt("io_ops_weight_multiplier", 

524 default=-1.0, 

525 help=""" 

526IO operations weight multiplier ratio. 

527 

528This option determines how hosts with differing workloads are weighed. Negative 

529values, such as the default, will result in the scheduler preferring hosts with 

530lighter workloads whereas positive values will prefer hosts with heavier 

531workloads. Another way to look at it is that positive values for this option 

532will tend to schedule instances onto hosts that are already busy, while 

533negative values will tend to distribute the workload across more hosts. The 

534absolute value, whether positive or negative, controls how strong the io_ops 

535weigher is relative to other weighers. 

536 

537Note that this setting only affects scheduling if the ``IoOpsWeigher`` weigher 

538is enabled. 

539 

540Possible values: 

541 

542* An integer or float value, where the value corresponds to the multiplier 

543 ratio for this weigher. 

544 

545Related options: 

546 

547* ``[filter_scheduler] weight_classes`` 

548"""), 

549 cfg.FloatOpt("image_props_weight_multiplier", 

550 default=0.0, 

551 help=""" 

552Image Properties weight multiplier ratio. 

553 

554The multiplier is used for weighting hosts based on the reported 

555image properties for the instances they have. 

556A positive value will favor hosts with the same image properties (packing 

557strategy) while a negative value will follow a spread strategy that will favor 

558hosts not already having instances with those image properties. 

559The default value of the multiplier is 0, which disables the weigher. 

560 

561Possible values: 

562 

563* An integer or float value, where the value corresponds to the multiplier 

564 ratio for this weigher. 

565 

566Example: 

567 

568* Strongly prefer to pack instances with related image properties. 

569 

570 .. code-block:: ini 

571 

572 [filter_scheduler] 

573 image_props_weight_multiplier=1000 

574 

575* Softly prefer to spread instances having same properties between hosts 

576 

577 .. code-block:: ini 

578 

579 [filter_scheduler] 

580 image_props_weight_multiplier=-1.0 

581 

582* Disable weigher influence 

583 

584 .. code-block:: ini 

585 

586 [filter_scheduler] 

587 image_props_weight_multiplier=0 

588 

589Related options: 

590 

591* ``[filter_scheduler] weight_classes`` 

592"""), 

593 cfg.ListOpt("image_props_weight_setting", 

594 default=[], 

595 help=""" 

596Mapping of image properties to weight modifier. 

597 

598This setting specifies the properties to be weighed and the relative ratios for 

599each property. This should be a list of key/value pairs, consisting of a series 

600of one or more 'name=ratio' pairs, separated by commas, where ``name`` is the 

601name of the property to be weighed, and ``ratio`` is the relative weight for 

602that metric. 

603 

604Note that if the ratio is set to 0, the property value is ignored, and instead 

605the weight will be set to the value of the 

606``[filter_scheduler] image_props_weight_multiplier`` option. 

607 

608As an example, let's consider the case where this option is set to: 

609 

610 ``os_distro=1, hw_machine_type=-1`` 

611 

612If an instance would boot with an image having ``os_distro=windows`` and 

613``hw_machine_type=q35``, the final host weight will be: 

614 

615 ``(nb_inst(``os_distro=windows``) * 1.0) + 

616 (nb_inst(``hw_machine_type=q35``) * -1)`` 

617 

618where nb_inst(``prop=value``) would give me the number of instances having 

619an image where ``prop`` is set to ``value`` (eg. the number of instances 

620running with ``os_distro=windows``) 

621 

622Possible values: 

623 

624* A list of zero or more key/value pairs separated by commas, where the key is 

625 a string representing the name of a property and the value is a numeric 

626 weight for that property. If any value is set to 0, the number of instances 

627 match is ignored for that specific property key. 

628 If no key/value pairs are provided, then the weigher will compare all the 

629 instance's images with the requested image properties, all of them weighed 

630 evenly. 

631 

632 

633The overall host weight will be multiplied by the value of the 

634 ``[filter_scheduler] image_props_weight_multiplier`` option. 

635 

636Related options: 

637 

638* ``[filter_scheduler] image_props_weight_multiplier`` 

639"""), 

640 cfg.FloatOpt("pci_weight_multiplier", 

641 default=1.0, 

642 min=0.0, 

643 help=""" 

644PCI device affinity weight multiplier. 

645 

646The PCI device affinity weighter computes a weighting based on the number of 

647PCI devices on the host and the number of PCI devices requested by the 

648instance. 

649 

650Note that this setting only affects scheduling if the ``PCIWeigher`` weigher 

651and ``NUMATopologyFilter`` filter are enabled. 

652 

653Possible values: 

654 

655* A positive integer or float value, where the value corresponds to the 

656 multiplier ratio for this weigher. 

657 

658Related options: 

659 

660* ``[filter_scheduler] weight_classes`` 

661"""), 

662 cfg.FloatOpt("soft_affinity_weight_multiplier", 

663 default=1.0, 

664 min=0.0, 

665 help=""" 

666Multiplier used for weighing hosts for group soft-affinity. 

667 

668Note that this setting only affects scheduling if the 

669``ServerGroupSoftAffinityWeigher`` weigher is enabled. 

670 

671Possible values: 

672 

673* A non-negative integer or float value, where the value corresponds to 

674 weight multiplier for hosts with group soft affinity. 

675 

676Related options: 

677 

678* ``[filter_scheduler] weight_classes`` 

679"""), 

680 cfg.FloatOpt( 

681 "soft_anti_affinity_weight_multiplier", 

682 default=1.0, 

683 min=0.0, 

684 help=""" 

685Multiplier used for weighing hosts for group soft-anti-affinity. 

686 

687Note that this setting only affects scheduling if the 

688``ServerGroupSoftAntiAffinityWeigher`` weigher is enabled. 

689 

690Possible values: 

691 

692* A non-negative integer or float value, where the value corresponds to 

693 weight multiplier for hosts with group soft anti-affinity. 

694 

695Related options: 

696 

697* ``[filter_scheduler] weight_classes`` 

698"""), 

699 cfg.FloatOpt( 

700 "build_failure_weight_multiplier", 

701 default=1000000.0, 

702 help=""" 

703Multiplier used for weighing hosts that have had recent build failures. 

704 

705This option determines how much weight is placed on a compute node with 

706recent build failures. Build failures may indicate a failing, misconfigured, 

707or otherwise ailing compute node, and avoiding it during scheduling may be 

708beneficial. The weight is inversely proportional to the number of recent 

709build failures the compute node has experienced. This value should be 

710set to some high value to offset weight given by other enabled weighers 

711due to available resources. To disable weighing compute hosts by the 

712number of recent failures, set this to zero. 

713 

714Note that this setting only affects scheduling if the ``BuildFailureWeigher`` 

715weigher is enabled. 

716 

717Possible values: 

718 

719* An integer or float value, where the value corresponds to the multiplier 

720 ratio for this weigher. 

721 

722Related options: 

723 

724* ``[compute] consecutive_build_service_disable_threshold`` - Must be nonzero 

725 for a compute to report data considered by this weigher. 

726* ``[filter_scheduler] weight_classes`` 

727"""), 

728 cfg.FloatOpt( 

729 "cross_cell_move_weight_multiplier", 

730 default=1000000.0, 

731 help=""" 

732Multiplier used for weighing hosts during a cross-cell move. 

733 

734This option determines how much weight is placed on a host which is within the 

735same source cell when moving a server, for example during cross-cell resize. 

736By default, when moving an instance, the scheduler will prefer hosts within 

737the same cell since cross-cell move operations can be slower and riskier due to 

738the complicated nature of cross-cell migrations. 

739 

740Note that this setting only affects scheduling if the ``CrossCellWeigher`` 

741weigher is enabled. If your cloud is not configured to support cross-cell 

742migrations, then this option has no effect. 

743 

744The value of this configuration option can be overridden per host aggregate 

745by setting the aggregate metadata key with the same name 

746(``cross_cell_move_weight_multiplier``). 

747 

748Possible values: 

749 

750* An integer or float value, where the value corresponds to the multiplier 

751 ratio for this weigher. Positive values mean the weigher will prefer 

752 hosts within the same cell in which the instance is currently running. 

753 Negative values mean the weigher will prefer hosts in *other* cells from 

754 which the instance is currently running. 

755 

756Related options: 

757 

758* ``[filter_scheduler] weight_classes`` 

759"""), 

760 cfg.BoolOpt( 

761 "shuffle_best_same_weighed_hosts", 

762 default=False, 

763 help=""" 

764Enable spreading the instances between hosts with the same best weight. 

765 

766Enabling it is beneficial for cases when ``[filter_scheduler] 

767host_subset_size`` is 1 (default), but there is a large number of hosts with 

768same maximal weight. This scenario is common in Ironic deployments where there 

769are typically many baremetal nodes with identical weights returned to the 

770scheduler. In such case enabling this option will reduce contention and 

771chances for rescheduling events. At the same time it will make the instance 

772packing (even in unweighed case) less dense. 

773"""), 

774 cfg.StrOpt( 

775 "image_properties_default_architecture", 

776 choices=arch.ALL, 

777 help=""" 

778The default architecture to be used when using the image properties filter. 

779 

780When using the ``ImagePropertiesFilter``, it is possible that you want to 

781define a default architecture to make the user experience easier and avoid 

782having something like x86_64 images landing on AARCH64 compute nodes because 

783the user did not specify the ``hw_architecture`` property in Glance. 

784 

785Possible values: 

786 

787* CPU Architectures such as x86_64, aarch64, s390x. 

788"""), 

789 # TODO(mikal): replace this option with something involving host aggregates 

790 cfg.ListOpt("isolated_images", 

791 default=[], 

792 help=""" 

793List of UUIDs for images that can only be run on certain hosts. 

794 

795If there is a need to restrict some images to only run on certain designated 

796hosts, list those image UUIDs here. 

797 

798Note that this setting only affects scheduling if the ``IsolatedHostsFilter`` 

799filter is enabled. 

800 

801Possible values: 

802 

803* A list of UUID strings, where each string corresponds to the UUID of an 

804 image 

805 

806Related options: 

807 

808* ``[filter_scheduler] isolated_hosts`` 

809* ``[filter_scheduler] restrict_isolated_hosts_to_isolated_images`` 

810"""), 

811 cfg.ListOpt("isolated_hosts", 

812 default=[], 

813 help=""" 

814List of hosts that can only run certain images. 

815 

816If there is a need to restrict some images to only run on certain designated 

817hosts, list those host names here. 

818 

819Note that this setting only affects scheduling if the ``IsolatedHostsFilter`` 

820filter is enabled. 

821 

822Possible values: 

823 

824* A list of strings, where each string corresponds to the name of a host 

825 

826Related options: 

827 

828* ``[filter_scheduler] isolated_images`` 

829* ``[filter_scheduler] restrict_isolated_hosts_to_isolated_images`` 

830"""), 

831 cfg.BoolOpt( 

832 "restrict_isolated_hosts_to_isolated_images", 

833 default=True, 

834 help=""" 

835Prevent non-isolated images from being built on isolated hosts. 

836 

837Note that this setting only affects scheduling if the ``IsolatedHostsFilter`` 

838filter is enabled. Even then, this option doesn't affect the behavior of 

839requests for isolated images, which will *always* be restricted to isolated 

840hosts. 

841 

842Related options: 

843 

844* ``[filter_scheduler] isolated_images`` 

845* ``[filter_scheduler] isolated_hosts`` 

846"""), 

847 # TODO(stephenfin): Consider deprecating these next two options: they're 

848 # effectively useless now that we don't support arbitrary image metadata 

849 # properties 

850 cfg.StrOpt( 

851 "aggregate_image_properties_isolation_namespace", 

852 help=""" 

853Image property namespace for use in the host aggregate. 

854 

855Images and hosts can be configured so that certain images can only be scheduled 

856to hosts in a particular aggregate. This is done with metadata values set on 

857the host aggregate that are identified by beginning with the value of this 

858option. If the host is part of an aggregate with such a metadata key, the image 

859in the request spec must have the value of that metadata in its properties in 

860order for the scheduler to consider the host as acceptable. 

861 

862Note that this setting only affects scheduling if the 

863``AggregateImagePropertiesIsolation`` filter is enabled. 

864 

865Possible values: 

866 

867* A string, where the string corresponds to an image property namespace 

868 

869Related options: 

870 

871* ``[filter_scheduler] aggregate_image_properties_isolation_separator`` 

872"""), 

873 cfg.StrOpt( 

874 "aggregate_image_properties_isolation_separator", 

875 default=".", 

876 help=""" 

877Separator character(s) for image property namespace and name. 

878 

879When using the aggregate_image_properties_isolation filter, the relevant 

880metadata keys are prefixed with the namespace defined in the 

881aggregate_image_properties_isolation_namespace configuration option plus a 

882separator. This option defines the separator to be used. 

883 

884Note that this setting only affects scheduling if the 

885``AggregateImagePropertiesIsolation`` filter is enabled. 

886 

887Possible values: 

888 

889* A string, where the string corresponds to an image property namespace 

890 separator character 

891 

892Related options: 

893 

894* ``[filter_scheduler] aggregate_image_properties_isolation_namespace`` 

895"""), 

896 cfg.BoolOpt( 

897 "pci_in_placement", 

898 default=False, 

899 help=""" 

900Enable scheduling and claiming PCI devices in Placement. 

901 

902This can be enabled after ``[pci]report_in_placement`` is enabled on all 

903compute hosts. 

904 

905When enabled the scheduler queries Placement about the PCI device 

906availability to select destination for a server with PCI request. The scheduler 

907also allocates the selected PCI devices in Placement. Note that this logic 

908does not replace the PCIPassthroughFilter but extends it. 

909 

910* ``[pci] report_in_placement`` 

911* ``[pci] alias`` 

912* ``[pci] device_spec`` 

913"""), 

914] 

915 

916metrics_group = cfg.OptGroup( 

917 name="metrics", 

918 title="Metrics parameters", 

919 help=""" 

920Configuration options for metrics 

921 

922Options under this group allow to adjust how values assigned to metrics are 

923calculated. 

924""") 

925 

926# TODO(stephenfin): This entire feature could probably be removed. It's not 

927# tested and likely doesn't work with most drivers now. 

928metrics_weight_opts = [ 

929 cfg.FloatOpt("weight_multiplier", 

930 default=1.0, 

931 help=""" 

932Multiplier used for weighing hosts based on reported metrics. 

933 

934When using metrics to weight the suitability of a host, you can use this option 

935to change how the calculated weight influences the weight assigned to a host as 

936follows: 

937 

938* ``>1.0``: increases the effect of the metric on overall weight 

939* ``1.0``: no change to the calculated weight 

940* ``>0.0,<1.0``: reduces the effect of the metric on overall weight 

941* ``0.0``: the metric value is ignored, and the value of the 

942 ``[metrics] weight_of_unavailable`` option is returned instead 

943* ``>-1.0,<0.0``: the effect is reduced and reversed 

944* ``-1.0``: the effect is reversed 

945* ``<-1.0``: the effect is increased proportionally and reversed 

946 

947Possible values: 

948 

949* An integer or float value, where the value corresponds to the multiplier 

950 ratio for this weigher. 

951 

952Related options: 

953 

954* ``[filter_scheduler] weight_classes`` 

955* ``[metrics] weight_of_unavailable`` 

956"""), 

957 cfg.ListOpt("weight_setting", 

958 default=[], 

959 help=""" 

960Mapping of metric to weight modifier. 

961 

962This setting specifies the metrics to be weighed and the relative ratios for 

963each metric. This should be a single string value, consisting of a series of 

964one or more 'name=ratio' pairs, separated by commas, where ``name`` is the name 

965of the metric to be weighed, and ``ratio`` is the relative weight for that 

966metric. 

967 

968Note that if the ratio is set to 0, the metric value is ignored, and instead 

969the weight will be set to the value of the ``[metrics] weight_of_unavailable`` 

970option. 

971 

972As an example, let's consider the case where this option is set to: 

973 

974 ``name1=1.0, name2=-1.3`` 

975 

976The final weight will be: 

977 

978 ``(name1.value * 1.0) + (name2.value * -1.3)`` 

979 

980Possible values: 

981 

982* A list of zero or more key/value pairs separated by commas, where the key is 

983 a string representing the name of a metric and the value is a numeric weight 

984 for that metric. If any value is set to 0, the value is ignored and the 

985 weight will be set to the value of the ``[metrics] weight_of_unavailable`` 

986 option. 

987 

988Related options: 

989 

990* ``[metrics] weight_of_unavailable`` 

991"""), 

992 cfg.BoolOpt("required", 

993 default=True, 

994 help=""" 

995Whether metrics are required. 

996 

997This setting determines how any unavailable metrics are treated. If this option 

998is set to True, any hosts for which a metric is unavailable will raise an 

999exception, so it is recommended to also use the MetricFilter to filter out 

1000those hosts before weighing. 

1001 

1002Possible values: 

1003 

1004* A boolean value, where False ensures any metric being unavailable for a host 

1005 will set the host weight to ``[metrics] weight_of_unavailable``. 

1006 

1007Related options: 

1008 

1009* ``[metrics] weight_of_unavailable`` 

1010"""), 

1011 cfg.FloatOpt("weight_of_unavailable", 

1012 default=float(-10000.0), 

1013 help=""" 

1014Default weight for unavailable metrics. 

1015 

1016When any of the following conditions are met, this value will be used in place 

1017of any actual metric value: 

1018 

1019- One of the metrics named in ``[metrics] weight_setting`` is not available for 

1020 a host, and the value of ``required`` is ``False``. 

1021- The ratio specified for a metric in ``[metrics] weight_setting`` is 0. 

1022- The ``[metrics] weight_multiplier`` option is set to 0. 

1023 

1024Possible values: 

1025 

1026* An integer or float value, where the value corresponds to the multiplier 

1027 ratio for this weigher. 

1028 

1029Related options: 

1030 

1031* ``[metrics] weight_setting`` 

1032* ``[metrics] required`` 

1033* ``[metrics] weight_multiplier`` 

1034"""), 

1035] 

1036 

1037 

1038def register_opts(conf): 

1039 conf.register_group(scheduler_group) 

1040 conf.register_opts(scheduler_opts, group=scheduler_group) 

1041 

1042 conf.register_group(filter_scheduler_group) 

1043 conf.register_opts(filter_scheduler_opts, group=filter_scheduler_group) 

1044 

1045 conf.register_group(metrics_group) 

1046 conf.register_opts(metrics_weight_opts, group=metrics_group) 

1047 

1048 

1049def list_opts(): 

1050 return { 

1051 scheduler_group: scheduler_opts, 

1052 filter_scheduler_group: filter_scheduler_opts, 

1053 metrics_group: metrics_weight_opts, 

1054 }