}
cmd += "]}";
- dout(10) << __func__ << " cmd: " << cmd << dendl;
- vector<string> vcmd{cmd};
- bufferlist inbl;
-
- C_SaferCond w;
- string outs;
- int r = monc->start_mon_command(vcmd, inbl, NULL, &outs, &w);
- if (r == 0)
- r = w.wait();
- if (r < 0) {
- derr << __func__ << " fail: '" << outs << "': " << cpp_strerror(r) << dendl;
- return r;
+ bool created = false;
+ while (true) {
+ dout(10) << __func__ << " cmd: " << cmd << dendl;
+ vector<string> vcmd{cmd};
+ bufferlist inbl;
+ C_SaferCond w;
+ string outs;
+ int r = monc->start_mon_command(vcmd, inbl, NULL, &outs, &w);
+ if (r == 0)
+ r = w.wait();
+ if (r < 0) {
+ if (r == -ENOENT && !created) {
+ string newcmd = "{\"prefix\": \"osd create\", \"id\": " + stringify(whoami)
+ + ", \"uuid\": \"" + stringify(superblock.osd_fsid) + "\"}";
+ vector<string> vnewcmd{newcmd};
+ bufferlist inbl;
+ C_SaferCond w;
+ string outs;
+ int r = monc->start_mon_command(vnewcmd, inbl, NULL, &outs, &w);
+ if (r == 0)
+ r = w.wait();
+ if (r < 0) {
+ derr << __func__ << " fail: osd does not exist and created failed: "
+ << cpp_strerror(r) << dendl;
+ return r;
+ }
+ created = true;
+ continue;
+ }
+ derr << __func__ << " fail: '" << outs << "': " << cpp_strerror(r) << dendl;
+ return r;
+ }
+ break;
}
return 0;