A service for managing and provisioning Bare Metal servers.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

141 lines
4.7 KiB

  1. #!/usr/bin/env bash
  2. # ``upgrade-ironic``
  3. echo "*********************************************************************"
  4. echo "Begin $0"
  5. echo "*********************************************************************"
  6. # Clean up any resources that may be in use
  7. cleanup() {
  8. set +o errexit
  9. echo "*********************************************************************"
  10. echo "ERROR: Abort $0"
  11. echo "*********************************************************************"
  12. # Kill ourselves to signal any calling process
  13. trap 2; kill -2 $$
  14. }
  15. trap cleanup SIGHUP SIGINT SIGTERM
  16. # Keep track of the grenade directory
  17. RUN_DIR=$(cd $(dirname "$0") && pwd)
  18. # Source params
  19. source $GRENADE_DIR/grenaderc
  20. # Import common functions
  21. source $GRENADE_DIR/functions
  22. # This script exits on an error so that errors don't compound and you see
  23. # only the first error that occurred.
  24. set -o errexit
  25. # Upgrade Ironic
  26. # ============
  27. # Duplicate some setup bits from target DevStack
  28. source $TARGET_DEVSTACK_DIR/stackrc
  29. source $TARGET_DEVSTACK_DIR/lib/tls
  30. source $TARGET_DEVSTACK_DIR/lib/nova
  31. source $TARGET_DEVSTACK_DIR/lib/neutron-legacy
  32. source $TARGET_DEVSTACK_DIR/lib/apache
  33. source $TARGET_DEVSTACK_DIR/lib/keystone
  34. source $TOP_DIR/openrc admin admin
  35. # Keep track of the DevStack directory
  36. IRONIC_DEVSTACK_DIR=$(dirname "$0")/..
  37. source $IRONIC_DEVSTACK_DIR/lib/ironic
  38. # Print the commands being run so that we can see the command that triggers
  39. # an error. It is also useful for following allowing as the install occurs.
  40. set -o xtrace
  41. function wait_for_keystone {
  42. if ! wait_for_service $SERVICE_TIMEOUT ${KEYSTONE_AUTH_URI}/v$IDENTITY_API_VERSION/; then
  43. die $LINENO "keystone did not start"
  44. fi
  45. }
  46. # Save current config files for posterity
  47. if [[ -d $IRONIC_CONF_DIR ]] && [[ ! -d $SAVE_DIR/etc.ironic ]] ; then
  48. cp -pr $IRONIC_CONF_DIR $SAVE_DIR/etc.ironic
  49. fi
  50. stack_install_service ironic
  51. # calls upgrade-ironic for specific release
  52. upgrade_project ironic $RUN_DIR $BASE_DEVSTACK_BRANCH $TARGET_DEVSTACK_BRANCH
  53. # NOTE(rloo): make sure it is OK to do an upgrade. Except that we aren't
  54. # parsing/checking the output of this command because the output could change
  55. # based on the checks it makes.
  56. $IRONIC_BIN_DIR/ironic-status upgrade check
  57. $IRONIC_BIN_DIR/ironic-dbsync --config-file=$IRONIC_CONF_FILE
  58. # NOTE(vsaienko) pin_release only on multinode job, for cold upgrade (single node)
  59. # run online data migration instead.
  60. if [[ "${HOST_TOPOLOGY}" == "multinode" ]]; then
  61. iniset $IRONIC_CONF_FILE DEFAULT pin_release_version ${BASE_DEVSTACK_BRANCH#*/}
  62. else
  63. ironic-dbsync online_data_migrations
  64. fi
  65. ensure_started='ironic-conductor nova-compute '
  66. ensure_stopped=''
  67. # Multinode grenade is designed to upgrade services only on primary node. And there is no way to manipulate
  68. # subnode during grenade phases. With this after upgrade we can have upgraded (new) services on primary
  69. # node and not upgraded (old) services on subnode.
  70. # According to Ironic upgrade procedure, we shouldn't have upgraded (new) ironic-api and not upgraded (old)
  71. # ironic-conductor. By setting redirect of API requests from primary node to subnode during upgrade
  72. # allow to satisfy ironic upgrade requirements.
  73. if [[ "$HOST_TOPOLOGY_ROLE" == "primary" ]]; then
  74. disable_service ir-api
  75. ensure_stopped+='ironic-api'
  76. ironic_wsgi_conf=$(apache_site_config_for ironic-api-wsgi)
  77. sudo cp $IRONIC_DEVSTACK_FILES_DIR/apache-ironic-api-redirect.template $ironic_wsgi_conf
  78. sudo sed -e "
  79. s|%IRONIC_SERVICE_PROTOCOL%|$IRONIC_SERVICE_PROTOCOL|g;
  80. s|%IRONIC_SERVICE_HOST%|$IRONIC_PROVISION_SUBNET_SUBNODE_IP|g;
  81. " -i $ironic_wsgi_conf
  82. enable_apache_site ipxe-ironic
  83. else
  84. ensure_started+='ironic-api '
  85. fi
  86. start_ironic
  87. # NOTE(vsaienko) do not restart n-cpu on multinode as we didn't upgrade nova.
  88. if [[ "${HOST_TOPOLOGY}" != "multinode" ]]; then
  89. # NOTE(vsaienko) installing ironic service triggers apache restart, that
  90. # may cause nova-compute failure due to LP1537076
  91. stop_nova_compute || true
  92. wait_for_keystone
  93. start_nova_compute
  94. fi
  95. if [[ -n "$ensure_stopped" ]]; then
  96. ensure_services_stopped $ensure_stopped
  97. fi
  98. ensure_services_started $ensure_started
  99. # We need these steps only in case of flat-network
  100. # NOTE(vsaienko) starting from Ocata when Neutron is restarted there is no guarantee that
  101. # internal tag, that was assigned to network will be the same. As result we need to update
  102. # tag on link between br-int and brbm to new value after restart.
  103. if [[ -z "${IRONIC_PROVISION_NETWORK_NAME}" ]]; then
  104. net_id=$(openstack network show ironic_grenade -f value -c id)
  105. create_ovs_taps $net_id
  106. fi
  107. set +o xtrace
  108. echo "*********************************************************************"
  109. echo "SUCCESS: End $0"
  110. echo "*********************************************************************"