]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
tools: refuse to start if obj cache daemon fail to initialize cache dir
authorYuan Zhou <yuan.zhou@intel.com>
Thu, 17 Jan 2019 15:37:12 +0000 (23:37 +0800)
committerYuan Zhou <yuan.zhou@intel.com>
Thu, 21 Mar 2019 16:16:27 +0000 (00:16 +0800)
Signed-off-by: Yuan Zhou <yuan.zhou@intel.com>
src/tools/immutable_object_cache/ObjectCacheStore.cc
src/tools/immutable_object_cache/main.cc

index ea066e6d7f9ba1d38e919c88d8e352e09d767736..cb5a84e9c05c69dacbe16c208697c64fa121d600 100644 (file)
@@ -51,10 +51,18 @@ int ObjectCacheStore::init(bool reset) {
 
   //TODO(): fsck and reuse existing cache objects
   if (reset) {
+    std::error_code ec;
     if (efs::exists(m_cache_root_dir)) {
-      efs::remove_all(m_cache_root_dir);
+      if (!efs::remove_all(m_cache_root_dir, ec)) {
+        lderr(m_cct) << "fail to remove old cache store: " << ec << dendl;
+       return -1;
+      }
+    }
+
+    if (!efs::create_directories(m_cache_root_dir, ec)) {
+        lderr(m_cct) << "fail to create cache store dir: " << ec << dendl;
+       return -1;
     }
-    efs::create_directories(m_cache_root_dir);
   }
 
   return ret;
index a030c5cdbbe91a17076c43ca1783fb8f1ea276d1..dffae87acc95a3b1166fe4fefcd894ad00ee9c20 100644 (file)
@@ -35,17 +35,15 @@ int main(int argc, const char **argv)
   env_to_vec(args);
   argv_to_vec(argc, argv, args);
 
+  if (ceph_argparse_need_usage(args)) {
+    usage();
+    exit(0);
+  }
+
   auto cct = global_init(nullptr, args, CEPH_ENTITY_TYPE_CLIENT,
                         CODE_ENVIRONMENT_DAEMON,
                         CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS);
 
-  for (auto i = args.begin(); i != args.end(); ++i) {
-    if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
-      usage();
-      return EXIT_SUCCESS;
-    }
-  }
-
   if (g_conf()->daemonize) {
     global_init_daemonize(g_ceph_context);
   }