You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by vi...@apache.org on 2012/07/17 18:45:26 UTC

svn commit: r1362564 - in /incubator/oozie/trunk: core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java core/src/test/java/org/apache/oozie/action/hadoop/TestJavaActionExecutor.java release-log.txt

Author: virag
Date: Tue Jul 17 16:45:25 2012
New Revision: 1362564

URL: http://svn.apache.org/viewvc?rev=1362564&view=rev
Log:
OOZIE-907 Default ACL settings for Oozie launcher (mona via virag)

Modified:
    incubator/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java
    incubator/oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestJavaActionExecutor.java
    incubator/oozie/trunk/release-log.txt

Modified: incubator/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java?rev=1362564&r1=1362563&r2=1362564&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java (original)
+++ incubator/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java Tue Jul 17 16:45:25 2012
@@ -84,6 +84,8 @@ public class JavaActionExecutor extends 
     public static final int MAX_EXTERNAL_STATS_SIZE_DEFAULT = Integer.MAX_VALUE;
     private static final Set<String> DISALLOWED_PROPERTIES = new HashSet<String>();
     public final static String MAX_EXTERNAL_STATS_SIZE = "oozie.external.stats.max.size";
+    public static final String ACL_VIEW_JOB = "mapreduce.job.acl-view-job";
+    public static final String ACL_MODIFY_JOB = "mapreduce.job.acl-modify-job";
     private static int maxActionOutputLen;
     private static int maxExternalStatsSize;
 
@@ -507,7 +509,6 @@ public class JavaActionExecutor extends 
     }
 
     private static final String QUEUE_NAME = "mapred.job.queue.name";
-    private static final String OOZIE_LAUNCHER_QUEUE_NAME = "oozie.launcher.mapred.job.queue.name";
 
     private static final Set<String> SPECIAL_PROPERTIES = new HashSet<String>();
 
@@ -515,6 +516,8 @@ public class JavaActionExecutor extends 
         SPECIAL_PROPERTIES.add(QUEUE_NAME);
         SPECIAL_PROPERTIES.add("mapreduce.jobtracker.kerberos.principal");
         SPECIAL_PROPERTIES.add("dfs.namenode.kerberos.principal");
+        SPECIAL_PROPERTIES.add(ACL_VIEW_JOB);
+        SPECIAL_PROPERTIES.add(ACL_MODIFY_JOB);
     }
 
     @SuppressWarnings("unchecked")
@@ -586,27 +589,13 @@ public class JavaActionExecutor extends 
                 launcherJobConf.set("mapred.child.java.opts", opts);
             }
 
-            // properties from action that are needed by the launcher (QUEUE NAME)
+            // properties from action that are needed by the launcher (e.g. QUEUE NAME, ACLs)
             // maybe we should add queue to the WF schema, below job-tracker
-            for (String name : SPECIAL_PROPERTIES) {
-                String value = actionConf.get(name);
-                if (value != null) {
-                    if (!name.equals(QUEUE_NAME) ||
-                        (name.equals(QUEUE_NAME) && launcherJobConf.get(OOZIE_LAUNCHER_QUEUE_NAME) == null)) {
-                        launcherJobConf.set(name, value);
-                    }
-                }
-            }
+            actionConfToLauncherConf(actionConf, launcherJobConf);
 
             // to disable cancelation of delegation token on launcher job end
             launcherJobConf.setBoolean("mapreduce.job.complete.cancel.delegation.tokens", false);
 
-            if (context.getWorkflow().getAcl() != null) {
-                // setting the group owning the Oozie job to allow anybody in that
-                // group to kill the jobs.
-                launcherJobConf.set("mapreduce.job.acl-modify-job", context.getWorkflow().getAcl());
-            }
-
             return launcherJobConf;
         }
         catch (Exception ex) {
@@ -630,6 +619,14 @@ public class JavaActionExecutor extends 
         injectCallback(context, launcherConf);
     }
 
+    private void actionConfToLauncherConf(Configuration actionConf, JobConf launcherConf) {
+        for (String name : SPECIAL_PROPERTIES) {
+            if (actionConf.get(name) != null && launcherConf.get("oozie.launcher." + name) == null) {
+                launcherConf.set(name, actionConf.get(name));
+            }
+        }
+    }
+
     public void submitLauncher(FileSystem actionFs, Context context, WorkflowAction action) throws ActionExecutorException {
         JobClient jobClient = null;
         boolean exception = false;

Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestJavaActionExecutor.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestJavaActionExecutor.java?rev=1362564&r1=1362563&r2=1362564&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestJavaActionExecutor.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestJavaActionExecutor.java Tue Jul 17 16:45:25 2012
@@ -997,4 +997,81 @@ public class TestJavaActionExecutor exte
         assertTrue(cacheFilesStr.contains(jar2Path.toString()));
         assertTrue(cacheFilesStr.contains(jar3Path.toString()));
     }
+
+    public void testACLDefaults_launcherACLsSetToDefault() throws Exception {
+        // CASE: launcher specific ACLs not configured - set defaults
+        String actionXml = "<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" +
+                "<name-node>" + getNameNodeUri() + "</name-node> <configuration>" +
+                "<property><name>mapreduce.job.acl-view-job</name><value>VIEWER</value></property>" +
+                "<property><name>mapreduce.job.acl-modify-job</name><value>MODIFIER</value></property>" +
+                "</configuration>" + "<main-class>MAIN-CLASS</main-class>" +
+                "</java>";
+
+        WorkflowJobBean wfBean = addRecordToWfJobTable("test1-acl", actionXml);
+        WorkflowActionBean action = (WorkflowActionBean) wfBean.getActions().get(0);
+        JavaActionExecutor ae = new JavaActionExecutor();
+        action.setType(ae.getType());
+        Context context = new Context(wfBean, action);
+
+        Element eActionXml = XmlUtils.parseXml(actionXml);
+
+        Configuration actionConf = ae.createBaseHadoopConf(context, eActionXml);
+        ae.setupActionConf(actionConf, context, eActionXml, getAppPath());
+        Configuration conf = ae.createLauncherConf(getFileSystem(), context, action, eActionXml, actionConf);
+
+        assertEquals("VIEWER", conf.get(JavaActionExecutor.ACL_VIEW_JOB));
+        assertEquals("MODIFIER", conf.get(JavaActionExecutor.ACL_MODIFY_JOB));
+    }
+
+    public void testACLDefaults_noFalseChange() throws Exception {
+        // CASE: launcher specific ACLs configured, but MR job ACLs not configured i.e. null. Check for no false changes to null
+        String actionXml = "<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" +
+                "<name-node>" + getNameNodeUri() + "</name-node> <configuration>" +
+                "<property><name>oozie.launcher.mapreduce.job.acl-view-job</name><value>V</value></property>" +
+                "<property><name>oozie.launcher.mapreduce.job.acl-modify-job</name><value>M</value></property>" +
+                "</configuration>" + "<main-class>MAIN-CLASS</main-class>" +
+                "</java>";
+
+        WorkflowJobBean wfBean = addRecordToWfJobTable("test2-acl", actionXml);
+        WorkflowActionBean action = (WorkflowActionBean) wfBean.getActions().get(0);
+        JavaActionExecutor ae = new JavaActionExecutor();
+        action.setType(ae.getType());
+        Context context = new Context(wfBean, action);
+
+        Element eActionXml = XmlUtils.parseXml(actionXml);
+
+        Configuration actionConf = ae.createBaseHadoopConf(context, eActionXml);
+        ae.setupActionConf(actionConf, context, eActionXml, getAppPath());
+        Configuration conf = ae.createLauncherConf(getFileSystem(), context, action, eActionXml, actionConf);
+
+        assertNotNull(conf.get(JavaActionExecutor.ACL_VIEW_JOB));
+        assertNotNull(conf.get(JavaActionExecutor.ACL_MODIFY_JOB));
+    }
+
+    public void testACLDefaults_explicitLauncherAndActionSettings() throws Exception {
+        // CASE: launcher specific ACLs configured, as well as MR job ACLs configured. Check that NO overriding with defaults
+        String actionXml = "<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" +
+                "<name-node>" + getNameNodeUri() + "</name-node> <configuration>" +
+                "<property><name>oozie.launcher.mapreduce.job.acl-view-job</name><value>V</value></property>" +
+                "<property><name>oozie.launcher.mapreduce.job.acl-modify-job</name><value>M</value></property>" +
+                "<property><name>mapreduce.job.acl-view-job</name><value>VIEWER</value></property>" +
+                "<property><name>mapreduce.job.acl-modify-job</name><value>MODIFIER</value></property>" +
+                "</configuration>" + "<main-class>MAIN-CLASS</main-class>" +
+                "</java>";
+
+        WorkflowJobBean wfBean = addRecordToWfJobTable("test3-acl", actionXml);
+        WorkflowActionBean action = (WorkflowActionBean) wfBean.getActions().get(0);
+        JavaActionExecutor ae = new JavaActionExecutor();
+        action.setType(ae.getType());
+        Context context = new Context(wfBean, action);
+
+        Element eActionXml = XmlUtils.parseXml(actionXml);
+
+        Configuration actionConf = ae.createBaseHadoopConf(context, eActionXml);
+        ae.setupActionConf(actionConf, context, eActionXml, getAppPath());
+        Configuration conf = ae.createLauncherConf(getFileSystem(), context, action, eActionXml, actionConf);
+
+        assertNotSame(conf.get(JavaActionExecutor.ACL_VIEW_JOB), actionConf.get(JavaActionExecutor.ACL_VIEW_JOB));
+        assertNotSame(conf.get(JavaActionExecutor.ACL_MODIFY_JOB), actionConf.get(JavaActionExecutor.ACL_MODIFY_JOB));
+    }
 }

Modified: incubator/oozie/trunk/release-log.txt
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/release-log.txt?rev=1362564&r1=1362563&r2=1362564&view=diff
==============================================================================
--- incubator/oozie/trunk/release-log.txt (original)
+++ incubator/oozie/trunk/release-log.txt Tue Jul 17 16:45:25 2012
@@ -1,5 +1,6 @@
 -- Oozie 3.3.0 release (trunk - unreleased)
 
+OOZIE-907 Default ACL settings for Oozie launcher (mona via virag)
 OOZIE-908 Oozie docs build instructions for hadoop versions (mona via virag)
 OOZIE-874 Eliminate redundancies in xml (britt via virag)
 OOZIE-900 Indicate that the exception thrown from the db-cli during an error is for debug purposes (harsh)
@@ -193,7 +194,7 @@ OOZIE-589 Make the command requeue inter
 OOZIE-156 Add support for a SQOOP action. (tucu)
 OOZIE-77  Oozie should support Kerberos authentication on its HTTP REST API. (tucu)
 OOZIE-622 Remove system sharelib tests from TestLiteWorkflowAppService. (tucu)
-OOZIE-588 Oozie to allow drill down to hadoop job's details (virag via Mohammad)
+OOZIE-588 Oozie to allow drill down to hadoop job's details (virag/params via Mohammad)
 OOZIE-68  Add Hive action. (tucu)
 OOZIE-608 Fix test failure for testCoordChangeXCommand, testCoordChangeEndTime Unit
 OOZIE-610 Oozie system share lib should have jars per action type. (tucu)