ceph-objectstore-tool: Better messages for bad --journal-path

Signed-off-by: David Zafman <dzafman@redhat.com>
This commit is contained in:
David Zafman 2017-09-08 17:09:48 -07:00
parent 3ac219df2d
commit 49ca1fff7f
2 changed files with 20 additions and 0 deletions

View File

@ -995,6 +995,12 @@ def main(argv):
cmd = "{path}/ceph-objectstore-tool --journal-path BAD_JOURNAL_PATH --op dump-journal".format(path=CEPH_BIN)
ERRORS += test_failure(cmd, "journal-path: BAD_JOURNAL_PATH: (2) No such file or directory")
cmd = (CFSD_PREFIX + "--journal-path BAD_JOURNAL_PATH --op list").format(osd=ONEOSD)
ERRORS += test_failure(cmd, "journal-path: BAD_JOURNAL_PATH: No such file or directory")
cmd = (CFSD_PREFIX + "--journal-path /bin --op list").format(osd=ONEOSD)
ERRORS += test_failure(cmd, "journal-path: /bin: (21) Is a directory")
# On import can't use stdin from a terminal
cmd = (CFSD_PREFIX + "--op import --pgid {pg}").format(osd=ONEOSD, pg=ONEPG)
ERRORS += test_failure(cmd, "stdin is a tty and no --file filename specified", tty=True)

View File

@ -2772,6 +2772,20 @@ int main(int argc, char **argv)
return 1;
}
//Verify that the journal-path really exists
if (type == "filestore") {
if (::stat(jpath.c_str(), &st) == -1) {
string err = string("journal-path: ") + jpath;
perror(err.c_str());
return 1;
}
if (S_ISDIR(st.st_mode)) {
cerr << "journal-path: " << jpath << ": "
<< cpp_strerror(EISDIR) << std::endl;
return 1;
}
}
ObjectStore *fs = ObjectStore::create(g_ceph_context, type, dpath, jpath, flags);
if (fs == NULL) {
cerr << "Unable to create store of type " << type << std::endl;