From 0841218191367f98ada5d2a6492b5f5ab6b7e686 Mon Sep 17 00:00:00 2001 From: starsliao Date: Tue, 10 Oct 2023 01:02:23 +0800 Subject: [PATCH] 1.0.2 --- flask-consul/manager.py | 16 +++++++++------- flask-consul/units/consul_manager.py | 14 ++++++++++++++ vue-consul/src/main.js | 2 +- vue-consul/src/views/dashboard/index.vue | 9 +++++++++ 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/flask-consul/manager.py b/flask-consul/manager.py index e1e22de..a8a13d4 100755 --- a/flask-consul/manager.py +++ b/flask-consul/manager.py @@ -1,18 +1,20 @@ #!/usr/bin/env python3 from flask import Flask -from units import consul_kv -import uuid +from units import consul_kv,consul_manager +import uuid,sys from units.config_log import * +if consul_manager.get_consul_ver() == False: + sys.exit("请求consul异常, 程序退出.") - -skey_path = 'ConsulManager/assets/secret/skey' -if consul_kv.get_kv_dict(skey_path) == {}: +skey_path = 'ConsulManager/assets/secret/' +if consul_kv.get_kv_dict(skey_path + 'skey') == {}: from datetime import datetime now = datetime.strftime(datetime.now(), '%Y-%m-%d_%H-%M-%S') skeyuid = ''.join(str(uuid.uuid4()).split('-')) - consul_kv.put_kv(skey_path,{'sk':skeyuid}) - consul_kv.put_kv(skey_path + now,{'sk':skeyuid}) + consul_kv.put_kv(skey_path + 'skey',{'sk':skeyuid}) + consul_kv.put_kv(f'{skey_path}bak-skey{now}',{'sk':skeyuid}) + logger.warning(f"【初始化SKey完成】") from views import login, blackbox, consul, jobs, nodes, selfnode, selfrds, selfredis, avd, exp, jms, edit_cloud, ldap, rds, redis from views.prom import cloud_metrics diff --git a/flask-consul/units/consul_manager.py b/flask-consul/units/consul_manager.py index 72ba96b..755160e 100644 --- a/flask-consul/units/consul_manager.py +++ b/flask-consul/units/consul_manager.py @@ -4,6 +4,20 @@ headers = {'X-Consul-Token': consul_token} +def get_consul_ver(): + url = f'{consul_url}/operator/autopilot/state' + response = requests.get(url, headers=headers, timeout=2) + response.encoding='utf-8' + if response.status_code == 200: + logger.info(f'【consul】请求成功, 认证成功: {consul_url} ') + return True + elif response.status_code == 403: + logger.error(f'【consul】连接正常: {consul_url}【认证失败】请检查consul token!') + return False + else: + logger.error(f'【consul】连接失败 {response.status_code}: {consul_url}, 请检查consul状态以及网络是否正常!') + return False + def get_hosts(): url = f'{consul_url}/agent/host' response = requests.get(url, headers=headers) diff --git a/vue-consul/src/main.js b/vue-consul/src/main.js index 6b77a6e..384f532 100644 --- a/vue-consul/src/main.js +++ b/vue-consul/src/main.js @@ -46,7 +46,7 @@ Object.keys(filters).forEach(key => { }) Vue.config.productionTip = false -Vue.prototype.VER = 'v1.0.1' +Vue.prototype.VER = 'v1.0.2' new Vue({ el: '#app', diff --git a/vue-consul/src/views/dashboard/index.vue b/vue-consul/src/views/dashboard/index.vue index c6934f4..3b1eec7 100644 --- a/vue-consul/src/views/dashboard/index.vue +++ b/vue-consul/src/views/dashboard/index.vue @@ -7,6 +7,15 @@ 🚀StarsL.cn + + +

v1.0.2

+

修复K8S部署consul无法持久化KV信息的bug【查看明细】

+

修复同步阿里云Redis实例报错"失败:'EndTime'"的bug

+

修复采集RDS会采集到非MySql数据库的bug

+

优化启动后端检查consul状态和初始化skey的逻辑

+
+

v1.0.1