-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for root filesystem image transfer via uftp, and md5sum c… #3560
Open
rich350
wants to merge
8
commits into
xcat2:master
Choose a base branch
from
rich350:rich350_uftp
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a7ab2e6
add support for root filesystem image transfer via uftp, and md5sum c…
fcd5003
Merge branch 'master' of github.com:xcat2/xcat-core into rich350_uftp
9cf42fd
added support for copying multiple images simultaneously
979fd4b
Merge branch 'master' of github.com:xcat2/xcat-core into rich350_uftp
23eea8b
Merge branch 'master' of github.com:xcat2/xcat-core into rich350_uftp
538f479
Merge branch 'master' of github.com:xcat2/xcat-core into rich350_uftp
11cfcd4
Merge branch 'master' of github.com:xcat2/xcat-core into rich350_uftp
81820c5
Merge branch 'master' of github.com:xcat2/xcat-core into rich350_uftp
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Implementing UFTP in xCAT | ||
|
||
When a node boots via xCAT in stateless mode, it first receives a kernel and | ||
an initial ramdisk from the management server. Inside the initial ramdisk is | ||
a script named xcatroot which is responsible for copying the node's root | ||
filesystem image from the management server with wget, uncompressing it into | ||
RAM, and switching to it. The URL of the root filesystem image is passed to | ||
xcatroot via a kernel boot parameter. | ||
|
||
In order to support uftp, xcatroot needs to start uftpd, and then signal the | ||
management server that it is ready to receive the image file. The management | ||
server also needs to wait for some amount of time before starting the transfer, | ||
since there could be some variability in the hardware boot process, and the | ||
slowest node might not have started uftpd yet. In order to make sure the image | ||
transferred correctly, the md5 checksum is checked. If the md5 check fails, or | ||
the transfer times out, xcatroot falls back to wget. | ||
|
||
To implement this, three kernel boot parameters were added, which are: | ||
|
||
uftp | ||
uftpdelay | ||
md5sum | ||
|
||
To use UFTP, set uftp=true. The uftpdelay parameter is for specifying the | ||
number of seconds to wait before the transfer starts, and defaults to 30 if | ||
not specified. The md5sum parameter should be set to the md5 checksum of the | ||
root filesystem image. These need to be set in the addkcmdline field in the | ||
osimage table in xCAT, so that nodeset will pick them up. The packimage | ||
command has been extended with some options to facilitate this: | ||
|
||
packimage [-s| --sum] set md5sum=<md5 checksum of image> | ||
packimage [-u| --uftp] set uftp=true | ||
packimage [-d| --delay=<uftp delay in seconds> set uftpdelay=<uftp delay in seconds> | ||
|
||
Note that if -s is omitted, and an md5sum exists in addkcmdline, the existing | ||
entry is removed because it would no longer be valid. Similarly, if -u is | ||
omitted and uftp=true exists in addkcmdline, it is removed. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,100 @@ | ||
#!/bin/bash | ||
LOGDIR=/var/log/xcat/ | ||
LOGFILE=uftp_listener.log | ||
mkdir -p $LOGDIR | ||
|
||
usage() { | ||
echo "usage: uftp-listener [ -i interface ] [ -s sleep time ]" | ||
exit 1 | ||
} | ||
|
||
debug() { | ||
[ "$DEBUG" ] && echo "$@" | ||
echo "$@" >> $LOGDIR/$LOGFILE | ||
} | ||
|
||
start_copy() { | ||
sleep $SLEEP | ||
debug "copying $ROOTIMG" | ||
debug "$UFTP -I $INTERFACE -R 950000 -p $UFTPPORT -D /rootimg.cpio.gz $ROOTIMG" | ||
$UFTP -I $INTERFACE -R 950000 -p $UFTPPORT -D /rootimg.cpio.gz $ROOTIMG | ||
} | ||
|
||
while getopts ":i:s:hd" options | ||
do | ||
case ${options} in | ||
i ) INTERFACE=${OPTARG};; | ||
s ) SLEEP=${OPTARG};; | ||
d ) DEBUG=true;; | ||
h ) usage | ||
exit 1;; | ||
* ) usage | ||
exit 1;; | ||
esac | ||
done | ||
|
||
# if INTERFACE is null, try to detect | ||
if [ -z "$INTERFACE" ]; then | ||
MAN_NET=$(/opt/xcat/bin/lsdef -t network management | grep net | sed 's/.*=//') | ||
INTERFACE=$(netstat -nr | grep $MAN_NET | awk '{print $8}') | ||
fi | ||
|
||
if [ -z "$INTERFACE" ]; then | ||
debug "ERROR: detection of interface failed and none supplied with -i, aborting..." | ||
exit 1 | ||
fi | ||
|
||
ip link show $INTERFACE > /dev/null 2>&1 | ||
RC=$? | ||
|
||
if [ "$RC" != 0 ]; then | ||
debug "ERROR: invalid interface $INTERFACE" | ||
exit 1 | ||
fi | ||
|
||
# if no sleep time supplied, use the default of 30 seconds | ||
if [ -z "$SLEEP" ]; then | ||
SLEEP=30 | ||
fi | ||
|
||
UFTP=$(which uftp) | ||
if [ ! -x $UFTP ]; then | ||
debug "ERROR: uftp binary not found, exiting!" | ||
exit 1 | ||
fi | ||
|
||
# make sure 1045/tcp is not already in use | ||
nc -i 500ms -l -p 1045 2>&1 | grep "Address already in use" > /dev/null | ||
RC=$? | ||
if [ "$RC" = 0 ]; then | ||
debug "ERROR: 1045/tcp is already in use, sleeping 10 seconds and exiting" | ||
sleep 10 | ||
exit 1 | ||
fi | ||
|
||
debug "listening for transfer request on interface $INTERFACE 1045/tcp" | ||
declare -A copyjobs | ||
while true | ||
do | ||
nc -l -p 1045 -k | while read LINE; do | ||
VALIDATED=$(echo $LINE | grep -E "/install/.*/rootimg(\.sfs|\.cpio\.gz|\.cpio\.xz|\.tar.gz|\.tar\.xz|-statelite\.gz)") | ||
if [ -n "$VALIDATED" ]; then | ||
ROOTIMG=$(echo $VALIDATED | sed 's/.*GET //' | sed 's+ HTTP/1.1.*++') | ||
if $(echo $ROOTIMG | grep uftpport > /dev/null); then | ||
UFTPPORT=$(echo $ROOTIMG | sed 's+.*uftpport=++') | ||
ROOTIMG=$(echo $ROOTIMG | sed 's+/uftpport=.*++') | ||
else | ||
UFTPPORT=1044 | ||
fi | ||
if [ ! -f "$ROOTIMG" ]; then | ||
debug "$ROOTIMG: file not found" | ||
elif [ ! x${copyjobs[$ROOTIMG]} = x ] && jobs -lr | grep ${copyjobs[$ROOTIMG]} > /dev/null; then | ||
: # if we get here, there is already a uftp copy job staged for this url, so do nothing | ||
# debug "$ROOTIMG job detected" | ||
else | ||
start_copy $ROOTIMG & | ||
copyjobs[$ROOTIMG]=$! | ||
fi | ||
fi | ||
done | ||
done |
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,12 @@ | ||
[Unit] | ||
Description=UFTP listener | ||
Wants=basic.target | ||
After=basic.target network.target | ||
|
||
[Service] | ||
Type=simple | ||
ExecStart=/bin/bash /opt/xcat/bin/uftp-listener | ||
KillMode=control-group | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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,41 @@ | ||
Name: uftp | ||
Version: 4.9.3 | ||
Release: 1 | ||
Summary: UFTP - Encrypted UDP based FTP with multicast | ||
|
||
Group: FTP Server | ||
License: GPL | ||
URL: http://uftp-multicast.sourceforge.net | ||
Source0: http://sourceforge.net/projects/uftp-multicast/files/source-tar/uftp-4.9.3.tar.gz | ||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) | ||
|
||
BuildRequires: openssl-devel | ||
|
||
%description | ||
UFTP is an encrypted multicast file transfer program, designed to securely, reliably, and efficiently transfer files to multiple receivers simultaneously. This is useful for distributing large files to a large number of receivers, and is especially useful for data distribution over a satellite link (with two way communication), where the inherent delay makes any TCP based communication highly inefficient. The multicast encryption scheme is based on TLS with extensions to allow multiple receivers to share a common key. UFTP also has the capability to communicate over disjoint networks separated by one or more firewalls (NAT traversal) and without full end-to-end multicast capability (multicast tunneling) through the use of a UFTP proxy server. These proxies also provide scalability by aggregating responses from a group of receivers. | ||
|
||
%prep | ||
%setup -q | ||
|
||
%build | ||
make %{?_smp_mflags} | ||
|
||
%install | ||
rm -rf $RPM_BUILD_ROOT | ||
make install DESTDIR=$RPM_BUILD_ROOT | ||
|
||
%clean | ||
rm -rf $RPM_BUILD_ROOT | ||
|
||
%files | ||
%defattr(-,root,root,-) | ||
/usr/bin/uftp | ||
/usr/sbin/uftpd | ||
/usr/sbin/uftpproxyd | ||
/usr/bin/uftp_keymgt | ||
/usr/share/man/man1/uftp.1.gz | ||
/usr/share/man/man1/uftp_keymgt.1.gz | ||
/usr/share/man/man1/uftpd.1.gz | ||
/usr/share/man/man1/uftpproxyd.1.gz | ||
|
||
%changelog |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @rich350 , what is this argument
"delay|t=s" => \$uftpdelay
for?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an amount of time to wait to make sure all booting nodes have gone through their hardware initialization, loaded the kernel and initrd, started xcatroot, and started uftpd. For example, let's say we are booting lots of nodes at the same time to the same image. Each node will initialize, but maybe a few nodes take longer to load a particular driver for whatever reason. So, with each boot there will be a fastest node, and a slowest node. The fastest node will start uftpd and be the first to send a request to uftp-listener for the image. If uftp-listener immediately starts the transfer after the first request, the slowest node might not have started uftpd yet, and would therefore miss the transfer. So, uftpdelay is the amount of time that uftp-listener should wait before starting the transfer, once it receives the first request from the node that booted the fastest.
Since there is a timeout built into the uftp transfer logic in xcatroot, both uftp-listener and xcatroot need to be aware of uftpdelay, so it is passed as a boot parameter. I added the timeout so that if some node is really slow and doesn't get uftpd started before the transfer starts, then sends his request after the transfer has started, it will time out and fall back to wget. The default of 30 seconds is probably overkill, and could probably safely be reduced to 15 or even 10 seconds, but this will depend on the particular hardware, networking, number of nodes, etc. Since this will vary by site, I went with a safe default that can be tuned.