Skip to content
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

validate copy kubetarball #496

Merged
merged 1 commit into from
Oct 15, 2020
Merged

validate copy kubetarball #496

merged 1 commit into from
Oct 15, 2020

Conversation

oldthreefeng
Copy link
Collaborator

@oldthreefeng oldthreefeng commented Oct 13, 2020

fix #491 . 复制过程 如果文件存在和PkgUrl路径下的进行MD5比对,
比对不一样, 就删除远程的主机文件(是退出安装还是删除文件靠谱点..),

不存在复制,沿用逻辑..
[SKIP CI]seaols: 一句话简短描述该PR内容

日志

$ sealos  init --master 192.168.1.21 --pkg-url kube1.18.8.tar.gz  --version v1.18.8
14:25:11 [INFO] [ssh.go:13] [ssh][192.168.1.21:22] hostname
14:25:11 [DEBG] [ssh.go:25] [ssh][192.168.1.21:22]command result is: k8s-dev

14:25:11 [INFO] [ssh.go:58] [ssh][192.168.1.21:22] cat /etc/hosts |grep k8s-dev || echo '192.168.1.21 k8s-dev' >> /etc/hosts
14:25:11 [INFO] [ssh.go:51] [192.168.1.21:22] 192.168.1.21 k8s-dev
14:25:11 [INFO] [check.go:52] [192.168.1.21:22]  ------------ check ok
14:25:11 [INFO] [print.go:13] 
[globals]sealos config is:  {"Hosts":["192.168.1.21:22"],"Masters":["192.168.1.21:22"],"Nodes":null}
14:25:11 [INFO] [ssh.go:58] [ssh][192.168.1.21:22] mkdir -p /usr/bin || true
14:25:11 [DEBG] [download.go:29] [192.168.1.21:22]please wait for mkDstDir
14:25:11 [DEBG] [download.go:31] [192.168.1.21:22]please wait for before hook
14:25:11 [INFO] [ssh.go:58] [ssh][192.168.1.21:22] ps -ef |grep -v 'grep'|grep sealos >/dev/null || rm -rf /usr/bin/sealos
14:25:11 [INFO] [ssh.go:13] [ssh][192.168.1.21:22] ls -l /usr/bin/sealos 2>/dev/null |wc -l
14:25:12 [DEBG] [ssh.go:25] [ssh][192.168.1.21:22]command result is: 1

14:25:12 [INFO] [ssh.go:13] [ssh][192.168.1.21:22] md5sum /usr/bin/sealos | cut -d" " -f1
14:25:12 [DEBG] [ssh.go:25] [ssh][192.168.1.21:22]command result is: 7b8912b8255a3ded07bd985e16d91238

14:25:12 [INFO] [download.go:36] [192.168.1.21:22]SendPackage:  /usr/bin/sealos file is exist and ValidateMd5 success
14:25:12 [DEBG] [download.go:49] [192.168.1.21:22]please wait for after hook
14:25:12 [INFO] [ssh.go:58] [ssh][192.168.1.21:22] chmod a+x /usr/bin/sealos
14:25:14 [INFO] [ssh.go:58] [ssh][192.168.1.21:22] mkdir -p /root || true
14:25:14 [DEBG] [download.go:29] [192.168.1.21:22]please wait for mkDstDir
14:25:14 [INFO] [ssh.go:13] [ssh][192.168.1.21:22] ls -l /root/kube1.18.8.tar.gz 2>/dev/null |wc -l
14:25:14 [DEBG] [ssh.go:25] [ssh][192.168.1.21:22]command result is: 1

14:25:15 [INFO] [ssh.go:13] [ssh][192.168.1.21:22] md5sum /root/kube1.18.8.tar.gz | cut -d" " -f1
14:25:17 [DEBG] [ssh.go:25] [ssh][192.168.1.21:22]command result is: cd3d5791b292325d38bbfaffd9855312

14:25:17 [INFO] [download.go:36] [192.168.1.21:22]SendPackage:  /root/kube1.18.8.tar.gz file is exist and ValidateMd5 success

存在但是md5不对.

14:58:34 [INFO] [ssh.go:58] [ssh][192.168.1.21:22] ps -ef |grep -v 'grep'|grep sealos >/dev/null || rm -rf /usr/bin/sealos
14:58:34 [INFO] [ssh.go:13] [ssh][192.168.1.21:22] ls -l /usr/bin/sealos 2>/dev/null |wc -l
14:58:34 [DEBG] [ssh.go:25] [ssh][192.168.1.21:22]command result is: 1

14:58:34 [INFO] [ssh.go:13] [ssh][192.168.1.21:22] md5sum /usr/bin/sealos | cut -d" " -f1
14:58:34 [DEBG] [ssh.go:25] [ssh][192.168.1.21:22]command result is: c305a622668a7f6f0a02c9798f3eb3a7

14:58:34 [INFO] [download.go:36] [192.168.1.21:22]SendPackage:  /usr/bin/sealos file is exist and ValidateMd5 success
14:58:34 [DEBG] [download.go:54] [192.168.1.21:22]please wait for after hook
14:58:34 [INFO] [ssh.go:58] [ssh][192.168.1.21:22] chmod a+x /usr/bin/sealos
14:58:36 [INFO] [ssh.go:58] [ssh][192.168.1.21:22] mkdir -p /root || true
14:58:36 [DEBG] [download.go:29] [192.168.1.21:22]please wait for mkDstDir
14:58:36 [INFO] [ssh.go:13] [ssh][192.168.1.21:22] ls -l /root/kube1.18.8.tar.gz 2>/dev/null |wc -l
14:58:36 [DEBG] [ssh.go:25] [ssh][192.168.1.21:22]command result is: 1

14:58:37 [INFO] [ssh.go:13] [ssh][192.168.1.21:22] md5sum /root/kube1.18.8.tar.gz | cut -d" " -f1
14:58:38 [DEBG] [ssh.go:25] [ssh][192.168.1.21:22]command result is: d41d8cd98f00b204e9800998ecf8427e

14:58:38 [INFO] [ssh.go:13] [ssh][192.168.1.21:22] rm -f /root/kube1.18.8.tar.gz
14:58:38 [DEBG] [ssh.go:25] [ssh][192.168.1.21:22]command result is: 
14:58:38 [DEBG] [scp.go:27] [ssh]source file md5 value is cd3d5791b292325d38bbfaffd9855312
14:58:39 [INFO] [scp.go:101] [ssh][192.168.1.21:22]transfer total size is: 100.00MB ;speed is 100MB
14:58:40 [INFO] [scp.go:101] [ssh][192.168.1.21:22]transfer total size is: 200.00MB ;speed is 100MB
14:58:41 [INFO] [scp.go:101] [ssh][192.168.1.21:22]transfer total size is: 300.00MB ;speed is 100MB
14:58:42 [INFO] [scp.go:101] [ssh][192.168.1.21:22]transfer total size is: 400.00MB ;speed is 100MB
14:58:43 [INFO] [scp.go:101] [ssh][192.168.1.21:22]transfer total size is: 500.00MB ;speed is 100MB
14:58:44 [INFO] [scp.go:101] [ssh][192.168.1.21:22]transfer total size is: 600.00MB ;speed is 100MB
14:58:44 [INFO] [scp.go:101] [ssh][192.168.1.21:22]transfer total size is: 610.15MB ;speed is 10MB
14:58:44 [INFO] [ssh.go:13] [ssh][192.168.1.21:22] md5sum /root/kube1.18.8.tar.gz | cut -d" " -f1
14:58:46 [DEBG] [ssh.go:25] [ssh][192.168.1.21:22]command result is: cd3d5791b292325d38bbfaffd9855312

14:58:46 [DEBG] [scp.go:30] [ssh]host: 192.168.1.21:22 , remote md5: cd3d5791b292325d38bbfaffd9855312
14:58:46 [INFO] [scp.go:34] [ssh]md5 validate true
14:58:46 [INFO] [download.go:41] [192.168.1.21:22]copy file md5 validate success

if SSHConfig.ValidateMd5sumLocalWithRemote(host, location, fullPath) {
logger.Info("[%s]SendPackage: %s file is exist and ValidateMd5 success", host, fullPath)
} else {
rm := fmt.Sprintf("rm -f %s", fullPath)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里待考虑, 复制过程, 文件存在 ,但是目标文件的md5和源文件的md5校验失败的情况下. sealos该如何处理??

Signed-off-by: oldthreefeng <[email protected]>
@fanux fanux merged commit ac1f735 into labring:develop Oct 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

传输离线包时手动中断部署,离线包被破坏,重新部署对应节点会被跳过
2 participants