实现基础的智能调度

This commit is contained in:
刘祥超
2023-05-17 18:41:27 +08:00
parent 275320ad9b
commit c65dffee13
7 changed files with 85 additions and 31 deletions

View File

@@ -187,6 +187,8 @@ func (this *DetailAction) RunGet(params struct {
"route": route.Name,
"value": addr.Ip,
"clusterName": cluster.Name,
"isBackup": dnsInfo.IsBackupForCluster || dnsInfo.IsBackupForGroup,
"isOffline": dnsInfo.IsOffline,
})
}
}
@@ -362,6 +364,10 @@ func (this *DetailAction) RunGet(params struct {
"lnAddrs": lnAddrs,
"enableIPLists": node.EnableIPLists,
"apiNodeAddrs": apiNodeAddrStrings,
"offlineDay": node.OfflineDay,
"isOffline": len(node.OfflineDay) > 0 && node.OfflineDay < timeutil.Format("Ymd"),
"isBackupForCluster": node.IsBackupForCluster,
"isBackupForGroup": node.IsBackupForGroup,
"status": maps.Map{
"isActive": status.IsActive,

View File

@@ -136,6 +136,8 @@ func (this *ClusterAction) RunGet(params struct {
"clusterId": node.NodeClusterId,
"isResolved": isResolved,
"isInstalled": isInstalled,
"isBackup": node.IsBackupForCluster || node.IsBackupForGroup,
"isOffline": node.IsOffline,
})
}
} else {
@@ -171,6 +173,8 @@ func (this *ClusterAction) RunGet(params struct {
"clusterId": node.NodeClusterId,
"isResolved": isResolved,
"isInstalled": isInstalled,
"isBackup": node.IsBackupForCluster || node.IsBackupForGroup,
"isOffline": node.IsOffline,
})
}
}

View File

@@ -1,5 +1,5 @@
Vue.component("time-duration-box", {
props: ["v-name", "v-value", "v-count", "v-unit"],
props: ["name", "v-name", "v-value", "v-count", "v-unit"],
mounted: function () {
this.change()
},
@@ -14,9 +14,18 @@ Vue.component("time-duration-box", {
if (typeof (v["count"]) != "number") {
v["count"] = -1
}
let realName = ""
if (typeof this.name == "string" && this.name.length > 0) {
realName = this.name
} else if (typeof this.vName == "string" && this.vName.length > 0) {
realName = this.vName
}
return {
duration: v,
countString: (v.count >= 0) ? v.count.toString() : ""
countString: (v.count >= 0) ? v.count.toString() : "",
realName: realName
}
},
watch: {
@@ -39,7 +48,7 @@ Vue.component("time-duration-box", {
}
},
template: `<div class="ui fields inline" style="padding-bottom: 0; margin-bottom: 0">
<input type="hidden" :name="vName" :value="JSON.stringify(duration)"/>
<input type="hidden" :name="realName" :value="JSON.stringify(duration)"/>
<div class="ui field">
<input type="text" v-model="countString" maxlength="11" size="11" @keypress.enter.prevent="1"/>
</div>

View File

@@ -95,6 +95,16 @@ Vue.component("message-row", {
<div v-if="message.type == 'serverNamesRequireAuditing'" style="margin-top: 0.8em">
<a :href="'/servers/server/settings/serverNames?serverId=' + params.serverId" target="_top">去审核</a></a>
</div>
<!-- 节点调度 -->
<div v-if="message.type == 'NodeSchedule'" style="margin-top: 0.8em">
<a :href="'/clusters/cluster/node/settings/schedule?clusterId=' + message.cluster.id + '&nodeId=' + message.node.id" target="_top">查看调度状态 &raquo;</a>
</div>
<!-- 节点租期结束 -->
<div v-if="message.type == 'NodeOfflineDay'" style="margin-top: 0.8em">
<a :href="'/clusters/cluster/node/detail?clusterId=' + message.cluster.id + '&nodeId=' + message.node.id" target="_top">查看详情 &raquo;</a>
</div>
</td>
</tr>
</table>

View File

@@ -16,6 +16,21 @@
<td>
<node-clusters-labels :v-primary-cluster="node.cluster" :v-secondary-clusters="node.secondaryClusters"></node-clusters-labels>
</td>
</tr>
<tr v-show="node.isBackupForCluster || node.isBackupForGroup">
<td>备用节点</td>
<td>
<span class="ui label basic small" v-if="node.isBackupForCluster">集群备用节点</span>
<span class="ui label basic small" v-if="node.isBackupForGroup">分组备用节点</span>
&nbsp; <a :href="'/clusters/cluster/node/settings/schedule?clusterId=' + clusterId + '&nodeId=' + node.id" style="font-size: 0.8em">[修改]</a>
</td>
</tr>
<tr v-show="node.offlineDay.length > 0">
<td>租期结束日期</td>
<td>
{{node.offlineDay.substring(0, 4)}}-{{node.offlineDay.substring(4, 6)}}-{{node.offlineDay.substring(6, 8)}} &nbsp; <a :href="'/clusters/cluster/node/settings/schedule?clusterId=' + clusterId + '&nodeId=' + node.id" style="font-size: 0.8em">[修改]</a>
<p class="comment" v-if="node.isOffline"><span class="red">已到期</span></p>
</td>
</tr>
<tr>
<td>IP地址</td>
@@ -60,6 +75,7 @@
<th>记录类型</th>
<th>线路</th>
<th>记录值</th>
<th>状态</th>
</tr>
</thead>
@@ -72,6 +88,11 @@
<span v-else class="disabled">默认</span>
</td>
<td>{{record.value}}</td>
<td>
<span v-if="record.isBackup" class="red">备用节点</span>
<span v-else-if="record.isOffline" class="red">已下线</span>
<span v-else>正常</span>
</td>
</tr>
</table>
<p class="comment" v-if="!dnsIsExcludingLnNode">通过设置A记录可以将集群上的服务请求转发到不同线路的节点上。</p>

View File

@@ -67,7 +67,7 @@
</thead>
<tr v-for="task in tasks">
<td>
<span v-if="task.type == 'clusterChange'">{{task.cluster.name}}
<span v-if="(task.type == 'clusterChange' || task.type == 'clusterNodesChange') && task.cluster != null">{{task.cluster.name}}
<link-icon :href="'/dns/clusters/cluster?clusterId=' + task.cluster.id" target="_top"></link-icon>
</span>
<span v-if="task.type == 'nodeChange'">{{task.node.name}}</span>
@@ -75,7 +75,7 @@
<span v-if="task.type == 'domainChange'">{{task.domain.name}}</span>
</td>
<td>
<span v-if="task.type == 'clusterChange'">集群</span>
<span v-if="task.type == 'clusterChange' || task.type == 'clusterNodesChange'">集群</span>
<span v-if="task.type == 'nodeChange'">节点</span>
<span v-if="task.type == 'serverChange'">服务</span>
<span v-if="task.type == 'domainChange'">域名</span>
@@ -164,11 +164,15 @@
<link-red v-else title="点击设置" @click.prevent="updateNode(node.clusterId, node.id, node.ipAddrId)">没有设置</link-red>
</td>
<td>
<span v-if="node.isBackup" class="red">备用节点</span>
<span v-else-if="node.isOffline" class="red">已下线</span>
<div v-else="">
<span v-if="node.isInstalled">
<span class="green" v-if="node.isResolved">已解析</span>
<span v-else class="red">未解析</span>
</span>
<link-red :href="'/clusters/cluster/node/install?clusterId=' + cluster.id + '&nodeId=' + node.id" v-if="!node.isInstalled" title="节点未安装"><span class="red">未安装</span></link-red>
</div>
</td>
<td>
<link-popup @click.prevent="updateNode(node.clusterId, node.id, node.ipAddrId)">修改</link-popup>

View File

@@ -15,7 +15,7 @@
</thead>
<tr v-for="task in tasks">
<td nowrap="">
<span v-if="(task.type == 'clusterChange' || task.type == 'clusterRemoveDomain') && task.cluster != null">{{task.cluster.name}}
<span v-if="(task.type == 'clusterChange' || task.type == 'clusterNodesChange' || task.type == 'clusterRemoveDomain') && task.cluster != null">{{task.cluster.name}}
<link-icon :href="'/dns/clusters/cluster?clusterId=' + task.cluster.id" target="_top"></link-icon>
</span>
<span v-if="task.type == 'nodeChange'">{{task.node.name}}</span>
@@ -23,7 +23,7 @@
<span v-if="task.type == 'domainChange'">{{task.domain.name}}</span>
</td>
<td nowrap="">
<span v-if="task.type == 'clusterChange' || task.type == 'clusterRemoveDomain'">集群</span>
<span v-if="task.type == 'clusterChange' || task.type == 'clusterNodesChange' || task.type == 'clusterRemoveDomain'">集群</span>
<span v-if="task.type == 'nodeChange'">节点</span>
<span v-if="task.type == 'serverChange'">服务</span>
<span v-if="task.type == 'domainChange'">域名</span>