Alon Bar-Lev has uploaded a new change for review. Change subject: packaging: services: ovirt-engine: move deployments to tmpdir ......................................................................
packaging: services: ovirt-engine: move deployments to tmpdir the deployments' content is controlled by ENGINE_APPS, we should run these applications and only these. much easier to re-create on every startup than syncing with existing. this removes the need to remove markers, sync symlinks and other tasks. I failed to make jboss substitute system property within the configuration and within the paths configuration, so I use template substitution. Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1059480 Change-Id: I17e7bc91229e9b05e6fb719a9c15c1036a3ba19b Signed-off-by: Alon Bar-Lev <alo...@redhat.com> --- M Makefile M ovirt-engine.spec.in M packaging/services/ovirt-engine/ovirt-engine.py M packaging/services/ovirt-engine/ovirt-engine.xml.in M packaging/setup/ovirt_engine_setup/constants.py M packaging/setup/plugins/ovirt-engine-setup/system/localstate.py 6 files changed, 30 insertions(+), 81 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/80/23880/1 diff --git a/Makefile b/Makefile index a1c89b8..8d160e9 100644 --- a/Makefile +++ b/Makefile @@ -61,6 +61,7 @@ PKG_LOG_DIR=$(LOCALSTATE_DIR)/log/$(ENGINE_NAME) PKG_TMP_DIR=$(LOCALSTATE_DIR)/tmp/$(ENGINE_NAME) PKG_STATE_DIR=$(LOCALSTATE_DIR)/lib/$(ENGINE_NAME) +PKG_TMP_DIR=$(LOCALSTATE_DIR)/tmp/$(ENGINE_NAME) JBOSS_HOME=/usr/share/jboss-as PYTHON_DIR=$(PYTHON_SYS_DIR) DEV_PYTHON_DIR= @@ -422,7 +423,6 @@ install -d "$(DESTDIR)$(PKG_TMP_DIR)" install -d "$(DESTDIR)$(PKG_CACHE_DIR)" - install -d "$(DESTDIR)$(PKG_STATE_DIR)/deployments" install -d "$(DESTDIR)$(PKG_STATE_DIR)/content" install -d "$(DESTDIR)$(PKG_STATE_DIR)/setup/answers" install -d "$(DESTDIR)$(PKG_LOG_DIR)/host-deploy" @@ -431,4 +431,6 @@ install -d "$(DESTDIR)$(PKG_LOG_DIR)/engine-manage-domains" install -d "$(DESTDIR)$(PKG_LOG_DIR)/dump" - touch "$(DESTDIR)$(PKG_STATE_DIR)/deployments/engine.ear.deployed" + if [ -e "$(DESTDIR)$(PKG_TMP_DIR)/deployments" ]; then \ + touch "$(DESTDIR)$(PKG_TMP_DIR)/deployments/engine.ear.deployed"; \ + fi diff --git a/ovirt-engine.spec.in b/ovirt-engine.spec.in index 7ee0852..fe60674 100644 --- a/ovirt-engine.spec.in +++ b/ovirt-engine.spec.in @@ -499,7 +499,7 @@ # # /var creation # -install -dm 755 "%{buildroot}/%{engine_state}"/{deployments,content,setup/answers} +install -dm 755 "%{buildroot}/%{engine_state}"/{content,setup/answers} install -dm 755 "%{buildroot}/%{engine_log}"/{host-deploy,setup,notifier,engine-manage-domains,dump} install -dm 755 "%{buildroot}/%{engine_cache}" install -dm 755 "%{buildroot}/%{engine_run}/notifier" @@ -737,7 +737,6 @@ %attr(-, %{engine_user}, %{engine_group}) %{engine_log}/host-deploy %attr(-, %{engine_user}, %{engine_group}) %{engine_state}/content -%attr(-, %{engine_user}, %{engine_group}) %{engine_state}/deployments %config %{_sysconfdir}/logrotate.d/ovirt-engine %config(noreplace) %{engine_etc}/sysprep %dir %attr(-, %{engine_user}, %{engine_group}) %{engine_state} diff --git a/packaging/services/ovirt-engine/ovirt-engine.py b/packaging/services/ovirt-engine/ovirt-engine.py index eb850a9..95c5470 100755 --- a/packaging/services/ovirt-engine/ovirt-engine.py +++ b/packaging/services/ovirt-engine/ovirt-engine.py @@ -15,7 +15,6 @@ # limitations under the License. -import glob import os import sys import re @@ -54,7 +53,19 @@ with open(out, 'w') as f: if mode is not None: os.chmod(out, mode) - f.write(str(Template(file=template, searchList=[self._config]))) + f.write( + '%s' % ( + Template( + file=template, + searchList=[ + self._config, + { + 'tempdir': self._tempDir.directory, + }, + ], + ) + ), + ) return out def _linkModules(self, modulesDir): @@ -114,15 +125,6 @@ writable=True, mustExist=False, ) - for dir in ('.', 'content', 'deployments'): - self.check( - os.path.join( - self._config.get('ENGINE_VAR'), - dir - ), - directory=True, - writable=True, - ) self.check( self._config.get('ENGINE_LOG'), directory=True, @@ -151,8 +153,14 @@ def _setupEngineApps(self): + deploymentsDir = os.path.join( + self._tempDir.directory, + 'deployments', + ) + os.mkdir(deploymentsDir) + # The list of applications to be deployed: - for engineAppDir in self._config.get('ENGINE_APPS').split(): + for engineAppDir in shlex.split(self._config.get('ENGINE_APPS')): self.logger.debug('Deploying: %s', engineAppDir) if not os.path.isabs(engineAppDir): engineAppDir = os.path.join( @@ -170,61 +178,13 @@ ) continue - # Make sure the application is linked in the deployments - # directory, if not link it now: engineAppLink = os.path.join( - self._config.get('ENGINE_VAR'), - 'deployments', + deploymentsDir, os.path.basename(engineAppDir), ) - if not os.path.islink(engineAppLink): - try: - os.symlink(engineAppDir, engineAppLink) - except OSError as e: - self.logger.debug('exception', exc_info=True) - raise RuntimeError( - _( - "Cannot create symbolic link '{file}': " - "{error}" - ).format( - file=engineAppLink, - error=e, - ), - ) - - # Remove all existing deployment markers: - for markerFile in glob.glob('%s.*' % engineAppLink): - try: - os.remove(markerFile) - except OSError as e: - self.logger.debug('exception', exc_info=True) - raise RuntimeError( - _( - "Cannot remove deployment marker file '{file}': " - "{error}" - ).format( - file=markerFile, - error=e, - ), - ) - - # Create the new marker file to trigger deployment - # of the application: - markerFile = "%s.dodeploy" % engineAppLink - try: - with open(markerFile, "w"): - pass - except IOError as e: - self.logger.debug('exception', exc_info=True) - raise RuntimeError( - _( - "Cannot create deployment marker file '{file}': " - "{error}" - ).format( - file=markerFile, - error=e, - ) - ) + os.symlink(engineAppDir, engineAppLink) + with open('%s.dodeploy' % engineAppLink, 'w'): + pass def daemonSetup(self): diff --git a/packaging/services/ovirt-engine/ovirt-engine.xml.in b/packaging/services/ovirt-engine/ovirt-engine.xml.in index 0b335dc..48485cd 100644 --- a/packaging/services/ovirt-engine/ovirt-engine.xml.in +++ b/packaging/services/ovirt-engine/ovirt-engine.xml.in @@ -167,7 +167,7 @@ </subsystem> <subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1"> - <deployment-scanner scan-interval="5000" path="$getstring('ENGINE_VAR')/deployments"/> + <deployment-scanner scan-interval="5000" path="$tempdir/deployments"/> </subsystem> <subsystem xmlns="urn:jboss:domain:ee:1.0"/> diff --git a/packaging/setup/ovirt_engine_setup/constants.py b/packaging/setup/ovirt_engine_setup/constants.py index f7b76b8..cf2476c 100644 --- a/packaging/setup/ovirt_engine_setup/constants.py +++ b/packaging/setup/ovirt_engine_setup/constants.py @@ -186,10 +186,6 @@ OVIRT_ENGINE_LOCALSTATEDIR, 'dbmd5', ) - OVIRT_ENGINE_DEPLOYMENTS_DIR = os.path.join( - OVIRT_ENGINE_LOCALSTATEDIR, - 'deployments', - ) OVIRT_SETUP_STATE_DIR = os.path.join( OVIRT_ENGINE_LOCALSTATEDIR, 'setup', diff --git a/packaging/setup/plugins/ovirt-engine-setup/system/localstate.py b/packaging/setup/plugins/ovirt-engine-setup/system/localstate.py index 3ec2234..9dcf1cf 100644 --- a/packaging/setup/plugins/ovirt-engine-setup/system/localstate.py +++ b/packaging/setup/plugins/ovirt-engine-setup/system/localstate.py @@ -77,13 +77,5 @@ ) shutil.rmtree(osetupcons.FileLocations.OVIRT_ENGINE_TMPDIR) - for root, dirs, files in os.walk( - top=osetupcons.FileLocations.OVIRT_ENGINE_DEPLOYMENTS_DIR, - followlinks=False, - ): - os.chown(root, uid, gid) - for name in dirs + files: - os.chown(os.path.join(root, name), uid, gid) - # vim: expandtab tabstop=4 shiftwidth=4 -- To view, visit http://gerrit.ovirt.org/23880 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I17e7bc91229e9b05e6fb719a9c15c1036a3ba19b Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.3 Gerrit-Owner: Alon Bar-Lev <alo...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches