[improvement](doris compose) show all cluster (#28288)

This commit is contained in:
yujun
2023-12-13 01:35:41 +08:00
committed by GitHub
parent eda2818b95
commit bb4c192a57
3 changed files with 22 additions and 21 deletions

View File

@ -83,14 +83,12 @@ python docker/runtime/doris-compose/doris-compose.py restart <cluster-name> --
### List doris cluster
```
python docker/runtime/doris-compose/doris-compose.py ls <-a> <multiple cluster names>
python docker/runtime/doris-compose/doris-compose.py ls <multiple cluster names>
```
if specific cluster names, it will list all the cluster's nodes.
Otherwise it will just list summary of each clusters. If not specific -a, it will list only active clusters.
If specific `-a`, it will list the unactive clusters too.
Otherwise it will just list summary of each clusters.
There are more options about doris-compose. Just try

View File

@ -78,6 +78,19 @@ def gen_subnet_prefix16():
raise Exception("Failed to gen subnet")
def get_master_fe_endpoint(cluster_name):
master_fe_ip_file = get_cluster_path(cluster_name) + "/status/master_fe_ip"
if os.path.exists(master_fe_ip_file):
with open(master_fe_ip_file, "r") as f:
return "{}:{}".format(f.read().strip(), FE_QUERY_PORT)
try:
cluster = Cluster.load(cluster_name)
return "{}:{}".format(
cluster.get_node(Node.TYPE_FE, 1).get_ip(), FE_QUERY_PORT)
except:
return ""
class NodeMeta(object):
def __init__(self, image):

View File

@ -269,14 +269,10 @@ class UpCommand(Command):
utils.exec_docker_compose_command(cluster.get_compose_file(), "up",
options, related_nodes)
master_fe_ip_file = cluster.get_path() + "/status/master_fe_ip"
master_fe_ip = ""
if os.path.exists(master_fe_ip_file):
master_fe_ip = open(master_fe_ip_file, "r").read().strip()
else:
master_fe_ip = cluster.get_node(CLUSTER.Node.TYPE_FE, 1).get_ip()
LOG.info("Master fe query address: " + utils.render_green(
"{}:{}".format(master_fe_ip, CLUSTER.FE_QUERY_PORT)) + "\n")
LOG.info(
"Master fe query address: " +
utils.render_green(CLUSTER.get_master_fe_endpoint(cluster.name)) +
"\n")
if not args.start:
LOG.info(
@ -491,12 +487,6 @@ class ListCommand(Command):
"Specify multiple clusters, if specific, show all their containers."
)
self._add_parser_output_json(parser)
parser.add_argument(
"-a",
"--all",
default=False,
action=self._get_parser_bool_action(True),
help="Show all clusters, include stopped or bad clusters.")
parser.add_argument("--detail",
default=False,
action=self._get_parser_bool_action(True),
@ -576,7 +566,8 @@ class ListCommand(Command):
TYPE_COMPOSESERVICE = type(ComposeService("", "", ""))
if not args.NAME:
header = ("CLUSTER", "OWNER", "STATUS", "CONFIG FILES")
header = ("CLUSTER", "OWNER", "STATUS", "MASTER FE",
"CONFIG FILES")
rows = []
for name in sorted(clusters.keys()):
cluster_info = clusters[name]
@ -590,11 +581,10 @@ class ListCommand(Command):
"{}({})".format(status, count)
for status, count in service_statuses.items()
])
if not args.all and service_statuses.get("running", 0) == 0:
continue
owner = utils.get_path_owner(CLUSTER.get_cluster_path(name))
compose_file = CLUSTER.get_compose_file(name)
rows.append((name, owner, show_status,
CLUSTER.get_master_fe_endpoint(name),
"{}{}".format(compose_file,
cluster_info["status"])))
return self._handle_data(header, rows)