Skip to content

Commit d3b20c8

Browse files
authored
Merge pull request #332 from eclipse-pullpiri/hotfix-nodeinfo
Hotfix nodeinfo
2 parents f285bb4 + 11795df commit d3b20c8

File tree

15 files changed

+76
-73
lines changed

15 files changed

+76
-73
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ install:
6363
-mkdir -p /etc/containers/systemd/piccolo/etcd-data/
6464
-cp -r ./src/settings.yaml /etc/containers/systemd/piccolo/
6565
-cp -r ./containers/piccolo-*.* /etc/containers/systemd/piccolo/
66+
-cp -r ./scripts/update_server_ip.sh /etc/containers/systemd/piccolo/
67+
6668
systemctl daemon-reload
6769
systemctl start piccolo-server
6870
systemctl start piccolo-player

containers/piccolo-player.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ spec:
2626
- name: systemd
2727
mountPath: /etc/containers/systemd
2828
- name: config-path
29-
mountPath: /piccolo/settings.yaml
29+
mountPath: /etc/piccolo/settings.yaml
3030
- name: statemanager
3131
image: localhost/pullpiri:latest
3232
command: ["/piccolo/statemanager"]
@@ -38,7 +38,7 @@ spec:
3838
- name: systemd
3939
mountPath: /etc/containers/systemd
4040
- name: config-path
41-
mountPath: /piccolo/settings.yaml
41+
mountPath: /etc/piccolo/settings.yaml
4242
volumes:
4343
- name: piccolo-yaml
4444
hostPath:

containers/piccolo-server.kube

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ Yaml=/etc/containers/systemd/piccolo/piccolo-server.yaml
1111

1212
[Service]
1313
Restart=always
14+
# settings.yaml에서 IP를 읽어서 yaml 파일을 동적으로 수정하는 스크립트 실행
15+
ExecStartPre=/etc/containers/systemd/piccolo/update_server_ip.sh

containers/piccolo-server.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ spec:
1515
- name: etcd
1616
image: gcr.io/etcd-development/etcd:v3.5.11
1717
command: ["/usr/local/bin/etcd"]
18-
args: ["--data-dir=/etcd-data"]
18+
args:
19+
- "--data-dir=/etcd-data"
20+
- "--listen-client-urls=http://127.0.0.1:2379,http://$(HOST_IP):2379"
21+
- "--advertise-client-urls=http://$(HOST_IP):2379"
1922
volumeMounts:
2023
- name: etcd-data
2124
mountPath: /etcd-data
@@ -26,7 +29,7 @@ spec:
2629
- name: piccolo-yaml
2730
mountPath: /etc/piccolo/yaml
2831
- name: config-path
29-
mountPath: /piccolo/settings.yaml
32+
mountPath: /etc/piccolo/settings.yaml
3033
- name: policymanager
3134
image: localhost/pullpiri:latest
3235
command: ["/piccolo/policymanager"]
@@ -40,7 +43,7 @@ spec:
4043
- name: piccolo-yaml
4144
mountPath: /etc/piccolo/yaml
4245
- name: config-path
43-
mountPath: /piccolo/settings.yaml
46+
mountPath: /etc/piccolo/settings.yaml
4447
volumes:
4548
- name: piccolo-yaml
4649
hostPath:

scripts/update_server_ip.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
# settings.yaml 파일에서 IP를 추출하여 YAML 파일의 $(HOST_IP) 패턴을 대체하는 스크립트
3+
4+
# 입력 및 출력 파일 경로
5+
SETTINGS_YAML="/etc/containers/systemd/piccolo/settings.yaml"
6+
SERVER_YAML="/etc/containers/systemd/piccolo/piccolo-server.yaml"
7+
8+
# settings.yaml에서 IP 주소 추출
9+
HOST_IP=$(grep -A 3 "host:" $SETTINGS_YAML | grep "ip:" | sed -e "s/^[ ]*ip:[ ]*//" -e "s/[ ]*$//")
10+
echo "Extracted HOST_IP: $HOST_IP"
11+
12+
# IP 주소가 비어있는지 확인
13+
if [ -z "$HOST_IP" ]; then
14+
echo "Failed to extract host IP from settings.yaml"
15+
exit 1
16+
fi
17+
18+
# 문자 그대로의 $(HOST_IP)를 실제 IP 주소로 대체
19+
sed -i "s/\\\$(HOST_IP)/${HOST_IP}/g" $SERVER_YAML
20+
21+
echo "Successfully replaced \$(HOST_IP) with $HOST_IP in $SERVER_YAML"
22+
exit 0

src/player/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/player/actioncontroller/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ prost = "0.13.3"
1313
dbus = "0.9.7"
1414
serde = { version = "1.0.214", features = ["derive"] }
1515
serde_yaml = "0.9"
16+
serde_json = "1.0"
1617
common = { workspace = true }
1718
base64 = "0.22.1"

src/player/actioncontroller/src/manager.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ use std::{thread, time::Duration};
22

33
use crate::grpc::sender::statemanager::StateManagerSender;
44
use crate::{grpc::sender::pharos::request_network_pod, runtime::bluechi};
5-
use base64::Engine;
5+
use serde_json;
66
use common::{
77
actioncontroller::PodStatus as Status,
88
spec::artifact::{Package, Scenario},
99
statemanager::{ResourceType, StateChange},
1010
Result,
1111
};
12-
use prost::Message; // Prost Message 트레이트 추가 // base64 Engine 트레이트 추가
12+
// Prost Message 트레이트 추가 // base64 Engine 트레이트 추가
1313

1414
/// Manager for coordinating scenario actions and workload operations
1515
///
@@ -81,9 +81,9 @@ impl ActionControllerManager {
8181
}
8282
};
8383

84-
// 2. 이제 cluster/nodes 접두사에서 상세 정보 조회 시도
84+
// 2. 이제 cluster/nodes 접두사에서 상세 정보 조회 시도 (json string)
8585
let cluster_node_key = format!("cluster/nodes/{}", node_name);
86-
let encoded = match common::etcd::get(&cluster_node_key).await {
86+
let node_json = match common::etcd::get(&cluster_node_key).await {
8787
Ok(value) => value,
8888
Err(e) => {
8989
println!(
@@ -107,9 +107,8 @@ impl ActionControllerManager {
107107
}
108108
};
109109

110-
// 3. base64 디코드 및 NodeInfo 디코드
111-
let buf = base64::engine::general_purpose::STANDARD.decode(&encoded)?;
112-
let node_info = common::apiserver::NodeInfo::decode(buf.as_slice())?;
110+
// 3. json 파싱
111+
let node_info: common::apiserver::NodeInfo = serde_json::from_str(&node_json)?;
113112

114113
// 4. node_role 값에 따라 노드 유형 결정 (node_role: 3 = Bluechi, 2 = Nodeagent)
115114
let role = if node_info.node_role == 3 {

src/player/filtergateway/src/vehicle/dds/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ impl DdsManager {
214214
env::var("PICCOLO_SETTINGS_PATH")
215215
.map(PathBuf::from)
216216
.unwrap_or_else(|_| {
217-
PathBuf::from("/home/edo/2025/projects/pullpiri/src/settings.yaml")
217+
PathBuf::from("/etc/piccolo/settings.yaml")
218218
})
219219
});
220220

src/server/apiserver/src/grpc/receiver.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use base64::Engine;
88
use common::apiserver::api_server_connection_server::ApiServerConnection;
99
use common::apiserver::{
1010
ClusterTopology, GetNodeRequest, GetNodeResponse, GetNodesRequest, GetNodesResponse,
11-
GetTopologyRequest, GetTopologyResponse, NodeInfo, TopologyType, UpdateTopologyRequest,
11+
GetTopologyRequest, GetTopologyResponse, TopologyType, UpdateTopologyRequest,
1212
UpdateTopologyResponse,
1313
};
1414
use common::etcd;
@@ -50,11 +50,10 @@ impl NodeRegistry {
5050
) -> Result<ClusterTopology, Box<dyn std::error::Error + Send + Sync>> {
5151
let topology_key = "cluster/topology";
5252

53-
let mut buf = Vec::new();
54-
prost::Message::encode(&topology, &mut buf)?;
55-
let encoded = base64::engine::general_purpose::STANDARD.encode(&buf);
56-
57-
etcd::put(topology_key, &encoded).await?;
53+
// 인코딩을 제거하고 json string으로 변환
54+
let topology_json = serde_json::to_string(&topology)?;
55+
56+
etcd::put(topology_key, &topology_json).await?;
5857

5958
println!("Updated cluster topology: {}", topology.cluster_name);
6059
Ok(topology)
@@ -166,14 +165,13 @@ impl ApiServerConnection for ApiServerReceiver {
166165
metadata: req.metadata.clone(),
167166
};
168167

169-
let mut buf = Vec::new();
170-
prost::Message::encode(&node_info, &mut buf).unwrap();
171-
let encoded = base64::engine::general_purpose::STANDARD.encode(&buf);
168+
// 인코딩을 제거하고 json string으로 저장
169+
let node_json = serde_json::to_string(&node_info).unwrap();
172170

173171
// 두 가지 키로 저장
174-
// 1. IP 주소로 빠른 조회용 (기존 코드)
175-
let _ = common::etcd::put(&format!("nodes/{}", req.ip_address), &encoded).await;
176-
println!("Node info stored at IP key: nodes/{}", req.ip_address);
172+
// 1. IP 주소로 빠른 조회용 (json 문자열로 변경)
173+
let _ = common::etcd::put(&format!("nodes/{}", req.ip_address), &req.hostname).await;
174+
println!("Hostname stored at IP key: nodes/{}", req.ip_address);
177175

178176
// 2. 호스트 이름으로 빠른 조회용 (ActionController용)
179177
let _ =

0 commit comments

Comments
 (0)