uint64_t snap_id;
if (is_remote) {
if (!info.nr_snap_metadata) {
- derr << ": snap_path=" << snap_path << " has invalid metadata in remote snapshot"
- << dendl;
+ std::string failed_reason = "snapshot '" + snap + "' has invalid metadata";
+ derr << ": " << failed_reason << dendl;
+ m_snap_sync_stats.at(dir_root).last_failed_reason = failed_reason;
rv = -EINVAL;
} else {
auto metadata = decode_snap_metadata(info.snap_metadata, info.nr_snap_metadata);
f->open_object_section(dir_root);
if (sync_stat.failed) {
f->dump_string("state", "failed");
+ if (sync_stat.last_failed_reason) {
+ f->dump_string("failure_reason", *sync_stat.last_failed_reason);
+ }
} else if (!sync_stat.current_syncing_snap) {
f->dump_string("state", "idle");
} else {
struct SnapSyncStat {
uint64_t nr_failures = 0; // number of consecutive failures
boost::optional<monotime> last_failed; // lat failed timestamp
+ boost::optional<std::string> last_failed_reason;
bool failed = false; // hit upper cap for consecutive failures
boost::optional<std::pair<uint64_t, std::string>> last_synced_snap;
boost::optional<std::pair<uint64_t, std::string>> current_syncing_snap;
sync_stat.nr_failures = 0;
sync_stat.failed = false;
sync_stat.last_failed = boost::none;
+ sync_stat.last_failed_reason = boost::none;
}
void _set_last_synced_snap(const std::string &dir_root, uint64_t snap_id,