Repository: oozie Updated Branches: refs/heads/master 05027479a -> 30b29c81d
OOZIE-2027 Disable re-runs using the workflow directly if it has a parent (jaydeepvishwakarma via shwethags) Project: http://git-wip-us.apache.org/repos/asf/oozie/repo Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/30b29c81 Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/30b29c81 Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/30b29c81 Branch: refs/heads/master Commit: 30b29c81d820cb98ae21e093a50da3534791b574 Parents: 0502747 Author: shwethags <[email protected]> Authored: Mon Dec 29 12:00:23 2014 +0530 Committer: shwethags <[email protected]> Committed: Mon Dec 29 12:00:23 2014 +0530 ---------------------------------------------------------------------- .../main/java/org/apache/oozie/ErrorCode.java | 1 + .../action/oozie/SubWorkflowActionExecutor.java | 2 + .../apache/oozie/command/wf/ReRunXCommand.java | 10 ++++ core/src/main/resources/oozie-default.xml | 9 +++ .../oozie/command/wf/TestReRunXCommand.java | 63 ++++++++++++++++++-- release-log.txt | 1 + 6 files changed, 80 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oozie/blob/30b29c81/core/src/main/java/org/apache/oozie/ErrorCode.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/ErrorCode.java b/core/src/main/java/org/apache/oozie/ErrorCode.java index 710b27f..28b90c0 100644 --- a/core/src/main/java/org/apache/oozie/ErrorCode.java +++ b/core/src/main/java/org/apache/oozie/ErrorCode.java @@ -152,6 +152,7 @@ public enum ErrorCode { E0742(XLog.STD, "No Fork for Join [{0}] to pair with"), E0743(XLog.STD, "Multiple \"ok to\" transitions to the same node, [{0}], are not allowed"), E0744(XLog.STD, "A fork, [{0}], is not allowed to have multiple transitions to the same node, [{1}]"), + E0755(XLog.STD, "Workflow Job Rerun Error: {0}"), E0800(XLog.STD, "Action it is not running its in [{1}] state, action [{0}]"), E0801(XLog.STD, "Workflow already running, workflow [{0}]"), http://git-wip-us.apache.org/repos/asf/oozie/blob/30b29c81/core/src/main/java/org/apache/oozie/action/oozie/SubWorkflowActionExecutor.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/action/oozie/SubWorkflowActionExecutor.java b/core/src/main/java/org/apache/oozie/action/oozie/SubWorkflowActionExecutor.java index debbf90..527a5e2 100644 --- a/core/src/main/java/org/apache/oozie/action/oozie/SubWorkflowActionExecutor.java +++ b/core/src/main/java/org/apache/oozie/action/oozie/SubWorkflowActionExecutor.java @@ -52,6 +52,7 @@ public class SubWorkflowActionExecutor extends ActionExecutor { public static final String PARENT_ID = "oozie.wf.parent.id"; public static final String SUBWORKFLOW_MAX_DEPTH = "oozie.action.subworkflow.max.depth"; private static final String SUBWORKFLOW_DEPTH = "oozie.action.subworkflow.depth"; + public static final String SUBWORKFLOW_RERUN = "oozie.action.subworkflow.rerun"; private static final Set<String> DISALLOWED_DEFAULT_PROPERTIES = new HashSet<String>(); @@ -183,6 +184,7 @@ public class SubWorkflowActionExecutor extends ActionExecutor { // if the rerun failed node option is provided during the time of rerun command, old subworkflow will // rerun again. if(action.getExternalId() != null && parentConf.getBoolean(OozieClient.RERUN_FAIL_NODES, false)) { + subWorkflowConf.setBoolean(SUBWORKFLOW_RERUN, true); oozieClient.reRun(action.getExternalId(), subWorkflowConf.toProperties()); subWorkflowId = action.getExternalId(); } else { http://git-wip-us.apache.org/repos/asf/oozie/blob/30b29c81/core/src/main/java/org/apache/oozie/command/wf/ReRunXCommand.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/command/wf/ReRunXCommand.java b/core/src/main/java/org/apache/oozie/command/wf/ReRunXCommand.java index 19d3e8d..6138278 100644 --- a/core/src/main/java/org/apache/oozie/command/wf/ReRunXCommand.java +++ b/core/src/main/java/org/apache/oozie/command/wf/ReRunXCommand.java @@ -51,6 +51,7 @@ import org.apache.oozie.executor.jpa.BatchQueryExecutor; import org.apache.oozie.executor.jpa.WorkflowJobQueryExecutor; import org.apache.oozie.executor.jpa.BatchQueryExecutor.UpdateEntry; import org.apache.oozie.executor.jpa.WorkflowJobQueryExecutor.WorkflowJobQuery; +import org.apache.oozie.service.ConfigurationService; import org.apache.oozie.service.DagXLogInfoService; import org.apache.oozie.service.HadoopAccessorException; import org.apache.oozie.service.HadoopAccessorService; @@ -94,6 +95,7 @@ public class ReRunXCommand extends WorkflowXCommand<Void> { private static final Set<String> DISALLOWED_DEFAULT_PROPERTIES = new HashSet<String>(); private static final Set<String> DISALLOWED_USER_PROPERTIES = new HashSet<String>(); + public static final String DISABLE_CHILD_RERUN = "oozie.wf.rerun.disablechild"; static { String[] badUserProps = { PropertiesUtils.DAYS, PropertiesUtils.HOURS, PropertiesUtils.MINUTES, @@ -339,6 +341,14 @@ public class ReRunXCommand extends WorkflowXCommand<Void> { */ @Override protected void eagerVerifyPrecondition() throws CommandException, PreconditionException { + // Throwing error if parent exist and same workflow trying to rerun, when running child workflow disabled + // through conf. + if (wfBean.getParentId() != null && !conf.getBoolean(SubWorkflowActionExecutor.SUBWORKFLOW_RERUN, false) + && ConfigurationService.getBoolean(DISABLE_CHILD_RERUN)) { + throw new PreconditionException(ErrorCode.E0755, " Rerun is not allowed through child workflow, please" + + " re-run through the parent " + wfBean.getParentId()); + } + if (!(wfBean.getStatus().equals(WorkflowJob.Status.FAILED) || wfBean.getStatus().equals(WorkflowJob.Status.KILLED) || wfBean.getStatus().equals( WorkflowJob.Status.SUCCEEDED))) { http://git-wip-us.apache.org/repos/asf/oozie/blob/30b29c81/core/src/main/resources/oozie-default.xml ---------------------------------------------------------------------- diff --git a/core/src/main/resources/oozie-default.xml b/core/src/main/resources/oozie-default.xml index 3d07c6f..e849fc7 100644 --- a/core/src/main/resources/oozie-default.xml +++ b/core/src/main/resources/oozie-default.xml @@ -2358,4 +2358,13 @@ </description> </property> + <property> + <name>oozie.wf.rerun.disablechild</name> + <value>false</value> + <description> + By setting this option, workflow rerun will be disabled if parent workflow or coordinator exist and + it will only rerun through parent. + </description> + </property> + </configuration> http://git-wip-us.apache.org/repos/asf/oozie/blob/30b29c81/core/src/test/java/org/apache/oozie/command/wf/TestReRunXCommand.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/oozie/command/wf/TestReRunXCommand.java b/core/src/test/java/org/apache/oozie/command/wf/TestReRunXCommand.java index fa128df..ce32e51 100644 --- a/core/src/test/java/org/apache/oozie/command/wf/TestReRunXCommand.java +++ b/core/src/test/java/org/apache/oozie/command/wf/TestReRunXCommand.java @@ -28,7 +28,6 @@ import java.io.Writer; import java.util.List; import org.apache.hadoop.fs.Path; import org.apache.oozie.local.LocalOozie; -import org.apache.oozie.action.hadoop.ShellActionExecutor; import org.apache.oozie.client.CoordinatorAction; import org.apache.oozie.client.CoordinatorJob; import org.apache.oozie.client.WorkflowJob; @@ -37,17 +36,17 @@ import org.apache.oozie.client.OozieClientException; import org.apache.oozie.client.WorkflowAction; import org.apache.oozie.command.coord.CoordActionStartXCommand; import org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor; +import org.apache.oozie.service.ActionService; +import org.apache.oozie.service.JPAService; +import org.apache.oozie.service.SchemaService; +import org.apache.oozie.service.Services; +import org.apache.oozie.service.XLogService; import org.apache.oozie.test.XDataTestCase; import org.apache.oozie.util.DateUtils; import org.apache.oozie.util.IOUtils; import org.apache.oozie.CoordinatorActionBean; import org.apache.oozie.CoordinatorJobBean; import org.apache.oozie.ErrorCode; -import org.apache.oozie.service.ActionService; -import org.apache.oozie.service.JPAService; -import org.apache.oozie.service.SchemaService; -import org.apache.oozie.service.Services; -import org.apache.oozie.service.XLogService; public class TestReRunXCommand extends XDataTestCase { @Override @@ -388,4 +387,56 @@ public class TestReRunXCommand extends XDataTestCase { } + /** + * Rerun workflow should run by parent only if configuration has been set to + * true for oozie.wf.child.disable.rerun , Default it is disabled. + * @throws Exception + */ + public void testRerunDisableForChild() throws Exception { + final OozieClient wfClient = LocalOozie.getClient(); + + Date start = DateUtils.parseDateOozieTZ("2009-12-15T01:00Z"); + Date end = DateUtils.parseDateOozieTZ("2009-12-16T01:00Z"); + CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, false, + 1); + + CoordinatorActionBean action = addRecordToCoordActionTable(coordJob.getId(), 1, + CoordinatorAction.Status.SUBMITTED, "coord-action-start-escape-strings.xml", 0); + + String actionId = action.getId(); + new CoordActionStartXCommand(actionId, getTestUser(), "myapp", "myjob").call(); + + final JPAService jpaService = Services.get().get(JPAService.class); + action = jpaService.execute(new CoordActionGetJPAExecutor(actionId)); + + if (action.getStatus() == CoordinatorAction.Status.SUBMITTED) { + fail("CoordActionStartCommand didn't work because the status for action id" + actionId + " is :" + + action.getStatus() + " expected to be NOT SUBMITTED (i.e. RUNNING)"); + } + final String wfId = action.getExternalId(); + wfClient.kill(wfId); + waitFor(15 * 1000, new Predicate() { + public boolean evaluate() throws Exception { + return wfClient.getJobInfo(wfId).getStatus() == WorkflowJob.Status.KILLED; + } + }); + Properties newConf = wfClient.createConfiguration(); + newConf.setProperty(OozieClient.RERUN_FAIL_NODES, "true"); + Services.get().getConf().setBoolean(ReRunXCommand.DISABLE_CHILD_RERUN, true); + try { + wfClient.reRun(wfId, newConf); + } catch (OozieClientException ex){ + assertEquals(ErrorCode.E0755.toString(), ex.getErrorCode()); + } + + Services.get().getConf().setBoolean(ReRunXCommand.DISABLE_CHILD_RERUN, false); + wfClient.reRun(wfId, newConf); + waitFor(15 * 1000, new Predicate() { + public boolean evaluate() throws Exception { + return wfClient.getJobInfo(wfId).getStatus() == WorkflowJob.Status.SUCCEEDED; + } + }); + assertEquals(WorkflowJob.Status.SUCCEEDED, wfClient.getJobInfo(wfId).getStatus()); + + } } http://git-wip-us.apache.org/repos/asf/oozie/blob/30b29c81/release-log.txt ---------------------------------------------------------------------- diff --git a/release-log.txt b/release-log.txt index 8c35624..363c3d6 100644 --- a/release-log.txt +++ b/release-log.txt @@ -1,5 +1,6 @@ -- Oozie 4.2.0 release (trunk - unreleased) +OOZIE-2027 Disable re-runs using the workflow directly if it has a parent (jaydeepvishwakarma via shwethags) OOZIE-2098 Add Apache parent POM to oozie (sureshms via bzhang) OOZIE-2093 TestSubmitXCommand.testProtoConfStorage fails against Hadoop 2 (rkanter) OOZIE-2028 Coord action rerun with -failed option should rerun existing workflow with RERUN_FAIL_NODES=true (jaydeepvishwakarma via shwethags)
