Giuseppe Lavagetto has submitted this change and it was merged.

Change subject: puppet-compiler: work better with jenkins + fixes
......................................................................


puppet-compiler: work better with jenkins + fixes

- Now each jenkins run will have its own output directory
- Fixed an error when trying to copy naggen2 as non-root
- Now the production branch and the private repo get refreshed at each
  run

Change-Id: I6c27917c7e4b2f85d5a95be05e98b7119caf8607
Signed-off-by: Giuseppe Lavagetto <[email protected]>
---
M compare-puppet-catalogs/puppet_compare/app_defaults.py
M compare-puppet-catalogs/puppet_compare/generator.py
M compare-puppet-catalogs/shell/helper
M compare-puppet-catalogs/shell/prepare_change
4 files changed, 28 insertions(+), 6 deletions(-)

Approvals:
  Giuseppe Lavagetto: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/compare-puppet-catalogs/puppet_compare/app_defaults.py 
b/compare-puppet-catalogs/puppet_compare/app_defaults.py
index c56c6d0..720c57c 100644
--- a/compare-puppet-catalogs/puppet_compare/app_defaults.py
+++ b/compare-puppet-catalogs/puppet_compare/app_defaults.py
@@ -3,12 +3,17 @@
 PARENT=os.path.realpath(os.path.join(MYDIR,'..'))
 BASEDIR = os.environ.get('PUPPET_COMPILER_BASEDIR', PARENT)
 get_path = lambda x: os.path.join(BASEDIR, x)
+
 COMPILE_SCRIPT = get_path('shell/compile')
 FETCH_CHANGE = get_path('shell/prepare_change')
+HELPER_SCRIPT = get_path('shell/helper')
 DIFF_SCRIPT = get_path('shell/differ')
 NODE_DIR = get_path('external/var/yaml/node')
 PUPPET_VERSIONS = [('2.7', 'production'), ('3', 'production')]
-OUTPUT_DIR = get_path('output')
+
+BASE_OUTPUT_DIR = get_path('output')
+# Jenkins support
+OUTPUT_DIR = os.path.join(BASE_OUTPUT_DIR, os.environ.get('BUILD_NUMBER', ''))
 COMPILE_OUTPUT_DIR = os.path.join(OUTPUT_DIR, 'compiled')
 DIFF_DIR = os.path.join(OUTPUT_DIR, 'diff')
 HTML_DIR = os.path.join(OUTPUT_DIR, 'html')
diff --git a/compare-puppet-catalogs/puppet_compare/generator.py 
b/compare-puppet-catalogs/puppet_compare/generator.py
index 2496be6..faa6de0 100644
--- a/compare-puppet-catalogs/puppet_compare/generator.py
+++ b/compare-puppet-catalogs/puppet_compare/generator.py
@@ -79,7 +79,7 @@
         self.tp_size = args.numthreads
         self.mode = 'versions'
         self.get_host()
-        self.html_path = 'html'
+        self.html_path = 
self.html_dir.replace(app.config.get('BASE_OUTPUT_DIR'),'')
 
     def get_host(self):
         hostname = socket.gethostname()
@@ -207,7 +207,19 @@
                 self.nodelist['ERROR'].add(node)
         self.node_output(node)
 
+    def _refresh_main(self):
+        cmd = "{} {}".format(app.config.get('HELPER_SCRIPT'), 'install')
+        log.info('Refreshing the base installation')
+        run(cmd)
+        for d in [self.compiled_dir, self.html_dir, self.diff_dir]:
+            try:
+                os.makedirs(d)
+            except:
+                pass
+
     def run(self):
+        if self.change is None:
+            self._refresh_main()
         threadpool = threads.ThreadOrchestrator(self.tp_size)
         for node in self.node_generator():
             threadpool.add(self._run_node, node)
@@ -239,7 +251,7 @@
             'manifests/site.pp')
         self.mode = 'diffchanges'
         self._avoid_prepare_change = args.no_code_refresh
-        self.html_path = 'change/%d/html' % self.change
+        self.html_path = 
self.html_dir.replace(app.config.get('BASE_OUTPUT_DIR'),'')
 
     def run(self):
         if not self._avoid_prepare_change:
@@ -274,6 +286,11 @@
         log.info(
             'Downloading patch for change %s, revision %s', self.change, 
revision)
         run(cmd)
+        for d in [self.compiled_dir, self.html_dir, self.diff_dir]:
+            try:
+                os.makedirs(d)
+            except:
+                pass
 
 
 class NodeVersionsChange(NodeDiffChange):
diff --git a/compare-puppet-catalogs/shell/helper 
b/compare-puppet-catalogs/shell/helper
index 52e84f6..874dc9e 100755
--- a/compare-puppet-catalogs/shell/helper
+++ b/compare-puppet-catalogs/shell/helper
@@ -123,8 +123,9 @@
 }
 
 function setup_naggen() {
-    if [ ! -f /usr/local/bin/naggen ];  then
-        cp ${PUPPETDIR}/modules/puppetmaster/files/naggen /usr/local/bin/naggen
+    if [ ! -f /usr/local/bin/naggen2 -a $UID -eq 0 ];  then
+        # do this on vagrant only, where we run as root.
+        cp ${PUPPETDIR}/modules/puppetmaster/files/naggen2 
/usr/local/bin/naggen2
     fi;
 }
 
diff --git a/compare-puppet-catalogs/shell/prepare_change 
b/compare-puppet-catalogs/shell/prepare_change
index b2d4674..bc6d89c 100755
--- a/compare-puppet-catalogs/shell/prepare_change
+++ b/compare-puppet-catalogs/shell/prepare_change
@@ -14,4 +14,3 @@
 echo "Preparing the dir for change ${CHANGE}"
 ${DIR}/helper install ${CHANGE} ${REVISION}
 PARENT=$(readlink -f ${DIR}/../)
-mkdir -p ${PARENT}/output/change/${CHANGE}/{html,compiled,diff}

-- 
To view, visit https://gerrit.wikimedia.org/r/138614
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I6c27917c7e4b2f85d5a95be05e98b7119caf8607
Gerrit-PatchSet: 4
Gerrit-Project: operations/software
Gerrit-Branch: master
Gerrit-Owner: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to