docker_upgrade.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. ---
  2. - import_playbook: ../../../../init/evaluate_groups.yml
  3. vars:
  4. # Do not allow adding hosts during upgrade.
  5. g_new_master_hosts: []
  6. g_new_node_hosts: []
  7. - import_playbook: ../initialize_nodes_to_upgrade.yml
  8. - import_playbook: ../../../../init/basic_facts.yml
  9. vars:
  10. l_init_fact_hosts: "oo_masters_to_config:oo_etcd_to_config:oo_lb_to_config:oo_nodes_to_upgrade"
  11. - import_playbook: ../../../../init/cluster_facts.yml
  12. vars:
  13. l_init_fact_hosts: "oo_masters_to_config:oo_etcd_to_config:oo_lb_to_config:oo_nodes_to_upgrade"
  14. # We need version for sanity_checks, but we don't need to actually check if
  15. # packages/images are available because we're not install any origin components.
  16. - import_playbook: ../../../../init/version.yml
  17. vars:
  18. l_openshift_version_set_hosts: "oo_etcd_to_config:oo_nodes_to_upgrade:oo_masters_to_config:!oo_first_master"
  19. l_openshift_version_check_hosts: "all:!all"
  20. # Ensure inventory sanity_checks are run.
  21. - import_playbook: ../../../../init/sanity_checks.yml
  22. vars:
  23. l_sanity_check_hosts: "{{ groups['oo_nodes_to_upgrade'] | union(groups['oo_masters_to_config']) | union(groups['oo_etcd_to_config']) }}"
  24. - name: Check for appropriate Docker versions
  25. hosts: oo_masters_to_config:oo_nodes_to_upgrade:oo_etcd_to_config
  26. roles:
  27. - openshift_facts
  28. tasks:
  29. - fail:
  30. msg: Cannot upgrade Docker on Atomic operating systems.
  31. when: openshift_is_atomic | bool
  32. - import_role:
  33. name: container_runtime
  34. tasks_from: docker_upgrade_check.yml
  35. when: docker_upgrade | default(True) | bool
  36. # If a node fails, halt everything, the admin will need to clean up and we
  37. # don't want to carry on, potentially taking out every node. The playbook can safely be re-run
  38. # and will not take any action on a node already running the requested docker version.
  39. - name: Drain and upgrade nodes
  40. hosts: oo_masters_to_config:oo_nodes_to_upgrade:oo_etcd_to_config
  41. serial: 1
  42. any_errors_fatal: true
  43. roles:
  44. - openshift_facts
  45. - lib_openshift
  46. tasks:
  47. - name: Mark node unschedulable
  48. oc_adm_manage_node:
  49. node: "{{ openshift.node.nodename | lower }}"
  50. schedulable: False
  51. delegate_to: "{{ groups.oo_first_master.0 }}"
  52. retries: 10
  53. delay: 5
  54. register: node_unschedulable
  55. until: node_unschedulable is succeeded
  56. when:
  57. - l_docker_upgrade is defined
  58. - l_docker_upgrade | bool
  59. - inventory_hostname in groups.oo_nodes_to_upgrade
  60. - name: Drain Node for Kubelet upgrade
  61. command: >
  62. {{ hostvars[groups.oo_first_master.0]['first_master_client_binary'] }} adm drain {{ openshift.node.nodename | lower }}
  63. --config={{ openshift.common.config_base }}/master/admin.kubeconfig
  64. --force --delete-local-data --ignore-daemonsets
  65. --timeout={{ openshift_upgrade_nodes_drain_timeout | default(0) }}s
  66. delegate_to: "{{ groups.oo_first_master.0 }}"
  67. when:
  68. - l_docker_upgrade is defined
  69. - l_docker_upgrade | bool
  70. - inventory_hostname in groups.oo_nodes_to_upgrade
  71. register: l_docker_upgrade_drain_result
  72. until: not (l_docker_upgrade_drain_result is failed)
  73. retries: "{{ 1 if ( openshift_upgrade_nodes_drain_timeout | default(0) | int ) == 0 else 0 }}"
  74. delay: 5
  75. failed_when:
  76. - l_docker_upgrade_drain_result is failed
  77. - openshift_upgrade_nodes_drain_timeout | default(0) | int == 0
  78. - include_tasks: tasks/upgrade.yml
  79. when:
  80. - l_docker_upgrade is defined
  81. - l_docker_upgrade | bool
  82. - name: Set node schedulability
  83. oc_adm_manage_node:
  84. node: "{{ openshift.node.nodename | lower }}"
  85. schedulable: True
  86. delegate_to: "{{ groups.oo_first_master.0 }}"
  87. retries: 10
  88. delay: 5
  89. register: node_schedulable
  90. until: node_schedulable is succeeded
  91. when: node_unschedulable is changed