in
e5b1ae5554c4d8a20f9f0ff562b231ad0b0ba0ab, a new option named
"debug_version_for_testing" is introduced to override the version so
we can test version check.
in crimson, we have two families of shared functions.
- one of them is used by alien store. they are compiled with
-DWITH_SEASTAR and -DWITH_ALIEN, to enable the shim code between
seastar and POSIX thread.
- another is used by crimson in general. where no lock is allowed.
currently, we use the "crimson" and "ceph" namespace to differentiate
these two families of functions, so they can colocate in the same
executable without violating the ODR. see src/include/common_fwd.h for
more details.
the functions defined in src/common/version.cc are also shared by
alien store and crimson code. and because we have different
implementations of `CephContext` in crimson and in classic OSD (i.e.
alienstore), we have to have different implementations of this function
as well, if we follow the same approach. but since these functions are
very simple and are non-blocking, there is not much value in
differentiating them, it is better to inject the test settings using
environment variable instead of using ceph option subsystem.
in this change, "ceph_debug_version_for_testing" environment variable is
checked instead, so that crimson and alienstore can share the same
compilation unit of version.cc. and "debug_version_for_testing" option
is removed.
Signed-off-by: Kefu Chai <kchai@redhat.com>
ceph health detail | grep DAEMON_OLD_VERSION && return 1
kill_daemons $dir KILL osd.1
- EXTRA_OPTS=" --debug_version_for_testing=01.00.00-gversion-test" activate_osd $dir 1
+ ceph_debug_version_for_testing=01.00.00-gversion-test activate_osd $dir 1
wait_for_health_string "HEALTH_WARN .*There is a daemon running an older version of ceph" || return 1
ceph health detail | grep -q "osd.1 is running an older version of ceph: 01.00.00-gversion-test" || return 1
kill_daemons $dir KILL osd.2
- EXTRA_OPTS=" --debug_version_for_testing=01.00.00-gversion-test" activate_osd $dir 2
+ ceph_debug_version_for_testing=01.00.00-gversion-test activate_osd $dir 2
kill_daemons $dir KILL osd.0
- EXTRA_OPTS=" --debug_version_for_testing=02.00.00-gversion-test" activate_osd $dir 0
+ ceph_debug_version_for_testing=02.00.00-gversion-test activate_osd $dir 0
wait_for_health_string "HEALTH_ERR .*There are daemons running multiple old versions of ceph" || return 1
ceph health detail | grep DAEMON_OLD_VERSION && return 1
kill_daemons $dir KILL mon.b
- EXTRA_OPTS=" --debug_version_for_testing=01.00.00-gversion-test" run_mon $dir b --mon_warn_older_version_delay=0.0
+ ceph_debug_version_for_testing=01.00.00-gversion-test run_mon $dir b --mon_warn_older_version_delay=0.0
# XXX: Manager doesn't seem to use the test specific config for version
#kill_daemons $dir KILL mgr.x
- #EXTRA_OPTS=" --debug_version_for_testing=02.00.00-gversion-test" run_mgr $dir x
+ #ceph_debug_version_for_testing=02.00.00-gversion-test run_mgr $dir x
kill_daemons $dir KILL mds.m
- EXTRA_OPTS=" --debug_version_for_testing=01.00.00-gversion-test" run_mds $dir m
+ ceph_debug_version_for_testing=01.00.00-gversion-test run_mds $dir m
wait_for_health_string "HEALTH_WARN .*There are daemons running an older version of ceph" || return 1
ceph health detail | grep -q "mon.b mds.m are running an older version of ceph: 01.00.00-gversion-test" || return 1
kill_daemons $dir KILL osd.2
- EXTRA_OPTS=" --debug_version_for_testing=01.00.00-gversion-test" activate_osd $dir 2
+ ceph_debug_version_for_testing=01.00.00-gversion-test activate_osd $dir 2
kill_daemons $dir KILL osd.0
- EXTRA_OPTS=" --debug_version_for_testing=02.00.00-gversion-test" activate_osd $dir 0
+ ceph_debug_version_for_testing=02.00.00-gversion-test activate_osd $dir 0
wait_for_health_string "HEALTH_ERR .*There are daemons running multiple old versions of ceph" || return 1
ceph health detail | grep DAEMON_OLD_VERSION && return 1
kill_daemons $dir KILL osd.1
- EXTRA_OPTS=" --debug_version_for_testing=01.00.00-gversion-test" activate_osd $dir 1
+ ceph_debug_version_for_testing=01.00.00-gversion-test activate_osd $dir 1
# Wait 50% of 20 second delay config
sleep 10
ceph health detail | grep -q "osd.1 is running an older version of ceph: 01.00.00-gversion-test" || return 1
kill_daemons $dir KILL osd.2
- EXTRA_OPTS=" --debug_version_for_testing=01.00.00-gversion-test" activate_osd $dir 2
+ ceph_debug_version_for_testing=01.00.00-gversion-test activate_osd $dir 2
kill_daemons $dir KILL osd.0
- EXTRA_OPTS=" --debug_version_for_testing=02.00.00-gversion-test" activate_osd $dir 0
+ ceph_debug_version_for_testing=02.00.00-gversion-test activate_osd $dir 0
wait_for_health_string "HEALTH_ERR .*There are daemons running multiple old versions of ceph" || return 1
} else {
f->open_object_section("version");
if (command == "version") {
-#ifndef WITH_ALIEN
- f->dump_string("version", ceph_version_to_str(nullptr));
-#endif
+ f->dump_string("version", ceph_version_to_str());
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(cct);
+ (*m)["ceph_version_short"] = ceph_version_to_str();
(*m)["ceph_release"] = ceph_release_to_str();
#ifndef _WIN32
#include "common/version.h"
-#include <string.h>
+#include <stdlib.h>
#include <sstream>
#include "ceph_ver.h"
#define _STR(x) #x
#define STRINGIFY(x) _STR(x)
-// Keep ver.c_str() available
-static std::string ver;
-
-const char *ceph_version_to_str(CephContext *cct)
+const char *ceph_version_to_str()
{
- 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;
+ char* debug_version_for_testing = getenv("ceph_debug_version_for_testing");
+ if (debug_version_for_testing) {
+ return debug_version_for_testing;
+ } else {
+ return CEPH_GIT_NICE_VER;
+ }
}
const char *ceph_release_to_str(void)
#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(CephContext *cct);
+const char *ceph_version_to_str();
// 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(nullptr));
+ f->dump_string("version", ceph_version_to_str());
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(g_ceph_context));
+ jf.dump_string("ceph_version", ceph_version_to_str());
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(nullptr);
+ const char *v = ceph_version_to_str();
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(cct));
+ f->dump_string("version", ceph_version_to_str());
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(m_cct));
+ ceph_version_to_str());
reg_req->encode();
bufferlist bl;