upgrade_scheduler.yml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. ---
  2. # Upgrade predicates
  3. - vars:
  4. prev_predicates: "{{ lookup('openshift_master_facts_default_predicates', short_version=openshift_upgrade_min, deployment_type=openshift_deployment_type) }}"
  5. prev_predicates_no_region: "{{ lookup('openshift_master_facts_default_predicates', short_version=openshift_upgrade_min, deployment_type=openshift_deployment_type, regions_enabled=False) }}"
  6. default_predicates_no_region: "{{ lookup('openshift_master_facts_default_predicates', regions_enabled=False) }}"
  7. # older_predicates are the set of predicates that have previously been
  8. # hard-coded into openshift_facts
  9. older_predicates:
  10. - - name: MatchNodeSelector
  11. - name: PodFitsResources
  12. - name: PodFitsPorts
  13. - name: NoDiskConflict
  14. - name: NoVolumeZoneConflict
  15. - name: MaxEBSVolumeCount
  16. - name: MaxGCEPDVolumeCount
  17. - name: Region
  18. argument:
  19. serviceAffinity:
  20. labels:
  21. - region
  22. - - name: MatchNodeSelector
  23. - name: PodFitsResources
  24. - name: PodFitsPorts
  25. - name: NoDiskConflict
  26. - name: NoVolumeZoneConflict
  27. - name: Region
  28. argument:
  29. serviceAffinity:
  30. labels:
  31. - region
  32. - - name: MatchNodeSelector
  33. - name: PodFitsResources
  34. - name: PodFitsPorts
  35. - name: NoDiskConflict
  36. - name: Region
  37. argument:
  38. serviceAffinity:
  39. labels:
  40. - region
  41. # older_predicates_no_region are the set of predicates that have previously
  42. # been hard-coded into openshift_facts, with the Region predicate removed
  43. older_predicates_no_region:
  44. - - name: MatchNodeSelector
  45. - name: PodFitsResources
  46. - name: PodFitsPorts
  47. - name: NoDiskConflict
  48. - name: NoVolumeZoneConflict
  49. - name: MaxEBSVolumeCount
  50. - name: MaxGCEPDVolumeCount
  51. - - name: MatchNodeSelector
  52. - name: PodFitsResources
  53. - name: PodFitsPorts
  54. - name: NoDiskConflict
  55. - name: NoVolumeZoneConflict
  56. - - name: MatchNodeSelector
  57. - name: PodFitsResources
  58. - name: PodFitsPorts
  59. - name: NoDiskConflict
  60. block:
  61. # Handle case where openshift_master_predicates is defined
  62. - block:
  63. - debug:
  64. msg: "WARNING: openshift_master_scheduler_predicates is set to defaults from an earlier release of OpenShift current defaults are: {{ openshift_master_scheduler_default_predicates }}"
  65. when: openshift_master_scheduler_predicates in older_predicates + older_predicates_no_region + [prev_predicates] + [prev_predicates_no_region]
  66. - debug:
  67. msg: "WARNING: openshift_master_scheduler_predicates does not match current defaults of: {{ openshift_master_scheduler_default_predicates }}"
  68. when: openshift_master_scheduler_predicates != openshift_master_scheduler_default_predicates
  69. when: openshift_master_scheduler_predicates | default(none) is not none
  70. # Handle cases where openshift_master_predicates is not defined
  71. - block:
  72. - debug:
  73. msg: "WARNING: existing scheduler config does not match previous known defaults automated upgrade of scheduler config is disabled.\nexisting scheduler predicates: {{ openshift_master_scheduler_current_predicates }}\ncurrent scheduler default predicates are: {{ openshift_master_scheduler_default_predicates }}"
  74. when: "{{ openshift_master_scheduler_current_predicates != openshift_master_scheduler_default_predicates and
  75. openshift_master_scheduler_current_predicates not in older_predicates + [prev_predicates] }}"
  76. - set_fact:
  77. openshift_upgrade_scheduler_predicates: "{{ openshift_master_scheduler_default_predicates }}"
  78. when: "{{ openshift_master_scheduler_current_predicates != openshift_master_scheduler_default_predicates and
  79. openshift_master_scheduler_current_predicates in older_predicates + [prev_predicates] }}"
  80. - set_fact:
  81. openshift_upgrade_scheduler_predicates: "{{ default_predicates_no_region }}"
  82. when: "{{ openshift_master_scheduler_current_predicates != default_predicates_no_region and
  83. openshift_master_scheduler_current_predicates in older_predicates_no_region + [prev_predicates_no_region] }}"
  84. when: openshift_master_scheduler_predicates | default(none) is none
  85. # Upgrade priorities
  86. - vars:
  87. prev_priorities: "{{ lookup('openshift_master_facts_default_priorities', short_version=openshift_upgrade_min, deployment_type=openshift_deployment_type) }}"
  88. prev_priorities_no_zone: "{{ lookup('openshift_master_facts_default_priorities', short_version=openshift_upgrade_min, deployment_type=openshift_deployment_type, zones_enabled=False) }}"
  89. default_priorities_no_zone: "{{ lookup('openshift_master_facts_default_priorities', zones_enabled=False) }}"
  90. # older_priorities are the set of priorities that have previously been
  91. # hard-coded into openshift_facts
  92. older_priorities:
  93. - - name: LeastRequestedPriority
  94. weight: 1
  95. - name: SelectorSpreadPriority
  96. weight: 1
  97. - name: Zone
  98. weight: 2
  99. argument:
  100. serviceAntiAffinity:
  101. label: zone
  102. # older_priorities_no_region are the set of priorities that have previously
  103. # been hard-coded into openshift_facts, with the Zone priority removed
  104. older_priorities_no_zone:
  105. - - name: LeastRequestedPriority
  106. weight: 1
  107. - name: SelectorSpreadPriority
  108. weight: 1
  109. block:
  110. # Handle case where openshift_master_priorities is defined
  111. - block:
  112. - debug:
  113. msg: "WARNING: openshift_master_scheduler_priorities is set to defaults from an earlier release of OpenShift current defaults are: {{ openshift_master_scheduler_default_priorities }}"
  114. when: openshift_master_scheduler_priorities in older_priorities + older_priorities_no_zone + [prev_priorities] + [prev_priorities_no_zone]
  115. - debug:
  116. msg: "WARNING: openshift_master_scheduler_priorities does not match current defaults of: {{ openshift_master_scheduler_default_priorities }}"
  117. when: openshift_master_scheduler_priorities != openshift_master_scheduler_default_priorities
  118. when: openshift_master_scheduler_priorities | default(none) is not none
  119. # Handle cases where openshift_master_priorities is not defined
  120. - block:
  121. - debug:
  122. msg: "WARNING: existing scheduler config does not match previous known defaults automated upgrade of scheduler config is disabled.\nexisting scheduler priorities: {{ openshift_master_scheduler_current_priorities }}\ncurrent scheduler default priorities are: {{ openshift_master_scheduler_default_priorities }}"
  123. when: "{{ openshift_master_scheduler_current_priorities != openshift_master_scheduler_default_priorities and
  124. openshift_master_scheduler_current_priorities not in older_priorities + [prev_priorities] }}"
  125. - set_fact:
  126. openshift_upgrade_scheduler_priorities: "{{ openshift_master_scheduler_default_priorities }}"
  127. when: "{{ openshift_master_scheduler_current_priorities != openshift_master_scheduler_default_priorities and
  128. openshift_master_scheduler_current_priorities in older_priorities + [prev_priorities] }}"
  129. - set_fact:
  130. openshift_upgrade_scheduler_priorities: "{{ default_priorities_no_zone }}"
  131. when: "{{ openshift_master_scheduler_current_priorities != default_priorities_no_zone and
  132. openshift_master_scheduler_current_priorities in older_priorities_no_zone + [prev_priorities_no_zone] }}"
  133. when: openshift_master_scheduler_priorities | default(none) is none
  134. # Update scheduler
  135. - vars:
  136. scheduler_config:
  137. kind: Policy
  138. apiVersion: v1
  139. predicates: "{{ openshift_upgrade_scheduler_predicates
  140. | default(openshift_master_scheduler_current_predicates) }}"
  141. priorities: "{{ openshift_upgrade_scheduler_priorities
  142. | default(openshift_master_scheduler_current_priorities) }}"
  143. block:
  144. - name: Update scheduler config
  145. copy:
  146. content: "{{ scheduler_config | to_nice_json }}"
  147. dest: "{{ openshift_master_scheduler_conf }}"
  148. backup: true
  149. when: "{{ openshift_upgrade_scheduler_predicates is defined or
  150. openshift_upgrade_scheduler_priorities is defined }}"