Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GOBBLIN-1857] Add override flag to force generate a job execution id based on gobbl… #3719

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ public class GobblinClusterConfigurationKeys {
public static final String CANCEL_RUNNING_JOB_ON_DELETE = GOBBLIN_CLUSTER_PREFIX + "job.cancelRunningJobOnDelete";
public static final String DEFAULT_CANCEL_RUNNING_JOB_ON_DELETE = "false";

// Job Execution ID for Helix jobs is inferred from Flow Execution IDs, but there are scenarios in earlyStop jobs where
// this behavior needs to be avoided due to concurrent planning and actual jobs sharing the same execution ID
public static final String USE_GENERATED_JOBEXECUTION_IDS = GOBBLIN_CLUSTER_PREFIX + "job.useGeneratedJobExecutionIds";

// By default we cancel job by calling helix stop API. In some cases, jobs just hang in STOPPING state and preventing
// new job being launched. We provide this config to give an option to cancel jobs by calling Delete API. Directly delete
// a Helix workflow should be safe in Gobblin world, as Gobblin job is stateless for Helix since we implement our own state store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,17 @@ public HelixJobsMapping(Config sysConfig, URI fsUri, String rootDir) {
}

public static String createPlanningJobId (Properties jobPlanningProps) {
long planningJobId = PropertiesUtils.getPropAsBoolean(jobPlanningProps, GobblinClusterConfigurationKeys.USE_GENERATED_JOBEXECUTION_IDS, "false") ?
System.currentTimeMillis() : PropertiesUtils.getPropAsLong(jobPlanningProps, ConfigurationKeys.FLOW_EXECUTION_ID_KEY, System.currentTimeMillis());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in non-earlyStop scenarios is there an advantage to re-using the flow execution id for job id? Is this just for identifying the job more easily? In the early stop case is there a log line or something we can use to track the job id or how do we make the association?

Copy link
Contributor Author

@Will-Lo Will-Lo Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The advantage is primarily for tracking, GobblinTrackingEvents have an execution ID in their metadata and it would work nicely if the execution ID also allowed the caller to identify the flow execution ID from it as well, lets the user perform cancel() etc.
Uhh for earlyStop maybe we can append something to the jobName but it'll be hacky, I feel like that feature should be redesigned in general to follow gobblin conventions better

return JobLauncherUtils.newJobId(GobblinClusterConfigurationKeys.PLANNING_JOB_NAME_PREFIX
+ JobState.getJobNameFromProps(jobPlanningProps),
PropertiesUtils.getPropAsLong(jobPlanningProps, ConfigurationKeys.FLOW_EXECUTION_ID_KEY, System.currentTimeMillis()));
+ JobState.getJobNameFromProps(jobPlanningProps), planningJobId);
}

public static String createActualJobId (Properties jobProps) {
return JobLauncherUtils.newJobId(GobblinClusterConfigurationKeys.ACTUAL_JOB_NAME_PREFIX
+ JobState.getJobNameFromProps(jobProps),
PropertiesUtils.getPropAsLong(jobProps, ConfigurationKeys.FLOW_EXECUTION_ID_KEY, System.currentTimeMillis()));
long actualJobId = PropertiesUtils.getPropAsBoolean(jobProps, GobblinClusterConfigurationKeys.USE_GENERATED_JOBEXECUTION_IDS, "false") ?
System.currentTimeMillis() : PropertiesUtils.getPropAsLong(jobProps, ConfigurationKeys.FLOW_EXECUTION_ID_KEY, System.currentTimeMillis());
return JobLauncherUtils.newJobId(GobblinClusterConfigurationKeys.ACTUAL_JOB_NAME_PREFIX
+ JobState.getJobNameFromProps(jobProps), actualJobId);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.gobblin.cluster;

import java.util.Properties;

import org.testng.Assert;
import org.testng.annotations.Test;

import org.apache.gobblin.configuration.ConfigurationKeys;


public class GobblinHelixJobMappingTest {

@Test
void testMapJobNameWithFlowExecutionId() {
Properties props = new Properties();
props.setProperty(ConfigurationKeys.FLOW_EXECUTION_ID_KEY, "1234");
props.setProperty(ConfigurationKeys.JOB_NAME_KEY, "job1");
String planningJobId = HelixJobsMapping.createPlanningJobId(props);
String actualJobId = HelixJobsMapping.createActualJobId(props);
Assert.assertEquals(planningJobId, "job_PlanningJobjob1_1234");
Assert.assertEquals(actualJobId, "job_ActualJobjob1_1234");
}

@Test
void testMapJobNameWithOverride() {
Properties props = new Properties();
props.setProperty(GobblinClusterConfigurationKeys.USE_GENERATED_JOBEXECUTION_IDS, "true");
props.setProperty(ConfigurationKeys.FLOW_EXECUTION_ID_KEY, "1234");
props.setProperty(ConfigurationKeys.JOB_NAME_KEY, "job1");
String planningJobId = HelixJobsMapping.createPlanningJobId(props);
String actualJobId = HelixJobsMapping.createActualJobId(props);
// The jobID will be the system timestamp instead of the flow execution ID
Assert.assertNotEquals(planningJobId, "job_PlanningJobjob1_1234");
Assert.assertNotEquals(actualJobId, "job_ActualJobjob1_1234");
}
}