Skip to content

Commit 37b34b8

Browse files
authored
Merge pull request #283 from eclipse-pullpiri/clustering
2 parents 2f457e2 + ca4a5df commit 37b34b8

File tree

32 files changed

+1075
-526
lines changed

32 files changed

+1075
-526
lines changed

doc/scripts/install_nodeagent.sh

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# install_nodeagent.sh - NodeAgent installation script
3-
# Usage: ./install_nodeagent.sh <master_node_ip> [node_type]
3+
# Usage: ./install_nodeagent.sh --master <master_ip> --node <node_ip> [--role <node_role>] [--type <node_type>]
44

55
# Exit on error
66
set -e
@@ -11,9 +11,54 @@ if [ "$(id -u)" -ne 0 ]; then
1111
exit 1
1212
fi
1313

14+
# Initialize variables
15+
MASTER_IP=""
16+
NODE_IP=""
17+
NODE_NAME=$(hostname) # Always use system hostname
18+
NODE_ROLE="nodeagent" # Default node role (master, nodeagent, bluechi)
19+
NODE_TYPE="vehicle" # Default node type (vehicle, cloud)
20+
21+
# Process command line arguments
22+
while [[ $# -gt 0 ]]; do
23+
case $1 in
24+
--master)
25+
MASTER_IP="$2"
26+
shift 2
27+
;;
28+
--node)
29+
NODE_IP="$2"
30+
shift 2
31+
;;
32+
--role)
33+
NODE_ROLE="$2"
34+
# Validate node role
35+
if [[ ! "$NODE_ROLE" =~ ^(master|nodeagent|bluechi)$ ]]; then
36+
echo "Error: Invalid node role '$NODE_ROLE'. Must be one of: master, nodeagent, bluechi"
37+
exit 1
38+
fi
39+
shift 2
40+
;;
41+
--type)
42+
NODE_TYPE="$2"
43+
# Validate node type
44+
if [[ ! "$NODE_TYPE" =~ ^(vehicle|cloud|master|nodeagent|bluechi)$ ]]; then
45+
echo "Error: Invalid node type '$NODE_TYPE'. Must be one of: vehicle, cloud, master, nodeagent, bluechi"
46+
exit 1
47+
fi
48+
shift 2
49+
;;
50+
*)
51+
echo "Unknown option: $1"
52+
echo "Usage: $0 --master <master_ip> --node <node_ip> [--role <node_role>] [--type <node_type>]"
53+
exit 1
54+
;;
55+
esac
56+
done
57+
1458
# Parameter validation
15-
if [ $# -lt 1 ]; then
16-
echo "Usage: $0 <master_node_ip> [node_type(sub|master)]"
59+
if [ -z "$MASTER_IP" ] || [ -z "$NODE_IP" ]; then
60+
echo "Error: Both --master and --node options are required."
61+
echo "Usage: $0 --master <master_ip> --node <node_ip> [--role <node_role>] [--type <node_type>]"
1762
exit 1
1863
fi
1964

@@ -114,10 +159,9 @@ install_required_packages() {
114159
fi
115160
}
116161

117-
# Parameter settings
118-
MASTER_IP=$1
119-
NODE_TYPE=${2:-"sub"}
120-
GRPC_PORT=${3:-"47098"}
162+
# Parameter settings already processed from command line
163+
# MASTER_IP and NODE_IP are set from command line arguments
164+
GRPC_PORT="47004"
121165
#DOWNLOAD_URL="https://github.com/piccolo-framework/piccolo/releases/download/latest"
122166
DOWNLOAD_URL="https://raw.githubusercontent.com/eclipse-pullpiri/pullpiri/main/examples/binarys"
123167
CHECKSUM_URL="${DOWNLOAD_URL}" # Define CHECKSUM_URL
@@ -244,15 +288,16 @@ chmod +x /usr/local/bin/node_ready_check.sh
244288
echo "Creating configuration file..."
245289
cat > ${CONFIG_DIR}/nodeagent.yaml << EOF
246290
nodeagent:
291+
node_name: "${NODE_NAME}"
247292
node_type: "${NODE_TYPE}"
293+
node_role: "${NODE_ROLE}"
248294
master_ip: "${MASTER_IP}"
295+
node_ip: "${NODE_IP}"
249296
grpc_port: ${GRPC_PORT}
250297
log_level: "info"
251298
metrics:
252299
collection_interval: 5
253300
batch_size: 50
254-
etcd:
255-
endpoint: "${MASTER_IP}:2379"
256301
system:
257302
hostname: "$(hostname)"
258303
platform: "$(uname -s)"
@@ -300,6 +345,7 @@ Restart=on-failure
300345
RestartSec=10
301346
Environment=RUST_LOG=info
302347
Environment=MASTER_NODE_IP=${MASTER_IP}
348+
Environment=NODE_IP=${NODE_IP}
303349
Environment=GRPC_PORT=${GRPC_PORT}
304350
305351
# Security hardening settings
@@ -375,6 +421,7 @@ echo "Installation Summary:"
375421
echo "- Installation directory: ${INSTALL_DIR}"
376422
echo "- Configuration file: ${CONFIG_DIR}/nodeagent.yaml"
377423
echo "- Master node: ${MASTER_IP}:${GRPC_PORT}"
424+
echo "- Node IP: ${NODE_IP}"
378425
echo "- Node type: ${NODE_TYPE}"
379426
echo "- Status: $ERROR_COUNT errors, $WARNING_COUNT warnings"
380427

-29.1 KB
Binary file not shown.

src/Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33

44
.PHONY: default build
55
build:
6-
cargo build --manifest-path=agent/Cargo.toml
76
cargo build --manifest-path=player/Cargo.toml
87
cargo build --manifest-path=server/Cargo.toml
98

109
.PHONY: clean
1110
clean:
1211
cargo clean --manifest-path=common/Cargo.toml
13-
cargo clean --manifest-path=agent/Cargo.toml
1412
cargo clean --manifest-path=player/Cargo.toml
1513
cargo clean --manifest-path=server/Cargo.toml
1614
cargo clean --manifest-path=tools/Cargo.toml
@@ -22,15 +20,13 @@ tool:
2220
.PHONY: fmt
2321
fmt:
2422
cd common && cargo fmt
25-
cd agent && cargo fmt
2623
cd player && cargo fmt
2724
cd server && cargo fmt
2825
cd tools && cargo fmt
2926

3027
.PHONY: clippy
3128
clippy:
3229
cd common && cargo clippy
33-
cd agent && cargo clippy
3430
cd player && cargo clippy
3531
cd server && cargo clippy
3632
cd tools && cargo clippy

src/agent/Cargo.lock

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

src/agent/nodeagent/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ hyperlocal = { version = "0.8", features = ["client"] }
1717
thiserror = "1.0"
1818
once_cell = "1.19.0"
1919
sysinfo = "0.36.1"
20+
if-addrs = "0.10.1"
21+
hostname = "0.3.1"

src/agent/nodeagent/src/bluechi/filemaker.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,27 @@ pub async fn make_symlink(node_name: &str, model_name: &str) -> common::Result<(
4343
crate::config::Config::get().get_yaml_storage(),
4444
model_name
4545
);
46+
47+
// Make sure original file exists
48+
if !std::path::Path::new(&original).exists() {
49+
return Err(format!("Original file '{}' does not exist", original).into());
50+
}
51+
52+
// Make sure SYSTEMD_PATH exists
53+
if !std::path::Path::new(SYSTEMD_PATH).exists() {
54+
println!("Creating directory: {}", SYSTEMD_PATH);
55+
std::fs::create_dir_all(SYSTEMD_PATH)?;
56+
}
57+
4658
let link = format!("{}{}.kube", SYSTEMD_PATH, model_name);
4759

60+
// Remove existing symlink if it exists
61+
if std::path::Path::new(&link).exists() {
62+
println!("Removing existing symlink: {}", link);
63+
std::fs::remove_file(&link)?;
64+
}
65+
66+
println!("Creating symlink from {} to {}", original, link);
4867
std::os::unix::fs::symlink(original, link)?;
4968

5069
Ok(())

0 commit comments

Comments
 (0)