cleanup.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/env bash
  2. # Copyright 2021 gRPC authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. set -eo pipefail
  16. display_usage() {
  17. cat <<EOF >/dev/stderr
  18. Performs full TD and K8S resource cleanup
  19. USAGE: $0 [--nosecure] [arguments]
  20. --nosecure: Skip cleanup for the resources specific for PSM Security
  21. arguments ...: additional arguments passed to ./run.sh
  22. ENVIRONMENT:
  23. XDS_K8S_CONFIG: file path to the config flagfile, relative to
  24. driver root folder. Default: config/local-dev.cfg
  25. Will be appended as --flagfile="config_absolute_path" argument
  26. XDS_K8S_DRIVER_VENV_DIR: the path to python virtual environment directory
  27. Default: $XDS_K8S_DRIVER_DIR/venv
  28. EXAMPLES:
  29. $0
  30. $0 --secure
  31. XDS_K8S_CONFIG=./path-to-flagfile.cfg $0 --resource_suffix=override-suffix
  32. EOF
  33. exit 1
  34. }
  35. if [[ "$1" == "-h" || "$1" == "--help" ]]; then
  36. display_usage
  37. fi
  38. SCRIPT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
  39. readonly SCRIPT_DIR
  40. readonly XDS_K8S_DRIVER_DIR="${SCRIPT_DIR}/.."
  41. cd "${XDS_K8S_DRIVER_DIR}"
  42. if [[ "$1" == "--nosecure" ]]; then
  43. shift
  44. ./run.sh bin/run_td_setup.py --cmd=cleanup "$@" && \
  45. ./run.sh bin/run_test_client.py --cmd=cleanup --cleanup_namespace "$@" && \
  46. ./run.sh bin/run_test_server.py --cmd=cleanup --cleanup_namespace "$@"
  47. else
  48. ./run.sh bin/run_td_setup.py --cmd=cleanup --security=mtls "$@" && \
  49. ./run.sh bin/run_test_client.py --cmd=cleanup --cleanup_namespace --secure "$@" && \
  50. ./run.sh bin/run_test_server.py --cmd=cleanup --cleanup_namespace --secure "$@"
  51. fi