mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
fix: backup ignore file removed warning (#22044)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
@@ -2361,13 +2361,15 @@ func (s *sPodGuestInstance) tarHostDir(srcDir, targetPath string,
|
||||
log.Infof("[%s] tar cmd: %s", s.GetName(), cmd)
|
||||
if out, err := procutils.NewRemoteCommandAsFarAsPossible("sh", "-c", cmd).Output(); err != nil {
|
||||
outErr := errors.Wrapf(err, "%s: %s", cmd, out)
|
||||
outMsg := strings.ToLower(string(out))
|
||||
// ref: https://stackoverflow.com/questions/20318852/tar-file-changed-as-we-read-it
|
||||
exitStatus1 := "exit status 1"
|
||||
fileChangedMsg := "file changed as we read it"
|
||||
socketIgnoredMsg := "socket ignored"
|
||||
if strings.Contains(outErr.Error(), exitStatus1) {
|
||||
for _, warningMsg := range []string{fileChangedMsg, socketIgnoredMsg} {
|
||||
if strings.Contains(outErr.Error(), warningMsg) {
|
||||
const exitStatus1 = "exit status 1"
|
||||
const fileChangedMsg = "file changed as we read it"
|
||||
const fileRemovedMsg = "file removed before we read it"
|
||||
const socketIgnoredMsg = "socket ignored"
|
||||
if strings.Contains(outMsg, exitStatus1) {
|
||||
for _, warningMsg := range []string{fileChangedMsg, fileRemovedMsg, socketIgnoredMsg} {
|
||||
if strings.Contains(outMsg, warningMsg) {
|
||||
log.Warningf("[%s] got some warning message when tar: %s", s.GetName(), outErr)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user