[Agent] [Octopus] - caqa fix bugs

This commit is contained in:
zeaslity
2024-01-30 15:54:33 +08:00
parent a471dabe46
commit 36c650301e
15 changed files with 327 additions and 47 deletions

View File

@@ -1946,9 +1946,12 @@ func (op *AgentOsOperator) installChronyByDockerExec(funcArgs []string) (bool, [
"--name=chrony",
"--restart=always",
"--detach",
"--cap-add=SYS_TIME",
"--publish=123:123/udp",
"--env=NTP_SERVERS=\"ntp1.aliyun.com,ntp2.aliyun.com,ntp3.aliyun.com,ntp4.aliyun.com\"",
"--env=LOG_LEVEL=0",
"--env=TZ=Asia/Shanghai",
"--env=ENABLE_SYSCLK=true",
funcArgs[0] + ":8033/cmii/chronyd:0.4.3",
})
if !ok {

View File

@@ -257,6 +257,7 @@ func (hOp *HarborOperator) SyncProjectExec(funcArgs []string) (bool, []string) {
}
}
// todo cqga failed
octopusSourceRegistry := &model.Registry{
Credential: &model.RegistryCredential{
AccessKey: "admin",
@@ -264,24 +265,23 @@ func (hOp *HarborOperator) SyncProjectExec(funcArgs []string) (bool, []string) {
Type: "basic",
},
Insecure: true,
ID: 7,
Name: OctopusSourceHarborName, // 源 Harbor 实例的注册表 ID通常为 0
Type: "harbor",
URL: strings.Split(hOp.SourceHarborHost, "/api")[0],
}
err := targetClient.NewRegistry(ctx, octopusSourceRegistry)
if err != nil {
return false, []string{
"[Harbor Sync Project ] - source endpoints create failed !",
}
sprintf := fmt.Sprintf("[SyncProjectExec] - source endpoints create failed ! => %s", err.Error())
log.Error(sprintf)
return false, []string{sprintf}
}
// get the real one for it's ID
realOctopusSourceRegistry, err := targetClient.GetRegistryByName(ctx, OctopusSourceHarborName)
if err != nil {
return false, []string{
"[Harbor Sync Project ] - source endpoints get failed !",
}
sprintf := fmt.Sprintf("[SyncProjectExec] - get target registry id failed ! => %s", err.Error())
log.Error(sprintf)
return false, []string{sprintf}
}
// 创建复制策略

View File

@@ -10,6 +10,7 @@ import (
"strconv"
"strings"
"time"
"wdd.io/agent-go/utils"
)
type NetworkMetric struct {
@@ -165,6 +166,18 @@ func GetNetworkInfo() ([]NetworkInfo, error) {
return result, nil
}
func GetLocalHostIP() string {
interfaceStatList, err := net.Interfaces()
if err != nil {
log.ErrorF("[GetLocalHostIP] -- error %s", err.Error())
return ""
}
utils.BeautifulPrint(interfaceStatList)
return ""
}
func GetNetworkConnectionALl() []net.ConnectionStat {
connections, err := net.Connections("all")