Skip to content

Commit

Permalink
common: verify unix sockets support on Windows
Browse files Browse the repository at this point in the history
Windows Server 2016 doesn't support unix sockets. We'll
check the Windows version and log a message (but not at
error level) when attempting to initialize the admin socket.

This will prevent the following error from being printed
whenever mapping RBD images:

  AdminSocketConfigObs::init: failed: AdminSocket::bind_and_listen:
  failed to bind the UNIX domain socket to
  'C:/ProgramData/Ceph/out/client.admin.2560.asok':
  (10050) Unknown error

Signed-off-by: Lucian Petrut <[email protected]>
  • Loading branch information
petrutlucian94 committed Oct 28, 2020
1 parent 42b69e2 commit 948ffd4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/common/admin_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,19 @@ bool AdminSocket::init(const std::string& path)
{
ldout(m_cct, 5) << "init " << path << dendl;

#ifdef _WIN32
OSVERSIONINFOEXW ver = {0};
ver.dwOSVersionInfoSize = sizeof(ver);
get_windows_version(&ver);

if (std::tie(ver.dwMajorVersion, ver.dwMinorVersion, ver.dwBuildNumber) <
std::make_tuple(10, 0, 17063)) {
ldout(m_cct, 5) << "Unix sockets require Windows 10.0.17063 or later. "
<< "The admin socket will not be available." << dendl;
return false;
}
#endif

/* Set up things for the new thread */
std::string err;
int pipe_rd = -1, pipe_wr = -1;
Expand Down
5 changes: 5 additions & 0 deletions src/include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ int get_cgroup_memory_limit(uint64_t *limit);
/// collect info from @p uname(2), @p /proc/meminfo and @p /proc/cpuinfo
void collect_sys_info(std::map<std::string, std::string> *m, CephContext *cct);

#ifdef _WIN32
/// Retrieve the actual Windows version, regardless of the app manifest.
int get_windows_version(POSVERSIONINFOEXW ver);
#endif

/// dump service ids grouped by their host to the specified formatter
/// @param f formatter for the output
/// @param services a map from hostname to a list of service id hosted by this host
Expand Down

0 comments on commit 948ffd4

Please sign in to comment.