| 336 | } |
| 337 | |
| 338 | void MgrMonitor::encode_pending(MonitorDBStore::TransactionRef t) |
| 339 | { |
| 340 | dout(10) << __func__ << " " << pending_map << dendl; |
| 341 | bufferlist bl; |
| 342 | pending_map.encode(bl, mon.get_quorum_con_features()); |
| 343 | put_version(t, pending_map.epoch, bl); |
| 344 | put_last_committed(t, pending_map.epoch); |
| 345 | |
| 346 | for (auto& p : pending_metadata) { |
| 347 | dout(10) << __func__ << " set metadata for " << p.first << dendl; |
| 348 | t->put(MGR_METADATA_PREFIX, p.first, p.second); |
| 349 | } |
| 350 | for (auto& name : pending_metadata_rm) { |
| 351 | dout(10) << __func__ << " rm metadata for " << name << dendl; |
| 352 | t->erase(MGR_METADATA_PREFIX, name); |
| 353 | } |
| 354 | pending_metadata.clear(); |
| 355 | pending_metadata_rm.clear(); |
| 356 | |
| 357 | health_check_map_t next; |
| 358 | if (pending_map.active_gid == 0) { |
| 359 | auto level = should_warn_about_mgr_down(); |
| 360 | if (level != HEALTH_OK) { |
| 361 | next.add("MGR_DOWN", level, "no active mgr", 0); |
| 362 | } else { |
| 363 | dout(10) << __func__ << " no health warning (never active and new cluster)" |
| 364 | << dendl; |
| 365 | } |
| 366 | } else { |
| 367 | put_value(t, "ever_had_active_mgr", 1); |
| 368 | } |
| 369 | encode_health(next, t); |
| 370 | |
| 371 | if (pending_command_descs.size()) { |
| 372 | dout(4) << __func__ << " encoding " << pending_command_descs.size() |
| 373 | << " command_descs" << dendl; |
| 374 | for (auto& p : pending_command_descs) { |
| 375 | p.set_flag(MonCommand::FLAG_MGR); |
| 376 | } |
| 377 | bufferlist bl; |
| 378 | encode(pending_command_descs, bl); |
| 379 | t->put(command_descs_prefix, "", bl); |
| 380 | pending_command_descs.clear(); |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | bool MgrMonitor::check_caps(MonOpRequestRef op, const uuid_d& fsid) |
| 385 | { |