From 11a1215cde90125530f60739763a38fb29b1f1f1 Mon Sep 17 00:00:00 2001 From: zeaslity Date: Wed, 8 Nov 2023 17:13:52 +0800 Subject: [PATCH] [Agent] [init] update initializaiton --- .run/go build agent-go.run.xml | 24 +++++++++++------------- agent-go/AgentInitialization.go | 29 +++++++++++++++-------------- agent-go/server-env.yaml | 9 +++++---- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/.run/go build agent-go.run.xml b/.run/go build agent-go.run.xml index 2bb4a79..e56510f 100644 --- a/.run/go build agent-go.run.xml +++ b/.run/go build agent-go.run.xml @@ -1,15 +1,13 @@ - - - - - - - - - - - + + + + + + + + + + + \ No newline at end of file diff --git a/agent-go/AgentInitialization.go b/agent-go/AgentInitialization.go index 2c75c5d..3cc8175 100644 --- a/agent-go/AgentInitialization.go +++ b/agent-go/AgentInitialization.go @@ -172,40 +172,41 @@ func shutdownRegisterQueueConnection(initFromServerQueue *rabbitmq.RabbitQueue, func parseAgentServerInfo(agentServerInfoConf string) *register.AgentServerInfo { // 约定文件地址为 /octopus-agent/octopus-agent.conf - var agentServerInfo register.AgentServerInfo + var agentServerInfo *register.AgentServerInfo yamlFile, err := ioutil.ReadFile(agentServerInfoConf) if err != nil { panic(fmt.Errorf("failed to read YAML file: %v", err)) } - err = yaml.Unmarshal(yamlFile, agentServerInfo) + err = yaml.Unmarshal(yamlFile, &agentServerInfo) if err != nil { panic(fmt.Errorf("failed to unmarshal YAML: %v", err)) } - jsonFormat, err := json.Marshal(agentServerInfo) - if err != nil { - log.Error(fmt.Sprintf("agent server info convert error ! agentserverinfo is %v", agentServerInfo)) - panic(err) - } - log.Info(fmt.Sprintf("agent server info is %v", string(jsonFormat))) - // uniform agent server info UniformAgentServerInfo(agentServerInfo) // build operator cache BuildAgentOsOperator(agentServerInfo) - return &agentServerInfo + jsonFormat, err := json.Marshal(&agentServerInfo) + if err != nil { + log.Error(fmt.Sprintf("agent server info convert error ! agentserverinfo is %v", agentServerInfo)) + panic(err) + } + log.Info(fmt.Sprintf("agent server info is %v", string(jsonFormat))) + + return agentServerInfo } // UniformAgentServerInfo uniform deal with ip -func UniformAgentServerInfo(agentServerInfo register.AgentServerInfo) { +func UniformAgentServerInfo(agentServerInfo *register.AgentServerInfo) { // reflect to iterator all field log.Info("[Initialization] - UniformAgentServerInfo !") - value := reflect.ValueOf(agentServerInfo) + value := reflect.ValueOf(agentServerInfo).Elem() + for i := 0; i < value.NumField(); i++ { field := value.Field(i) if field.Kind() == reflect.String && field.CanSet() { @@ -224,7 +225,7 @@ func UniformAgentServerInfo(agentServerInfo register.AgentServerInfo) { } -func BuildAgentOsOperator(agentServerInfo register.AgentServerInfo) { +func BuildAgentOsOperator(agentServerInfo *register.AgentServerInfo) { // 2023年8月4日 passthrough some key information ossOfflinePrefix := g.G.AgentConfig.GetString("octopus.agent.executor.ossOfflinePrefix") @@ -236,7 +237,7 @@ func BuildAgentOsOperator(agentServerInfo register.AgentServerInfo) { agentOsOperator := executor.BuildAgentOsOperator(agentServerInfo.OSInfo, ossOfflinePrefix) // assign the agentServerInfo - agentOsOperator.AgentServerInfo = &agentServerInfo + agentOsOperator.AgentServerInfo = agentServerInfo // debug marshal, _ := json.Marshal(agentOsOperator) diff --git a/agent-go/server-env.yaml b/agent-go/server-env.yaml index 2144b59..4a0900c 100644 --- a/agent-go/server-env.yaml +++ b/agent-go/server-env.yaml @@ -12,11 +12,12 @@ memoryTotal: "7.6 GB" diskTotal: "914.9 GB" diskUsage: "12.3 GB" archInfo: "x86_64 (64 Bit)" -osInfo: "Ubuntu 20.04.5 LTS" +osInfo: " +Ubuntu 20.04.5 LTS" osKernelInfo: "5.4.0-135-generic" -tcpControl: "cubic" +tcpControl: "cubic " virtualization: "Dedicated" -ioSpeed: "150 MB/s" -machineId: "fakemachinid123" +ioSpeed: "150 MB/s " +machineId: "fakemachinid123 " agentVersion: "" topicName: ""