Skip to content

Commit

Permalink
Merge pull request #527 from village-way/main
Browse files Browse the repository at this point in the history
fix: node-agent restart when the version not changed #526
  • Loading branch information
kosmos-robot authored May 10, 2024
2 parents 107b823 + 0afb8f9 commit be27700
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
3 changes: 1 addition & 2 deletions deploy/virtual-cluster-operator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,7 @@ spec:
key: password
command: ["/bin/bash"]
args:
- "-c"
- "sed -i 's/^WEB_USER=.*/WEB_USER=$(WEB_USER)/' /app/agent.env && sed -i 's/^WEB_PASS=.*/WEB_PASS=$(WEB_PASS)/' /app/agent.env && rsync -avz /app/ /host-path/ && cp /app/node-agent.service /host-systemd/node-agent.service "
- "/app/init.sh"
volumeMounts:
- mountPath: /host-path
name: node-agent
Expand Down
8 changes: 8 additions & 0 deletions hack/node-agent/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -e
sed -i 's/^WEB_USER=.*/WEB_USER=$(WEB_USER)/' /app/agent.env
sed -i 's/^WEB_PASS=.*/WEB_PASS=$(WEB_PASS)/' /app/agent.env
sha256sum /app/node-agent > node-agent.sum
sha256sum /host-path/node-agent >> node-agent.sum
rsync -avz /app/ /host-path/
cp /app/node-agent.service /host-systemd/node-agent.service
15 changes: 11 additions & 4 deletions hack/node-agent/start.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/usr/bin/env bash
sudo systemctl daemon-reload
sudo systemctl enable node-agent
sudo systemctl stop node-agent
sudo systemctl start node-agent
img_app_sum=$(head -n 1 /srv/node-agent/node-agent.sum | cut -d' ' -f1)
host_app_sum=$(sed -n '2p' /srv/node-agent/node-agent.sum | cut -d' ' -f1)
if [ "$img_app_sum" == "$host_app_sum" ]; then
echo "app is same, skip restart node-agent"
else
echo "app is different, restart node-agent"
sudo systemctl daemon-reload
sudo systemctl enable node-agent
sudo systemctl stop node-agent
sudo systemctl start node-agent
fi

0 comments on commit be27700

Please sign in to comment.