This is an automated email from the ASF dual-hosted git repository.

bbannier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git


The following commit(s) were added to refs/heads/master by this push:
     new 3d197d8  Fixed the build on Windows.
3d197d8 is described below

commit 3d197d8e815f1f2de0565ce64547f409997c5e82
Author: Benjamin Bannier <[email protected]>
AuthorDate: Mon Feb 3 09:30:25 2020 +0100

    Fixed the build on Windows.
    
    The addition of executor domain socket support broke the build on
    Windows. This patch updates preprocessor directives in order to fix
    the build.
    
    Review: https://reviews.apache.org/r/72070/
---
 src/executor/executor.cpp         |  8 +++++++-
 src/launcher/default_executor.cpp |  6 ++++--
 src/local/local.cpp               |  2 ++
 src/slave/flags.cpp               |  7 +++++++
 src/slave/main.cpp                | 12 ++++++++++++
 src/slave/slave.cpp               |  6 ++++++
 src/slave/slave.hpp               |  5 +++++
 src/tests/cluster.cpp             | 10 ++++++++++
 src/tests/mock_slave.cpp          |  2 ++
 9 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/src/executor/executor.cpp b/src/executor/executor.cpp
index 7cff258..213f38e 100644
--- a/src/executor/executor.cpp
+++ b/src/executor/executor.cpp
@@ -43,7 +43,10 @@
 #include <stout/unreachable.hpp>
 #include <stout/uuid.hpp>
 
+#ifndef __WINDOWS__
 #include "common/domain_sockets.hpp"
+#endif // __WINDOWS__
+
 #include "common/http.hpp"
 #include "common/recordio.hpp"
 #include "common/validation.hpp"
@@ -233,6 +236,7 @@ public:
     }
 #endif // USE_SSL_SOCKET
 
+#ifndef __WINDOWS__
     value = env.get("MESOS_DOMAIN_SOCKET");
     if (value.isSome()) {
       string scheme = "http+unix";
@@ -269,7 +273,9 @@ public:
           scheme,
           path,
           upid.id + "/api/v1/executor");
-    } else {
+    } else
+#endif
+    {
       agent = ::URL(
           scheme,
           upid.address.ip,
diff --git a/src/launcher/default_executor.cpp 
b/src/launcher/default_executor.cpp
index 4369fd0..7997003 100644
--- a/src/launcher/default_executor.cpp
+++ b/src/launcher/default_executor.cpp
@@ -1730,6 +1730,7 @@ int main(int argc, char** argv)
   UPID upid(value.get());
   CHECK(upid) << "Failed to parse MESOS_SLAVE_PID '" << value.get() << "'";
 
+#ifndef __WINDOWS__
   value = os::getenv("MESOS_DOMAIN_SOCKET");
   if (value.isSome()) {
     // The previous value of `scheme` can be ignored here, since we do not
@@ -1764,8 +1765,9 @@ int main(int argc, char** argv)
         scheme,
         path,
         upid.id + "/api/v1");
-
-  } else {
+  } else
+#endif // __WINDOWS__
+  {
     agent = ::URL(
         scheme,
         upid.address.ip,
diff --git a/src/local/local.cpp b/src/local/local.cpp
index 6a7709d..8950570 100644
--- a/src/local/local.cpp
+++ b/src/local/local.cpp
@@ -535,7 +535,9 @@ PID<Master> launch(const Flags& flags, Allocator* 
_allocator)
         secretGenerators->back(),
         nullptr,
         nullptr,
+#ifndef __WINDOWS__
         None(),
+#endif // __WINDOWS__
         authorizer_); // Same authorizer as master.
 
     slaves[containerizer.get()] = slave;
diff --git a/src/slave/flags.cpp b/src/slave/flags.cpp
index 7653c39..0f159a3 100644
--- a/src/slave/flags.cpp
+++ b/src/slave/flags.cpp
@@ -25,7 +25,10 @@
 
 #include <mesos/type_utils.hpp>
 
+#ifndef __WINDOWS__
 #include "common/domain_sockets.hpp"
+#endif // __WINDOWS__
+
 #include "common/http.hpp"
 #include "common/parse.hpp"
 #include "common/protobuf_utils.hpp"
@@ -985,6 +988,7 @@ mesos::internal::slave::Flags::Flags()
 #endif // __WINDOWS__
       );
 
+#ifndef __WINDOWS__
   add(&Flags::domain_socket_location,
       "domain_socket_location",
       "Location on the host filesystem of the domain socket used for\n"
@@ -1003,6 +1007,7 @@ mesos::internal::slave::Flags::Flags()
 
         return None();
       });
+#endif // __WINDOWS__
 
   add(&Flags::default_container_dns,
       "default_container_dns",
@@ -1401,12 +1406,14 @@ mesos::internal::slave::Flags::Flags()
       false);
 #endif // USE_SSL_SOCKET
 
+#ifndef __WINDOWS__
   add(&Flags::http_executor_domain_sockets,
       "http_executor_domain_sockets",
       "If true, the agent will provide a unix domain sockets that the\n"
       "executor can use to connect to the agent, instead of relying on\n"
       "a TCP connection.",
       false);
+#endif // __WINDOWS__
 
   add(&Flags::http_credentials,
       "http_credentials",
diff --git a/src/slave/main.cpp b/src/slave/main.cpp
index b5715d9..c1e6551 100644
--- a/src/slave/main.cpp
+++ b/src/slave/main.cpp
@@ -62,7 +62,11 @@
 
 #include "common/authorization.hpp"
 #include "common/build.hpp"
+
+#ifndef __WINDOWS__
 #include "common/domain_sockets.hpp"
+#endif // __WINDOWS__
+
 #include "common/http.hpp"
 
 #include "hook/manager.hpp"
@@ -112,7 +116,9 @@ using process::Owned;
 using process::firewall::DisabledEndpointsFirewallRule;
 using process::firewall::FirewallRule;
 
+#ifndef __WINDOWS__
 using process::network::unix::Socket;
+#endif // __WINDOWS__
 
 using std::cerr;
 using std::cout;
@@ -352,6 +358,7 @@ int main(int argc, char** argv)
     os::setenv("LIBPROCESS_ADVERTISE_PORT", flags.advertise_port.get());
   }
 
+#ifndef __WINDOWS__
   if (flags.http_executor_domain_sockets) {
     if (flags.domain_socket_location.isNone()) {
       flags.domain_socket_location =
@@ -365,6 +372,7 @@ int main(int argc, char** argv)
         << " must have less than 108 characters.";
     }
   }
+#endif // __WINDOWS__
 
   os::setenv("LIBPROCESS_MEMORY_PROFILING", stringify(flags.memory_profiling));
 
@@ -629,6 +637,7 @@ int main(int argc, char** argv)
   }
 #endif // USE_SSL_SOCKET
 
+#ifndef __WINDOWS__
   // Create executor domain socket if the user so desires.
   Option<Socket> executorSocket = None();
   if (flags.http_executor_domain_sockets) {
@@ -696,6 +705,7 @@ int main(int argc, char** argv)
 
     LOG(INFO) << "Using domain socket at " << *flags.domain_socket_location;
   }
+#endif // __WINDOWS__
 
   Slave* slave = new Slave(
       id,
@@ -710,7 +720,9 @@ int main(int argc, char** argv)
       secretGenerator,
       volumeGidManager,
       futureTracker.get(),
+#ifndef __WINDOWS__
       executorSocket,
+#endif // __WINDOWS__
       authorizer_);
 
   process::spawn(slave);
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 4c3d471..75bf595 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -200,7 +200,9 @@ Slave::Slave(const string& id,
              SecretGenerator* _secretGenerator,
              VolumeGidManager* _volumeGidManager,
              PendingFutureTracker* _futureTracker,
+#ifndef __WINDOWS__
              const Option<process::network::unix::Socket>& _executorSocket,
+#endif // __WINDOWS__
              const Option<Authorizer*>& _authorizer)
   : ProcessBase(id),
     state(RECOVERING),
@@ -232,7 +234,9 @@ Slave::Slave(const string& id,
     secretGenerator(_secretGenerator),
     volumeGidManager(_volumeGidManager),
     futureTracker(_futureTracker),
+#ifndef __WINDOWS__
     executorSocket(_executorSocket),
+#endif // __WINDOWS__
     authorizer(_authorizer),
     resourceVersion(protobuf::createUUID()) {}
 
@@ -776,6 +780,7 @@ void Slave::initialize()
         },
         options);
 
+#ifndef __WINDOWS__
   if (executorSocket.isSome()) {
     // We use `http::Server` to manage the communication channel.
     // Since `http::Server` currently doesn't offer support for
@@ -837,6 +842,7 @@ void Slave::initialize()
       }
     }
   }
+#endif // __WINDOWS__
 
   route("/api/v1/executor",
         EXECUTOR_HTTP_AUTHENTICATION_REALM,
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index 3844867..03279db 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -130,7 +130,9 @@ public:
         mesos::SecretGenerator* secretGenerator,
         VolumeGidManager* volumeGidManager,
         PendingFutureTracker* futureTracker,
+#ifndef __WINDOWS__
         const Option<process::network::unix::Socket>& executorSocket,
+#endif // __WINDOWS__
         const Option<Authorizer*>& authorizer);
 
   ~Slave() override;
@@ -874,7 +876,10 @@ private:
 
   PendingFutureTracker* futureTracker;
 
+#ifndef __WINDOWS__
   Option<process::network::unix::Socket> executorSocket;
+#endif // __WINDOWS__
+
   Option<process::http::Server> executorSocketServer;
 
   const Option<Authorizer*> authorizer;
diff --git a/src/tests/cluster.cpp b/src/tests/cluster.cpp
index ffb7161..ab4cea4 100644
--- a/src/tests/cluster.cpp
+++ b/src/tests/cluster.cpp
@@ -71,7 +71,11 @@
 #include "authorizer/local/authorizer.hpp"
 
 #include "common/authorization.hpp"
+
+#ifndef __WINDOWS__
 #include "common/domain_sockets.hpp"
+#endif // __WINDOWS__
+
 #include "common/future_tracker.hpp"
 #include "common/http.hpp"
 
@@ -120,7 +124,9 @@ using mesos::master::detector::ZooKeeperMasterDetector;
 
 using mesos::slave::ContainerTermination;
 
+#ifndef __WINDOWS__
 using process::network::unix::Socket;
+#endif // __WINDOWS__
 
 namespace mesos {
 namespace internal {
@@ -610,6 +616,7 @@ Try<process::Owned<Slave>> Slave::create(
     slave->secretGenerator.reset(_secretGenerator);
   }
 
+#ifndef __WINDOWS__
   Option<Socket> executorSocket = None();
   if (flags.http_executor_domain_sockets) {
     // If `http_executor_domain_sockets` is true, then the location should have
@@ -627,6 +634,7 @@ Try<process::Owned<Slave>> Slave::create(
 
     executorSocket = socket.get();
   }
+#endif // __WINDOWS__
 
   // If the task status update manager is not provided, create a default one.
   if (taskStatusUpdateManager.isNone()) {
@@ -664,7 +672,9 @@ Try<process::Owned<Slave>> Slave::create(
         secretGenerator.getOrElse(slave->secretGenerator.get()),
         volumeGidManager,
         futureTracker.getOrElse(slave->futureTracker.get()),
+#ifndef __WINDOWS__
         executorSocket,
+#endif // __WINDOWS__
         authorizer));
   }
 
diff --git a/src/tests/mock_slave.cpp b/src/tests/mock_slave.cpp
index dfbca2a..fa2a0f5 100644
--- a/src/tests/mock_slave.cpp
+++ b/src/tests/mock_slave.cpp
@@ -124,7 +124,9 @@ MockSlave::MockSlave(
         secretGenerator,
         volumeGidManager,
         futureTracker,
+#ifndef __WINDOWS__
         None(),
+#endif // __WINDOWS__
         authorizer)
 {
   // Set up default behaviors, calling the original methods.

Reply via email to