} else {
f->open_object_section("version");
if (command == "version") {
- f->dump_string("version", ceph_version_to_str());
+ f->dump_string("version", ceph_version_to_str(nullptr));
f->dump_string("release", ceph_release_to_str());
f->dump_string("release_type", ceph_release_type());
} else if (command == "git_version") {
.set_description("Size of thread pool for ASIO completions")
.add_tag("client"),
+ Option("debug_version_for_testing", Option::TYPE_STR, Option::LEVEL_DEV)
+ .set_default("")
+ .set_description("Override ceph_version_short for testing"),
+
Option("client_shutdown_timeout", Option::TYPE_SECS, Option::LEVEL_ADVANCED)
.set_flag(Option::FLAG_RUNTIME)
.set_default(30)
{
// version
(*m)["ceph_version"] = pretty_version_to_str();
- (*m)["ceph_version_short"] = ceph_version_to_str();
+ (*m)["ceph_version_short"] = ceph_version_to_str(cct);
(*m)["ceph_release"] = ceph_release_to_str();
#ifndef _WIN32
#define _STR(x) #x
#define STRINGIFY(x) _STR(x)
-const char *ceph_version_to_str(void)
+// Keep ver.c_str() available
+static std::string ver;
+
+const char *ceph_version_to_str(CephContext *cct)
{
+ if (cct) ver = cct->_conf.get_val<std::string>("debug_version_for_testing");
+ if (ver.size() > 0)
+ return ver.c_str();
return CEPH_GIT_NICE_VER;
}
#define CEPH_COMMON_VERSION_H
#include <string>
+#include "common/ceph_context.h"
// Return a string describing the Ceph version
-const char *ceph_version_to_str(void);
+const char *ceph_version_to_str(CephContext *cct);
// Return a string with the Ceph release
const char *ceph_release_to_str(void);
{
unique_ptr<Formatter> f{Formatter::create(format, "json-pretty", "json-pretty")};
f->open_object_section("version");
- f->dump_string("version", ceph_version_to_str());
+ f->dump_string("version", ceph_version_to_str(nullptr));
f->dump_string("release", ceph_release_to_str());
f->dump_string("release_type", ceph_release_type());
f->close_section();
now.gmtime(jf.dump_stream("timestamp"));
jf.dump_string("process_name", g_process_name);
jf.dump_string("entity_name", g_ceph_context->_conf->name.to_str());
- jf.dump_string("ceph_version", ceph_version_to_str());
+ jf.dump_string("ceph_version", ceph_version_to_str(g_ceph_context));
struct utsname u;
r = uname(&u);
extern "C" const char *ceph_version(int *pmajor, int *pminor, int *ppatch)
{
int major, minor, patch;
- const char *v = ceph_version_to_str();
+ const char *v = ceph_version_to_str(nullptr);
int n = sscanf(v, "%d.%d.%d", &major, &minor, &patch);
if (pmajor)
f.reset(Formatter::create("json-pretty"));
f->open_object_section("report");
f->dump_stream("cluster_fingerprint") << fingerprint;
- f->dump_string("version", ceph_version_to_str());
+ f->dump_string("version", ceph_version_to_str(cct));
f->dump_string("commit", git_version_to_str());
f->dump_stream("timestamp") << ceph_clock_now();
int CacheClient::register_client(Context* on_finish) {
ObjectCacheRequest* reg_req = new ObjectCacheRegData(RBDSC_REGISTER,
m_sequence_id++,
- ceph_version_to_str());
+ ceph_version_to_str(m_cct));
reg_req->encode();
bufferlist bl;