mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-01 17:30:26 +08:00
集群增加自动同步时钟选项
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package settings
|
package settings
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils"
|
||||||
@@ -65,6 +66,19 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
}
|
}
|
||||||
this.Data["timeZoneLocation"] = nodeconfigs.FindTimeZoneLocation(cluster.TimeZone)
|
this.Data["timeZoneLocation"] = nodeconfigs.FindTimeZoneLocation(cluster.TimeZone)
|
||||||
|
|
||||||
|
// 时钟
|
||||||
|
var clockConfig = nodeconfigs.DefaultClockConfig()
|
||||||
|
if len(cluster.ClockJSON) > 0 {
|
||||||
|
err = json.Unmarshal(cluster.ClockJSON, clockConfig)
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if clockConfig == nil {
|
||||||
|
clockConfig = nodeconfigs.DefaultClockConfig()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.Data["cluster"] = maps.Map{
|
this.Data["cluster"] = maps.Map{
|
||||||
"id": cluster.Id,
|
"id": cluster.Id,
|
||||||
"name": cluster.Name,
|
"name": cluster.Name,
|
||||||
@@ -72,6 +86,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
"timeZone": cluster.TimeZone,
|
"timeZone": cluster.TimeZone,
|
||||||
"nodeMaxThreads": cluster.NodeMaxThreads,
|
"nodeMaxThreads": cluster.NodeMaxThreads,
|
||||||
"autoOpenPorts": cluster.AutoOpenPorts,
|
"autoOpenPorts": cluster.AutoOpenPorts,
|
||||||
|
"clock": clockConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 默认值
|
// 默认值
|
||||||
@@ -91,6 +106,8 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
TimeZone string
|
TimeZone string
|
||||||
NodeMaxThreads int32
|
NodeMaxThreads int32
|
||||||
AutoOpenPorts bool
|
AutoOpenPorts bool
|
||||||
|
ClockAutoSync bool
|
||||||
|
ClockServer string
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
}) {
|
}) {
|
||||||
@@ -108,7 +125,22 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
Lte(int64(nodeconfigs.DefaultMaxThreadsMax), "单节点最大线程数最大值不能大于"+types.String(nodeconfigs.DefaultMaxThreadsMax))
|
Lte(int64(nodeconfigs.DefaultMaxThreadsMax), "单节点最大线程数最大值不能大于"+types.String(nodeconfigs.DefaultMaxThreadsMax))
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := this.RPC().NodeClusterRPC().UpdateNodeCluster(this.AdminContext(), &pb.UpdateNodeClusterRequest{
|
var clockConfig = nodeconfigs.DefaultClockConfig()
|
||||||
|
clockConfig.AutoSync = params.ClockAutoSync
|
||||||
|
clockConfig.Server = params.ClockServer
|
||||||
|
clockConfigJSON, err := json.Marshal(clockConfig)
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = clockConfig.Init()
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = this.RPC().NodeClusterRPC().UpdateNodeCluster(this.AdminContext(), &pb.UpdateNodeClusterRequest{
|
||||||
NodeClusterId: params.ClusterId,
|
NodeClusterId: params.ClusterId,
|
||||||
Name: params.Name,
|
Name: params.Name,
|
||||||
NodeGrantId: params.GrantId,
|
NodeGrantId: params.GrantId,
|
||||||
@@ -116,6 +148,7 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
TimeZone: params.TimeZone,
|
TimeZone: params.TimeZone,
|
||||||
NodeMaxThreads: params.NodeMaxThreads,
|
NodeMaxThreads: params.NodeMaxThreads,
|
||||||
AutoOpenPorts: params.AutoOpenPorts,
|
AutoOpenPorts: params.AutoOpenPorts,
|
||||||
|
ClockJSON: clockConfigJSON,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
|
|||||||
@@ -60,6 +60,24 @@
|
|||||||
<p class="comment">选中后会自动尝试在边缘节点正在运行的firewalld中开放所需端口;如果有别的防火墙或者安全策略,仍然需要手工操作。</p>
|
<p class="comment">选中后会自动尝试在边缘节点正在运行的firewalld中开放所需端口;如果有别的防火墙或者安全策略,仍然需要手工操作。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="color-border">自动同步节点时钟</td>
|
||||||
|
<td>
|
||||||
|
<div class="ui fields inline">
|
||||||
|
<div class="ui field">
|
||||||
|
<checkbox name="clockAutoSync" v-model="cluster.clock.autoSync"></checkbox>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p class="comment">选中后表示尝试自动同步节点时钟。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr v-show="cluster.clock.autoSync">
|
||||||
|
<td class="color-border">NTP时钟服务器</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" name="clockServer" v-model="cluster.clock.server" maxlength="100"/>
|
||||||
|
<p class="comment">可选项。默认使用<code-label>pool.ntp.org</code-label>。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<submit-btn></submit-btn>
|
<submit-btn></submit-btn>
|
||||||
|
|||||||
Reference in New Issue
Block a user