-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the run collect-info through Edgeview
- Add the implementation on running collect-info through Edgeview - Egeview is mostly only with read permission access to device filesystems and it does not want to import all the pkgs and replicate the collect-info.sh operations and maintain compatibility of two sets of the collect-info - this implementation has a protocol to setup a request for debug container to start run 'collect-info.sh', and remove the request file after it is done; Edgeview then uses existing copy file protocol to transfer the collect-info tarball file back to user's laptop; then Edgeview put another request for - debug container to remove the created tarball file in /persist debug container has added a background task to monitor the request- - Since collect-info is mostly live info, there is no need to get all the newlogs, only fetch the newlogs of the past 10 days. - change the debug/ssh.sh into debug/debug-tasks.sh to reflect it does not only handling the ssh task Signed-off-by: Naiming Shen <naiming@zededa.com>
- Loading branch information
1 parent
e8a6474
commit 3578fc3
Showing
8 changed files
with
253 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/sh | ||
|
||
# setting things up for being able to access linux kernel symbols | ||
echo 0 > /proc/sys/kernel/kptr_restrict | ||
echo -1 > /proc/sys/kernel/perf_event_paranoid | ||
|
||
# This script used to be 'ssh.sh', at the time of introducing the | ||
# monitoring task, it was renamed to 'debug-tasks.sh' to reflect | ||
# multiple tasks that debug container can perform in the background. | ||
|
||
KEYS=$(find /etc/ssh -name 'ssh_host_*_key') | ||
[ -z "$KEYS" ] && ssh-keygen -A >/dev/null 2>/dev/null | ||
|
||
# Background monitoring non-ssh related tasks | ||
monitor_file_and_execute_tasks() { | ||
# edgeview request to generate collect-info and remove tar.gz file | ||
# the protocol is for edgeview to create a file | ||
# /run/edgeview/edgeview-request-collect-info, and debug container | ||
# run 'collect-info.sh' to generate the tar.gz file, when the job is | ||
# done, remove the file /run/edgeview/edgeview-request-collect-info. | ||
# edgeview can also request to remove the tar.gz file by creating | ||
# /run/edgeview/edgeview-request-remove-tar.gz file, and debug container | ||
# will get the file name and remove the generated tar.gz file. | ||
# | ||
# if addition tasks are needed, this can monitor multiple directories | ||
# and perform different actions by debug container in the future. | ||
while true; do | ||
if [ -f "/run/edgeview/edgeview-request-collect-info" ]; then | ||
echo "edgeview request to run collect-info..." > /dev/kmsg | ||
# the newlog part of the collection, only collect last 10 days | ||
/usr/bin/collect-info.sh -t 10 | ||
# remove the request file | ||
echo "edgeview request collect-info done" > /dev/kmsg | ||
rm /run/edgeview/edgeview-request-collect-info | ||
fi | ||
if [ -f "/run/edgeview/edgeview-request-remove-tar-gz" ]; then | ||
fileToRemove=$(cat /run/edgeview/edgeview-request-remove-tar-gz) | ||
echo "edgeview request to remove $fileToRemove file" > /dev/kmsg | ||
if [ -f "$fileToRemove" ]; then | ||
rm "$fileToRemove" | ||
fi | ||
# remove the request file | ||
rm /run/edgeview/edgeview-request-remove-tar-gz | ||
fi | ||
sleep 5 | ||
done | ||
} | ||
|
||
# Start the monitoring task in the background | ||
monitor_file_and_execute_tasks & | ||
|
||
if [ -f "/config/remote_access_disabled" ]; then | ||
# this is picked up by newlogd | ||
echo "Remote access disabled, ssh server not started" > /dev/kmsg | ||
while true; do | ||
# sleep for INT_MAX, keep the container running | ||
sleep inf | ||
done | ||
else | ||
exec /usr/sbin/sshd -D -e | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ const ( | |
copyTarFiles | ||
copyTechSupport | ||
copyKubeConfig | ||
copyCollectInfo | ||
) | ||
|
||
var ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.