Debian Codegraph @

tools/run_tests/xds_k8s_test_driver/bin/cleanup/namespace.py

raw
1 # Copyright 2022 gRPC authors.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 """Clean up GKE namespaces leaked by the tests."""
15
16 from absl import app
17
18 from bin.cleanup import cleanup
19 from framework import xds_flags
20 from framework import xds_k8s_flags
21
22
23 def main(argv):
24 if len(argv) > 1:
25 raise app.UsageError('Too many command-line arguments.')
26 cleanup.load_keep_config()
27
28 # Must be called before KubernetesApiManager or GcpApiManager init.
29 xds_flags.set_socket_default_timeout_from_flag()
30
31 project: str = xds_flags.PROJECT.value
32 network: str = xds_flags.NETWORK.value
33 gcp_service_account: str = xds_k8s_flags.GCP_SERVICE_ACCOUNT.value
34 dry_run: bool = cleanup.DRY_RUN.value
35
36 cleanup.find_and_remove_leaked_k8s_resources(dry_run, project, network,
37 gcp_service_account)
38
39
40 if __name__ == '__main__':
41 app.run(main)