Skip to content

Commit b443823

Browse files
chore: add version and distribution for agent to avoid painc at start (#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]>
1 parent ea73bf9 commit b443823

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

config/setup/common/data/task_config_tpl.dat

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ elasticsearch:
66
name: $[[TASK_ID]]
77
cluster_uuid: $[[CLUSTER_UUID]]
88
enabled: true
9+
distribution: $[[CLUSTER_DISTRIBUTION]]
10+
version: $[[CLUSTER_VERSION]]
911
endpoints: $[[CLUSTER_ENDPOINT]]
1012
discovery:
1113
enabled: false

docs/content.en/docs/release-notes/_index.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Information about release notes of INFINI Console is provided here.
2626
- Add credential settings for agent in enrolling agent
2727
- Add collection mode to cluster editing
2828
- Add default roles to fix the issue (#114) (#130)
29+
- Add agent connection config with `version` and `distribution` to avoid panic at start(#131)
2930

3031
## 1.28.1 (2025-01-24)
3132

docs/content.zh/docs/release-notes/_index.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ title: "版本历史"
2424
- 在集群编辑中新增采集模式
2525
- 当使用 Easysearch 存储指标时,自动为系统集群创建 Agent 指标写入最小权限用户 (#120)
2626
- 修复 LDAP 用户映射增加默认权限组 (#114) (#130)
27+
- Agent 连接 Easysearch 的配置信息中增加 `version``distribution` 来解决启动时退出问题 (#131)
2728

2829
## 1.28.1 (2025-01-24)
2930

modules/agent/api/remote_config.go

+26-17
Original file line numberDiff line numberDiff line change
@@ -197,22 +197,30 @@ func getAgentIngestConfigs(instance string, items map[string]BindingItem) (strin
197197

198198
var username = ""
199199
var password = ""
200+
var version = ""
201+
var distribution = ""
200202

201-
if metadata.Config.AgentCredentialID != "" {
202-
credential, err := common2.GetCredential(metadata.Config.AgentCredentialID)
203-
if err != nil {
204-
log.Error(err)
205-
continue
206-
}
207-
var dv interface{}
208-
dv, err = credential.Decode()
209-
if err != nil {
210-
log.Error(err)
211-
continue
212-
}
213-
if auth, ok := dv.(model.BasicAuth); ok {
214-
username = auth.Username
215-
password = auth.Password.Get()
203+
if metadata.Config != nil {
204+
205+
version = metadata.Config.Version
206+
distribution = metadata.Config.Distribution
207+
208+
if metadata.Config.AgentCredentialID != "" {
209+
credential, err := common2.GetCredential(metadata.Config.AgentCredentialID)
210+
if err != nil {
211+
log.Error(err)
212+
continue
213+
}
214+
var dv interface{}
215+
dv, err = credential.Decode()
216+
if err != nil {
217+
log.Error(err)
218+
continue
219+
}
220+
if auth, ok := dv.(model.BasicAuth); ok {
221+
username = auth.Username
222+
password = auth.Password.Get()
223+
}
216224
}
217225
}
218226

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

240248
taskID := v.ClusterID + "_" + v.NodeUUID
241-
242249
buffer.Write([]byte(fmt.Sprintf("\n - name: \"%v\"\n path: ./config/task_config.tpl\n "+
243250
"variable:\n "+
244251
"TASK_ID: %v\n "+
245252
"CLUSTER_ID: %v\n "+
246253
"CLUSTER_UUID: %v\n "+
247254
"NODE_UUID: %v\n "+
255+
"CLUSTER_VERSION: %v\n "+
256+
"CLUSTER_DISTRIBUTION: %v\n "+
248257
"CLUSTER_ENDPOINT: [\"%v\"]\n "+
249258
"CLUSTER_USERNAME: \"%v\"\n "+
250259
"CLUSTER_PASSWORD: \"%v\"\n "+
251260
"CLUSTER_LEVEL_TASKS_ENABLED: %v\n "+
252261
"NODE_LEVEL_TASKS_ENABLED: %v\n "+
253262
"NODE_LOGS_PATH: \"%v\"\n\n\n", taskID, taskID,
254-
v.ClusterID, v.ClusterUUID, v.NodeUUID, nodeEndPoint, username, password, clusterLevelEnabled, nodeLevelEnabled, pathLogs)))
263+
v.ClusterID, v.ClusterUUID, v.NodeUUID, version, distribution, nodeEndPoint, username, password, clusterLevelEnabled, nodeLevelEnabled, pathLogs)))
255264
}
256265

257266
hash := util.MD5digest(buffer.String())

0 commit comments

Comments
 (0)