Bläddra i källkod

HUE-2449 [oozie] Remove redundant delete

This deletion is unnecessary as we're using the
django.middleware.transaction.TransactionMiddleware, wraps all
the view calls in a transaction, and roll it back if there is
an error. This also helps to avoid calling `coordinator.delete()`
if an exception happens before the coordinator was saved.
Erick Tryzelaar 11 år sedan
förälder
incheckning
e2d99332ad
1 ändrade filer med 31 tillägg och 36 borttagningar
  1. 31 36
      apps/oozie/src/oozie/importlib/coordinators.py

+ 31 - 36
apps/oozie/src/oozie/importlib/coordinators.py

@@ -152,44 +152,39 @@ def _process_metadata(coordinator, metadata):
 
 
 def import_coordinator_root(coordinator, coordinator_definition_root, metadata=None):
-  try:
-    xslt_definition_fh = open("%(xslt_dir)s/coordinator.xslt" % {
-      'xslt_dir': os.path.join(conf.DEFINITION_XSLT_DIR.get(), 'coordinators')
+  xslt_definition_fh = open("%(xslt_dir)s/coordinator.xslt" % {
+    'xslt_dir': os.path.join(conf.DEFINITION_XSLT_DIR.get(), 'coordinators')
+  })
+
+  tag = etree.QName(coordinator_definition_root.tag)
+  schema_version = tag.namespace
+
+  # Ensure namespace exists
+  if schema_version not in OOZIE_NAMESPACES:
+    raise RuntimeError(_("Tag with namespace %(namespace)s is not valid. Please use one of the following namespaces: %(namespaces)s") % {
+      'namespace': coordinator_definition_root.tag,
+      'namespaces': ', '.join(OOZIE_NAMESPACES)
     })
 
-    tag = etree.QName(coordinator_definition_root.tag)
-    schema_version = tag.namespace
-
-    # Ensure namespace exists
-    if schema_version not in OOZIE_NAMESPACES:
-      raise RuntimeError(_("Tag with namespace %(namespace)s is not valid. Please use one of the following namespaces: %(namespaces)s") % {
-        'namespace': coordinator_definition_root.tag,
-        'namespaces': ', '.join(OOZIE_NAMESPACES)
-      })
-
-    # Get XSLT and Transform XML
-    xslt = etree.parse(xslt_definition_fh)
-    xslt_definition_fh.close()
-    transform = etree.XSLT(xslt)
-    transformed_root = transform(coordinator_definition_root)
-
-    # Deserialize XML
-    objects = serializers.deserialize('xml', etree.tostring(transformed_root))
-    # Resolve coordinator dependencies and node types and link dependencies
-    _set_coordinator_properties(coordinator, coordinator_definition_root, schema_version)
-    _set_controls(coordinator, coordinator_definition_root, schema_version)
-    _reconcile_datasets(coordinator, objects, coordinator_definition_root, schema_version)
-    _set_properties(coordinator, coordinator_definition_root, schema_version)
-    if metadata:
-      _process_metadata(coordinator, metadata)
-
-    # Update schema_version
-    coordinator.schema_version = schema_version
-    coordinator.save()
-  except:
-    # There was an error importing the coordinator so delete every thing associated with it.
-    coordinator.delete(skip_trash=True)
-    raise
+  # Get XSLT and Transform XML
+  xslt = etree.parse(xslt_definition_fh)
+  xslt_definition_fh.close()
+  transform = etree.XSLT(xslt)
+  transformed_root = transform(coordinator_definition_root)
+
+  # Deserialize XML
+  objects = serializers.deserialize('xml', etree.tostring(transformed_root))
+  # Resolve coordinator dependencies and node types and link dependencies
+  _set_coordinator_properties(coordinator, coordinator_definition_root, schema_version)
+  _set_controls(coordinator, coordinator_definition_root, schema_version)
+  _reconcile_datasets(coordinator, objects, coordinator_definition_root, schema_version)
+  _set_properties(coordinator, coordinator_definition_root, schema_version)
+  if metadata:
+    _process_metadata(coordinator, metadata)
+
+  # Update schema_version
+  coordinator.schema_version = schema_version
+  coordinator.save()
 
 
 def import_coordinator(coordinator, coordinator_definition, metadata=None):