Move shutdown timeout to Zone config 35/37835/1
authorLukasz Kostyra <l.kostyra@samsung.com>
Tue, 7 Apr 2015 06:25:21 +0000 (08:25 +0200)
committerLukasz Kostyra <l.kostyra@samsung.com>
Tue, 7 Apr 2015 08:16:32 +0000 (10:16 +0200)
[Feature]       Shutdown timeout is moved to Zone configuration file
[Cause]         Shutdown timeout was a constant hardcoded into Zone Admin
[Solution]      Move timeout for shutdown to Zone config file
[Verification]  Build, install, run tests

Change-Id: Ie8dd1f81d6fd21d7685923c31361a86dde5c9a3d

14 files changed:
server/configs/templates/default.conf
server/zone-admin.cpp
server/zone-config.hpp
tests/unit_tests/client/configs/ut-client/templates/console-dbus.conf.in
tests/unit_tests/server/configs/ut-server/templates/default.conf
tests/unit_tests/server/configs/ut-zone-admin/templates/buggy.conf
tests/unit_tests/server/configs/ut-zone-admin/templates/missing.conf
tests/unit_tests/server/configs/ut-zone-admin/templates/test-no-shutdown.conf
tests/unit_tests/server/configs/ut-zone-admin/templates/test.conf
tests/unit_tests/server/configs/ut-zone/templates/buggy.conf
tests/unit_tests/server/configs/ut-zone/templates/test-dbus.conf.in
tests/unit_tests/server/configs/ut-zone/templates/test.conf
tests/unit_tests/server/configs/ut-zones-manager/templates/console-dbus.conf.in
tests/unit_tests/server/configs/ut-zones-manager/templates/console.conf

index 42f587b..697be47 100644 (file)
@@ -8,6 +8,7 @@
     "cpuQuotaBackground" : 1000,
     "privilege" : 10,
     "vt" : 0,
+    "shutdownTimeout" : 10,
     "switchToDefaultAfterTimeout" : true,
     "enableDbusIntegration" : false,
     "runMountPoint" : "~NAME~/run",
index 3098f29..0f831d7 100644 (file)
 
 namespace vasum {
 
-namespace {
-
-// TODO: this should be in zone's configuration file
-const int SHUTDOWN_WAIT = 10;
-
-} // namespace
-
 const std::uint64_t DEFAULT_CPU_SHARES = 1024;
 const std::uint64_t DEFAULT_VCPU_PERIOD_MS = 100000;
 
@@ -163,7 +156,7 @@ void ZoneAdmin::stop()
         return;
     }
 
-    if (!mZone.shutdown(SHUTDOWN_WAIT)) {
+    if (!mZone.shutdown(mConfig.shutdownTimeout)) {
         // force stop
         if (!mZone.stop()) {
             throw ZoneOperationException("Could not stop zone");
index f5d81e5..8d92800 100644 (file)
@@ -92,6 +92,14 @@ struct ZoneConfig {
      */
     std::vector<std::string> validLinkPrefixes;
 
+    /**
+     * Timeout in seconds for zone to gracefully shut down.
+     * After given time, if Zone is not off, forced shutdown occurs.
+     *
+     * To wait forever, set -1 timeout. To skip waiting, set 0 timeout.
+     */
+    int shutdownTimeout;
+
     CONFIG_REGISTER
     (
         lxcTemplate,
@@ -103,7 +111,8 @@ struct ZoneConfig {
         cpuQuotaBackground,
         permittedToSend, // TODO move to dynamic and add an API to change
         permittedToRecv, // TODO move to dynamic and add an API to change
-        validLinkPrefixes
+        validLinkPrefixes,
+        shutdownTimeout
     )
 };
 
index 7778208..7df03e4 100644 (file)
@@ -10,6 +10,7 @@
     "enableDbusIntegration" : true,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
+    "shutdownTimeout" : 10,
     "runMountPoint" : "/tmp/ut-run/~NAME~",
     "provisions" : [],
     "permittedToSend" : [ "/tmp/.*" ],
index a2f703e..b637d72 100644 (file)
@@ -10,6 +10,7 @@
     "enableDbusIntegration" : false,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
+    "shutdownTimeout" : 10,
     "runMountPoint" : "",
     "provisions" : [],
     "permittedToSend" : [],
index f585ae8..c40ab33 100644 (file)
@@ -10,6 +10,7 @@
     "enableDbusIntegration" : false,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
+    "shutdownTimeout" : 10,
     "runMountPoint" : "",
     "provisions" : [],
     "permittedToSend" : [],
index a3f305b..99e893d 100644 (file)
@@ -10,6 +10,7 @@
     "enableDbusIntegration" : false,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
+    "shutdownTimeout" : 10,
     "runMountPoint" : "",
     "provisions" : [],
     "permittedToSend" : [],
index 98e95ab..363c7df 100644 (file)
@@ -10,6 +10,7 @@
     "enableDbusIntegration" : false,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
+    "shutdownTimeout" : 10,
     "runMountPoint" : "",
     "provisions" : [],
     "permittedToSend" : [],
index a16b3fa..df787df 100644 (file)
@@ -10,6 +10,7 @@
     "enableDbusIntegration" : false,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
+    "shutdownTimeout" : 10,
     "runMountPoint" : "",
     "provisions" : [],
     "permittedToSend" : [],
index 79436c0..91a9f7f 100644 (file)
@@ -10,6 +10,7 @@
     "enableDbusIntegration" : false,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
+    "shutdownTimeout" : 10,
     "runMountPoint" : "",
     "provisions" : [],
     "permittedToSend" : [],
index 5d76429..7d71f2d 100644 (file)
@@ -10,6 +10,7 @@
     "enableDbusIntegration" : true,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
+    "shutdownTimeout" : 10,
     "runMountPoint" : "/tmp/ut-run/zoneId",
     "provisions" : [],
     "permittedToSend" : [],
index 168aa21..a58f932 100644 (file)
@@ -10,6 +10,7 @@
     "enableDbusIntegration" : false,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
+    "shutdownTimeout" : 10,
     "runMountPoint" : "",
     "provisions" : [],
     "permittedToSend" : [],
index 7778208..7df03e4 100644 (file)
@@ -10,6 +10,7 @@
     "enableDbusIntegration" : true,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
+    "shutdownTimeout" : 10,
     "runMountPoint" : "/tmp/ut-run/~NAME~",
     "provisions" : [],
     "permittedToSend" : [ "/tmp/.*" ],
index 6e49c5b..5d5509b 100644 (file)
@@ -10,6 +10,7 @@
     "enableDbusIntegration" : false,
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
+    "shutdownTimeout" : 10,
     "runMountPoint" : "",
     "provisions" : [],
     "permittedToSend" : [ "/tmp/.*" ],