From f672c2b885200f54dd868a2758f550ce5386cb06 Mon Sep 17 00:00:00 2001 From: Quyc <94251049@qq.com> Date: Tue, 15 Aug 2023 15:10:21 +0800 Subject: [PATCH] fix: if there is no cluster to create a default cluster (#1381) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 曲源成 --- console/views/team.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/console/views/team.py b/console/views/team.py index a3669d0003..3e8b6d7b50 100644 --- a/console/views/team.py +++ b/console/views/team.py @@ -553,6 +553,17 @@ def get(self, request, *args, **kwargs): except region_api.CallApiError as e: logger.warning("数据中心{0}不可达,无法获取相关信息: {1}".format(self.response_region.region_name, e.message)) ent["is_enterprise"] = is_ent + regions = region_repo.get_regions_by_enterprise_id(self.enterprise.enterprise_id, 1) + default_region = {} + if os.getenv("ENABLE_CLUSTER") == "true" and not regions: + region = region_services.create_default_region(self.enterprise.enterprise_id, request.user) + if region: + ent["disable_install_cluster_log"] = True + _, total = team_services.get_enterprise_teams(self.enterprise.enterprise_id) + if total == 0: + region_services.create_sample_application(enter, region, request.user) + default_region = region.to_dict() + ent["default_region"] = default_region result = general_message(200, "success", "查询成功", bean=ent) return Response(result, status=result["code"])