This patch fix the problem as below. this is the first cluster snapshot I try to save, but I forgot to snapshot the vdi:
dog cluster snapshot save first cluster_snapshots Object not found. It may be caused by: 1. The cluster is empty. 2. All VDIs of the cluster don't have snapshots. and that's right! Then I take vdi snapshot and save cluster snapshot, then remove vdi snapshots. Now I try to make the same mistake dog cluster snapshot save second cluster_snapshots 100.0 % [=====] 4 / 4 There are no vdi snapshots and dog doesn't complain about it! It did it only the first time. Reported-by: Valerio Pachera <siri...@gmail.com> Signed-off-by: Ruoyu <lian...@ucweb.com> --- dog/cluster.c | 8 ++++++-- dog/farm/farm.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dog/cluster.c b/dog/cluster.c index 7c4856d..e42bc54 100644 --- a/dog/cluster.c +++ b/dog/cluster.c @@ -365,6 +365,9 @@ static void fill_object_tree(uint32_t vid, const char *name, const char *tag, return; } + if (i->name[0] != '\0') + opt->nr_snapshot++; + /* fill vdi object id */ object_tree_insert(vdi_oid, i->nr_copies, i->copy_policy); @@ -417,14 +420,15 @@ static int save_snapshot(int argc, char **argv) goto out; } + opt.nr_snapshot = 0; opt.count = argc - optind; opt.name = argv + optind; if (parse_vdi(fill_object_tree, SD_INODE_SIZE, &opt, false) != SD_RES_SUCCESS) goto out; - if (object_tree_size() == 0) { - sd_err("Object not found. It may be caused by:"); + if (opt.nr_snapshot == 0) { + sd_err("Cannot execute. It may be caused by:"); if (opt.count > 0) { sd_err("1. The specified VDIs are not found."); sd_err("2. The specified VDIs don't have snapshots."); diff --git a/dog/farm/farm.h b/dog/farm/farm.h index 745aa15..f4ec47f 100644 --- a/dog/farm/farm.h +++ b/dog/farm/farm.h @@ -50,6 +50,7 @@ struct snap_log { }; struct vdi_option { + int nr_snapshot; int count; char **name; void (*func)(struct sd_inode *inode); -- 1.8.3.2 -- sheepdog mailing list sheepdog@lists.wpkg.org http://lists.wpkg.org/mailman/listinfo/sheepdog