Skip to content

Commit

Permalink
chore: add version and distribution for agent to avoid painc at start (
Browse files Browse the repository at this point in the history
…#131)

* chore: add version and distribution for agent to avoid painc at start

* docs: add release notes

* docs: typo release notes

---------

Co-authored-by: hardy <[email protected]>
  • Loading branch information
luohoufu and luohf-infinilabs authored Feb 14, 2025
1 parent ea73bf9 commit b443823
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
2 changes: 2 additions & 0 deletions config/setup/common/data/task_config_tpl.dat
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ elasticsearch:
name: $[[TASK_ID]]
cluster_uuid: $[[CLUSTER_UUID]]
enabled: true
distribution: $[[CLUSTER_DISTRIBUTION]]
version: $[[CLUSTER_VERSION]]
endpoints: $[[CLUSTER_ENDPOINT]]
discovery:
enabled: false
Expand Down
1 change: 1 addition & 0 deletions docs/content.en/docs/release-notes/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Information about release notes of INFINI Console is provided here.
- Add credential settings for agent in enrolling agent
- Add collection mode to cluster editing
- Add default roles to fix the issue (#114) (#130)
- Add agent connection config with `version` and `distribution` to avoid panic at start(#131)

## 1.28.1 (2025-01-24)

Expand Down
1 change: 1 addition & 0 deletions docs/content.zh/docs/release-notes/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ title: "版本历史"
- 在集群编辑中新增采集模式
- 当使用 Easysearch 存储指标时,自动为系统集群创建 Agent 指标写入最小权限用户 (#120)
- 修复 LDAP 用户映射增加默认权限组 (#114) (#130)
- Agent 连接 Easysearch 的配置信息中增加 `version``distribution` 来解决启动时退出问题 (#131)

## 1.28.1 (2025-01-24)

Expand Down
43 changes: 26 additions & 17 deletions modules/agent/api/remote_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,30 @@ func getAgentIngestConfigs(instance string, items map[string]BindingItem) (strin

var username = ""
var password = ""
var version = ""
var distribution = ""

if metadata.Config.AgentCredentialID != "" {
credential, err := common2.GetCredential(metadata.Config.AgentCredentialID)
if err != nil {
log.Error(err)
continue
}
var dv interface{}
dv, err = credential.Decode()
if err != nil {
log.Error(err)
continue
}
if auth, ok := dv.(model.BasicAuth); ok {
username = auth.Username
password = auth.Password.Get()
if metadata.Config != nil {

version = metadata.Config.Version
distribution = metadata.Config.Distribution

if metadata.Config.AgentCredentialID != "" {
credential, err := common2.GetCredential(metadata.Config.AgentCredentialID)
if err != nil {
log.Error(err)
continue
}
var dv interface{}
dv, err = credential.Decode()
if err != nil {
log.Error(err)
continue
}
if auth, ok := dv.(model.BasicAuth); ok {
username = auth.Username
password = auth.Password.Get()
}
}
}

Expand All @@ -238,20 +246,21 @@ func getAgentIngestConfigs(instance string, items map[string]BindingItem) (strin
}

taskID := v.ClusterID + "_" + v.NodeUUID

buffer.Write([]byte(fmt.Sprintf("\n - name: \"%v\"\n path: ./config/task_config.tpl\n "+
"variable:\n "+
"TASK_ID: %v\n "+
"CLUSTER_ID: %v\n "+
"CLUSTER_UUID: %v\n "+
"NODE_UUID: %v\n "+
"CLUSTER_VERSION: %v\n "+
"CLUSTER_DISTRIBUTION: %v\n "+
"CLUSTER_ENDPOINT: [\"%v\"]\n "+
"CLUSTER_USERNAME: \"%v\"\n "+
"CLUSTER_PASSWORD: \"%v\"\n "+
"CLUSTER_LEVEL_TASKS_ENABLED: %v\n "+
"NODE_LEVEL_TASKS_ENABLED: %v\n "+
"NODE_LOGS_PATH: \"%v\"\n\n\n", taskID, taskID,
v.ClusterID, v.ClusterUUID, v.NodeUUID, nodeEndPoint, username, password, clusterLevelEnabled, nodeLevelEnabled, pathLogs)))
v.ClusterID, v.ClusterUUID, v.NodeUUID, version, distribution, nodeEndPoint, username, password, clusterLevelEnabled, nodeLevelEnabled, pathLogs)))
}

hash := util.MD5digest(buffer.String())
Expand Down

0 comments on commit b443823

Please sign in to comment.