Ofer Schreiber has uploaded a new change for review.

Change subject: packaging: verify sysctl.shmmax after modification
......................................................................

packaging: verify sysctl.shmmax after modification

In non-interactive mode, ovirt-engine-setup tries to modify
sysctl.shmmax.
This patch verifies that the above modification went correctly, and that
the current sysctl.shmmax is abve what we need.

Change-Id: If2e1eafad9dacfa4d784526cdd0118c45cc47ccb
Signed-off-by: Ofer Schreiber <oschr...@redhat.com>
Bug-Url: https://bugzilla.redhat.com/1033043
---
M packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/system/sysctl.py
1 file changed, 42 insertions(+), 22 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/84/23284/1

diff --git 
a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/system/sysctl.py 
b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/system/sysctl.py
index 9e16bcb..8f10ce7 100644
--- a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/system/sysctl.py
+++ b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/system/sysctl.py
@@ -68,14 +68,7 @@
         interactive = self.environment[osetupcons.CoreEnv.DEVELOPER_MODE]
 
         while True:
-            rc, shmmax, stderr = self.execute(
-                (
-                    self.command.get('sysctl'),
-                    '-n',
-                    'kernel.shmmax',
-                ),
-            )
-            shmmax = int(shmmax[0])
+            shmmax = self._get_shmmax()
 
             if shmmax >= self.environment[osetupcons.SystemEnv.SHMMAX]:
                 break
@@ -132,26 +125,53 @@
         condition=lambda self: self._enabled,
     )
     def _misc(self):
-        sysctl = filetransaction.FileTransaction(
-            name=osetupcons.FileLocations.OVIRT_ENGINE_SYSCTL,
-            content=self._content,
-            modifiedList=self.environment[
-                otopicons.CoreEnv.MODIFIED_FILES
-            ],
-        )
-        self.environment[
-            osetupcons.CoreEnv.UNINSTALL_UNREMOVABLE_FILES
-        ].append(osetupcons.FileLocations.OVIRT_ENGINE_SYSCTL)
+        if self._enabled:
+            sysctl = filetransaction.FileTransaction(
+                name=osetupcons.FileLocations.OVIRT_ENGINE_SYSCTL,
+                content=self._content,
+                modifiedList=self.environment[
+                    otopicons.CoreEnv.MODIFIED_FILES
+                ],
+            )
+            self.environment[
+                osetupcons.CoreEnv.UNINSTALL_UNREMOVABLE_FILES
+            ].append(osetupcons.FileLocations.OVIRT_ENGINE_SYSCTL)
 
-        self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(sysctl)
+            self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(sysctl)
 
-        # we must do this here as postgres requires it
-        self.execute(
+            # we must do this here as postgres requires it
+            self.execute(
+                (
+                    self.command.get('sysctl'),
+                    '-p', sysctl.tmpname,
+                ),
+            )
+
+        # Verify shmmax is set correctly
+        shmmax = self._get_shmmax()
+
+        if shmmax >= self.environment[osetupcons.SystemEnv.SHMMAX]:
+            self.logger.debug(
+                'sysctl kernel.shmmax is %s lower than %s' % (
+                    shmmax,
+                    self.environment[osetupcons.SystemEnv.SHMMAX],
+                )
+            )
+
+            raise RuntimeError(
+                _('Unable to set sysctl kernel.shmmax to minimum requirement')
+            )
+
+    def _get_shmmax(self):
+        rc, shmmax, stderr = self.execute(
             (
                 self.command.get('sysctl'),
-                '-p', sysctl.tmpname,
+                '-n',
+                'kernel.shmmax',
             ),
         )
+        return int(shmmax[0])
+
 
 
 # vim: expandtab tabstop=4 shiftwidth=4


-- 
To view, visit http://gerrit.ovirt.org/23284
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If2e1eafad9dacfa4d784526cdd0118c45cc47ccb
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Ofer Schreiber <oschr...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to