---
# Handle case where openshift_master_predicates is defined
- when: openshift_master_scheduler_predicates | default(none) is not none
  block:
  - name: openshift_master_scheduler_predicates is defined
    debug:
      msg: "openshift_master_scheduler_predicates is defined"

  - name: openshift_master_scheduler_predicates is set to defaults from an earlier release
    debug:
      msg: "WARNING: openshift_master_scheduler_predicates is set to defaults from an earlier release of OpenShift current defaults are: {{ openshift_master_scheduler_default_predicates }}"
    when: openshift_master_scheduler_predicates in osm_older_predicates + osm_older_predicates_no_region + [osm_prev_predicates] + [osm_prev_predicates_no_region]

  - name: openshift_master_scheduler_predicates does not match current defaults
    debug:
      msg: "WARNING: openshift_master_scheduler_predicates does not match current defaults of: {{ openshift_master_scheduler_default_predicates }}"
    when: openshift_master_scheduler_predicates != openshift_master_scheduler_default_predicates

# Handle cases where openshift_master_predicates is not defined
- when: openshift_master_scheduler_predicates | default(none) is none
  block:
  - name: openshift_master_scheduler_predicates is not defined
    debug:
      msg: "openshift_master_scheduler_predicates is not defined"

  - name: existing scheduler config does not match previous known defaults
    debug:
      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 }}"
    when:
    - openshift_master_scheduler_current_predicates != openshift_master_scheduler_default_predicates
    - openshift_master_scheduler_current_predicates not in osm_older_predicates + [osm_prev_predicates]

  - name: set_fact openshift_upgrade_scheduler_predicates 1
    set_fact:
      openshift_upgrade_scheduler_predicates: "{{ openshift_master_scheduler_default_predicates }}"
    when:
    - openshift_master_scheduler_current_predicates != openshift_master_scheduler_default_predicates
    - openshift_master_scheduler_current_predicates in osm_older_predicates + [osm_prev_predicates]

  - name: set_fact openshift_upgrade_scheduler_predicates 2
    set_fact:
      openshift_upgrade_scheduler_predicates: "{{ osm_default_predicates_no_region }}"
    when:
    - openshift_master_scheduler_current_predicates != osm_default_predicates_no_region
    - openshift_master_scheduler_current_predicates in osm_older_predicates_no_region + [osm_prev_predicates_no_region]
