Bug 801204

Summary: rhc-snapshot doesn't restore
Product: OKD Reporter: Nam Duong <nduong>
Component: ocAssignee: John (J5) Palmieri <johnp>
Status: CLOSED CURRENTRELEASE QA Contact: libra bugs <libra-bugs>
Severity: low Docs Contact:
Priority: high    
Version: 2.xCC: bmeng, jkeck, jofernan, mhicks, rmillner, xtian
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rhc-0.90.2 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-04-27 20:46:51 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Nam Duong 2012-03-07 22:43:55 UTC
Description of problem:
I'm able take a snapshot without a hitch:
rhc-snapshot -a wordpress

The resulting wordpress.tar.gz looks fine and extracts just fine.

But when I do a restore, I get a tar error:
$ rhc-snapshot -a wordpress -r wordpress.tar.gz 
Password: 
tar: Option --wildcards is not supported
Usage:
  List:    tar -tf <archive-filename>
  Extract: tar -xf <archive-filename>
  Create:  tar -cf <archive-filename> [filenames...]
  Help:    tar --help
Archive at wordpress.tar.gz does not contain the target application: ./*/wordpress
If you created this archive rather than exported with rhc-snapshot, be sure
the directory structure inside the archive starts with ./<app_uuid>/
i.e.: tar -czvf <app_name>.tar.gz ./<app_uuid>/


NOTE:  This is on Mac OSX.  I will try with Windows and Fedora after a demo...

Comment 1 Nam Duong 2012-03-07 22:53:11 UTC
works fine on fedora

Comment 2 Nam Duong 2012-03-07 23:01:11 UTC
Not sure where to store this information but it is good to know that some applications do not migrate across domains very well.  For example, Wordpress stores it's App URL within the database so if a user takes a snapshot from domain1 and restores on domain2, their data essentially hosed (useless).  In my case, from wordpress-macdomain.rhcloud.com -> wordpress-macfed.rhcloud.com and now it looks like this:
http://wordpress-macfed.rhcloud.com

Comment 3 Nam Duong 2012-03-08 01:24:33 UTC
Can't restore on Windows client either:

$ rhc-snapshot -a wordpress -r wordpress.tar.gz
Password: vostok08


gzip: stdin: invalid compressed data--format violated
tar: Child returned status 1
tar: ./*/wordpress: Not found in archive
tar: Exiting with failure status due to previous errors
Archive at wordpress.tar.gz does not contain the target application: ./*/wordpress
If you created this archive rather than exported with rhc-snapshot, be sure
the directory structure inside the archive starts with ./<app_uuid>/
i.e.: tar -czvf <app_name>.tar.gz ./<app_uuid>/

This seems to be a different problem as the tar.gz file seems corrupt (e.g., the snapshot produced a bad tar.gz possibly):
$ tar -xvf wordpress.tar.gz

gzip: stdin: invalid compressed data--format violated
tar: Child returned status 1
tar: Exiting with failure status due to previous errors


Lastly, this is with the latest rhc client tools as I did an update before running the commands.

Comment 4 Xiaoli Tian 2012-03-08 03:12:33 UTC
There's a similar bug on windows before :
https://bugzilla.redhat.com/show_bug.cgi?id=790795

Comment 5 Meng Bo 2012-03-08 07:56:32 UTC
checked with latest rhc (0.87.8) on windows 7 x86 under cygwin environment.
cannot reproduce this issue on Windows.

Comment 6 Rob Millner 2012-03-08 20:03:23 UTC
Whether '--wildcards' is required or cannot be used seems to vary by the platform.  Windows requires it.  MacOSX must not have it.

Comment 7 John (J5) Palmieri 2012-03-30 20:23:09 UTC
https://developer.apple.com/library/mac/#documentation/Darwin/Reference/Manpages/man1/tar.1.html

OsX uses BSD's tar. --wildcard might be a GNU extension.

A couple of solutions - 

1) untar on the server, then we never have to worry about different options for tar

2) get a list of files from the archive, do our own globbing and output a file with a list of files we want to extract, use the -T option to pass that file list to tar.

Comment 8 John (J5) Palmieri 2012-04-09 19:57:03 UTC
fixed in git 6538e748e88add96b4395242b04511f2765fca48

I was unable to check on MacOSX as I do not have access to a Mac machine. Works under Linux.  Keep an eye out for any regressions though there shouldn't be any.

Comment 9 John (J5) Palmieri 2012-04-09 19:57:55 UTC
just a note.  Fix was to use gnutar if it exists.  gnutar should be installed by default on OsX >= 10.6

Comment 10 Meng Bo 2012-04-11 09:01:30 UTC
checked on rhc-0.90.1,
'rhc app snapshot restore' works fine,
and 'rhc-snapshot -r' not works well,
will wait for the latest rhc client to test again.

Comment 11 John (J5) Palmieri 2012-04-11 17:09:29 UTC
just noticed that rhc-snapshot and rhc app snapshot restore are two separate code paths.  If rhc-snapshot -r still doesn't work I can simply port the code from rhc app snapshot restore as they should work the same.  Though I am not sure if tar on OS X will work with wildcards.

Comment 12 John (J5) Palmieri 2012-04-11 17:23:20 UTC
For sure rhc app snapshot restore won't work on OS X except by pure luck

http://docstore.mik.ua/orelly/unix3/upt/ch38_10.htm

rhc-snapshot -r should with my fixes (unless gnutar is not shipped with OS X).  Can you specify which client you are testing on when commenting.  There should be a matrix as such -

Windows - Pass
Linux   - Pass
OS X    - Fail:
  <error message>

Unix Power Tools book does point to a hack that can be used in place of --wildcard if gnutar is not on OS X by default.  The only ref I could find was a list of Open Source tools that apple ships with OS X but that doesn't mean it install it.

Comment 13 Meng Bo 2012-04-17 03:20:08 UTC
verified with rhc-0.90.5 and rhc-rest-0.0.14,
issue has been fixed.