Skip to content

Commit

Permalink
ENG-3080: Add version info to log file including build timestamp and …
Browse files Browse the repository at this point in the history
…git commit ID.

Summary:
- Added version info to log file including build timestamp and git commit ID.
- The same version info is displayed in internal UI and using cmd line flag `--version`.

Test Plan:
- Run local cluster.
- Check http://localhost:7001
- Check `yb-tserver --version`, `yb-master --version`
- Check log files header.

Reviewers: mikhail, bogdan, hector

Reviewed By: hector

Subscribers: ybase, bharat

Differential Revision: https://phabricator.dev.yugabyte.com/D4388
  • Loading branch information
ttyusupov committed Mar 19, 2018
1 parent f9bafcc commit 6f9bdef
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/yb/master/master_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ static int MasterMain(int argc, char** argv) {
return 1;
}

LOG_AND_RETURN_FROM_MAIN_NOT_OK(InitYB(MasterOptions::kServerType));
InitGoogleLoggingSafe(argv[0]);
LOG_AND_RETURN_FROM_MAIN_NOT_OK(InitYB(MasterOptions::kServerType, argv[0]));

auto opts_result = MasterOptions::CreateMasterOptions();
LOG_AND_RETURN_FROM_MAIN_NOT_OK(opts_result);
Expand Down
3 changes: 1 addition & 2 deletions src/yb/tserver/tablet_server_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ static int TabletServerMain(int argc, char** argv) {
std::cerr << "usage: " << argv[0] << std::endl;
return 1;
}
LOG_AND_RETURN_FROM_MAIN_NOT_OK(InitYB(TabletServerOptions::kServerType));
InitGoogleLoggingSafe(argv[0]);
LOG_AND_RETURN_FROM_MAIN_NOT_OK(InitYB(TabletServerOptions::kServerType, argv[0]));

#ifdef TCMALLOC_ENABLED
LOG(INFO) << "Setting tcmalloc max thread cache bytes to: " <<
Expand Down
8 changes: 6 additions & 2 deletions src/yb/util/init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "yb/util/env.h"
#include "yb/util/env_util.h"
#include "yb/util/flag_tags.h"
#include "yb/util/logging.h"
#include "yb/util/path_util.h"
#include "yb/util/status.h"
#include "yb/util/version_info.h"
Expand Down Expand Up @@ -101,10 +102,13 @@ Status SetupLogDir(const std::string& server_type) {
return Status::OK();
}

Status InitYB(const std::string &server_type) {
Status InitYB(const std::string &server_type, const char* argv0) {
RETURN_NOT_OK(CheckCPUFlags());
RETURN_NOT_OK(SetupLogDir(server_type));
return VersionInfo::Init();
RETURN_NOT_OK(VersionInfo::Init());
InitGoogleLoggingSafe(argv0);
LOG(INFO) << VersionInfo::GetShortVersionString();
return Status::OK();
}

} // namespace yb
3 changes: 2 additions & 1 deletion src/yb/util/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ CHECKED_STATUS SetupLogDir(const std::string& server_type);

// Initialize YB, checking that the platform we are running on is supported, etc.
// Issues a FATAL log message if we fail to init.
CHECKED_STATUS InitYB(const std::string &server_type);
// argv0 is passed to InitGoogleLoggingSafe.
CHECKED_STATUS InitYB(const std::string &server_type, const char* argv0);

} // namespace yb
#endif /* YB_UTIL_INIT_H */
8 changes: 5 additions & 3 deletions src/yb/util/version_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,20 @@ string VersionInfo::GetGitHash() {
string VersionInfo::GetShortVersionString() {
auto* data = GetVersionData();

return strings::Substitute("version $0 build $1 build_type $2",
return strings::Substitute("version $0 build $1 revision $2 build_type $3 built at $4",
data->version_number(),
data->build_number(),
data->build_type());
data->git_hash(),
data->build_type(),
data->build_timestamp());
}

string VersionInfo::GetAllVersionInfo() {
auto* data = GetVersionData();

string ret = strings::Substitute(
"version $0\n"
"build $1"
"build $1\n"
"revision $2\n"
"build_type $3\n"
"built by $4 at $5 on $6",
Expand Down
3 changes: 1 addition & 2 deletions src/yb/yql/cql/cqlserver/cql_server_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ static int CQLServerMain(int argc, char** argv) {
std::cerr << "usage: " << argv[0] << std::endl;
return 1;
}
LOG_AND_RETURN_FROM_MAIN_NOT_OK(InitYB("cqlserver"));
InitGoogleLoggingSafe(argv[0]);
LOG_AND_RETURN_FROM_MAIN_NOT_OK(InitYB("cqlserver", argv[0]));

CQLServerOptions cql_server_options;
cql_server_options.rpc_opts.rpc_bind_addresses = FLAGS_cql_proxy_bind_address;
Expand Down
3 changes: 1 addition & 2 deletions src/yb/yql/redis/redisserver/redis_server_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ static int RedisServerMain(int argc, char** argv) {
std::cerr << "usage: " << argv[0] << std::endl;
return 1;
}
LOG_AND_RETURN_FROM_MAIN_NOT_OK(InitYB("redisserver"));
InitGoogleLoggingSafe(argv[0]);
LOG_AND_RETURN_FROM_MAIN_NOT_OK(InitYB("redisserver", argv[0]));

RedisServerOptions opts;
opts.rpc_opts.rpc_bind_addresses = FLAGS_redis_proxy_bind_address;
Expand Down

0 comments on commit 6f9bdef

Please sign in to comment.