瀏覽代碼

[oozie] Fix bundle submission of multiple coordinators

Romain Rigaux 12 年之前
父節點
當前提交
2df537cd7e

+ 5 - 3
apps/oozie/src/oozie/templates/editor/gen/bundle.xml.mako

@@ -36,9 +36,12 @@
   % if bundle.coordinators:
     % for bundled in bundle.coordinators.all():
     <coordinator name='${ bundled.coordinator.name }' >
-       <app-path>${'${'}nameNode}${ bundled.coordinator.deployment_dir }</app-path>
-       % if bundled.get_parameters():
+       <app-path>${'${'}nameNode}${ mapping.pop('coord_%s_dir' % bundled.coordinator.id) }</app-path>
          <configuration>
+           <property>
+              <name>wf_application_path</name>
+              <value>${ mapping.pop('wf_%s_dir' % bundled.coordinator.workflow.id) }</value>
+          </property>
            % for param in bundled.get_parameters():
            <property>
               <name>${ param['name'] }</name>
@@ -46,7 +49,6 @@
           </property>
           % endfor
         </configuration>
-      % endif
     </coordinator>
     % endfor
   % endif

+ 11 - 5
apps/oozie/src/oozie/tests.py

@@ -1346,6 +1346,11 @@ class TestEditorBundle(OozieMockBase):
     response = self.c.post(reverse('oozie:create_bundled_coordinator', args=[bundle.id]), post, follow=True)
     assert_true('Coordinators' in response.content, response.content)
 
+    xml = bundle.to_xml({
+       'wf_%s_dir' % self.wf.id: '/deployment_path_wf',
+       'coord_%s_dir' % coord.id: '/deployment_path_coord'
+    })
+
     assert_true(
 """<bundle-app name="MyBundle"
   xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
@@ -1360,18 +1365,19 @@ class TestEditorBundle(OozieMockBase):
      <kick-off-time>2012-07-01T00:00Z</kick-off-time>
   </controls>
     <coordinator name='MyCoord' >
-       <app-path>${nameNode}/user/hue/oozie/workspaces""" in bundle.to_xml(), bundle.to_xml())
-
-    assert_true(
-"""</app-path>
+       <app-path>${nameNode}/deployment_path_coord</app-path>
          <configuration>
+           <property>
+              <name>wf_application_path</name>
+              <value>/deployment_path_wf</value>
+          </property>
            <property>
               <name>market</name>
               <value>US</value>
           </property>
         </configuration>
     </coordinator>
-</bundle-app>""" in bundle.to_xml(), bundle.to_xml())
+</bundle-app>""" in xml, xml)
 
 
 class TestImportWorkflow04(OozieMockBase):

+ 5 - 3
apps/oozie/src/oozie/views/editor.py

@@ -691,13 +691,15 @@ def submit_bundle(request, bundle):
 
 def _submit_bundle(request, bundle, properties):
   try:
+    deployment_dirs = {}
+
     for bundled in bundle.coordinators.all():
       wf_dir = Submission(request.user, bundled.coordinator.workflow, request.fs, properties).deploy()
-      properties = {'wf_application_path': request.fs.get_hdfs_path(wf_dir)}
+      deployment_dirs['wf_%s_dir' % bundled.coordinator.workflow.id] = request.fs.get_hdfs_path(wf_dir)
       coord_dir = Submission(request.user, bundled.coordinator, request.fs, properties).deploy()
-      bundled.coordinator.deployment_dir = coord_dir
-      bundled.coordinator.save() # Does not support concurrent submissions
+      deployment_dirs['coord_%s_dir' % bundled.coordinator.id] = coord_dir
 
+    properties.update(deployment_dirs)
     submission = Submission(request.user, bundle, request.fs, properties=properties)
     job_id = submission.run()