master-restart 756 B

1234567891011121314151617181920212223242526
  1. #!/bin/bash
  2. set -euo pipefail
  3. # Restart the named component by stopping its base container.
  4. if [[ -z "${1-}" ]]; then
  5. echo "A component name like 'api', 'etcd', or 'controllers' must be specified." 1>&2
  6. exit 1
  7. fi
  8. types=( "atomic-openshift" "origin" )
  9. for type in "${types[@]}"; do
  10. if systemctl cat "${type}-master-${1}.service" &>/dev/null; then
  11. systemctl restart "${type}-master-${1}.service"
  12. exit 0
  13. fi
  14. done
  15. # TODO: move to cri-ctl
  16. # TODO: short term hack for cri-o
  17. container=$(docker ps -l -q --filter "label=openshift.io/component=${1}" --filter "label=io.kubernetes.container.name=POD")
  18. if [[ -z "${container}" ]]; then
  19. echo "Component ${1} is already stopped" 1>&2
  20. exit 0
  21. fi
  22. exec docker stop "${container}" --time 30 >/dev/null