upgrade_scheduler.yml 8.1 KB

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