-
Notifications
You must be signed in to change notification settings - Fork 200
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
report error creating cron #732
Merged
+73
−19
Merged
Changes from 8 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c7297ce
report error creating cron
dtrager02 b19c2f7
add ut
dtrager02 435610b
validate cron in job definition constructor
dtrager02 0453f2b
fix unit test
dtrager02 a79dea6
fixed tests
dtrager02 1d02cf6
empty commit
dtrager02 c6b0034
empty
dtrager02 99e40b3
Merge branch 'master' into cron-error-reporting
Andyz26 f7cecb0
report error creating cron
dtrager02 1242e0c
add ut
dtrager02 1d4132e
validate cron in job definition constructor
dtrager02 9721df2
fix unit test
dtrager02 1c3eb4a
fixed tests
dtrager02 b29b8a1
empty commit
dtrager02 83e24d9
empty
dtrager02 1815edc
return on error handleR
dtrager02 031d0bb
merge
dtrager02 61a83fd
increase test retry interval to reduce flakiness
dtrager02 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,7 @@ | |
import io.mantisrx.master.jobcluster.job.MantisJobMetadataView; | ||
import io.mantisrx.master.jobcluster.job.worker.IMantisWorkerMetadata; | ||
import io.mantisrx.master.jobcluster.proto.JobClusterManagerProto; | ||
import io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.CreateJobClusterResponse; | ||
import io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.DeleteJobClusterResponse; | ||
import io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.DisableJobClusterRequest; | ||
import io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.DisableJobClusterResponse; | ||
|
@@ -701,7 +702,7 @@ public void onJobClusterInitialize(JobClusterProto.InitializeJobClusterRequest i | |
// create sla enforcer | ||
slaEnforcer = new SLAEnforcer(jobClusterMetadata.getJobClusterDefinition().getSLA()); | ||
long expireFrequency = ConfigurationProvider.getConfig().getCompletedJobPurgeFrequencySeqs(); | ||
|
||
String jobClusterName = jobClusterMetadata.getJobClusterDefinition().getName(); | ||
// If cluster is disabled | ||
if(jobClusterMetadata.isDisabled()) { | ||
logger.info("Cluster {} initialized but is Disabled", jobClusterMetadata | ||
|
@@ -718,7 +719,7 @@ public void onJobClusterInitialize(JobClusterProto.InitializeJobClusterRequest i | |
int count = 50; | ||
if(!initReq.jobList.isEmpty()) { | ||
logger.info("Cluster {} is disabled however it has {} active/accepted jobs", | ||
jobClusterMetadata.getJobClusterDefinition().getName(), initReq.jobList.size()); | ||
jobClusterName, initReq.jobList.size()); | ||
for(IMantisJobMetadata jobMeta : initReq.jobList) { | ||
try { | ||
if(count == 0) { | ||
|
@@ -728,7 +729,7 @@ public void onJobClusterInitialize(JobClusterProto.InitializeJobClusterRequest i | |
if(!JobState.isTerminalState(jobMeta.getState())) { | ||
logger.info("Job {} is in non terminal state {} for disabled cluster {}." | ||
+ "Marking it complete", jobMeta.getJobId(), jobMeta.getState(), | ||
jobClusterMetadata.getJobClusterDefinition().getName()); | ||
jobClusterName); | ||
count--; | ||
jobManager.markCompleted(jobMeta); | ||
jobStore.archiveJob(jobMeta); | ||
|
@@ -758,7 +759,7 @@ public void onJobClusterInitialize(JobClusterProto.InitializeJobClusterRequest i | |
eventPublisher.publishAuditEvent( | ||
new LifecycleEventsProto.AuditEvent( | ||
LifecycleEventsProto.AuditEvent.AuditEventType.JOB_CLUSTER_CREATE, | ||
jobClusterMetadata.getJobClusterDefinition().getName(), | ||
jobClusterName, | ||
"saved job cluster " + name) | ||
); | ||
logger.info("successfully saved job cluster {}", name); | ||
|
@@ -790,6 +791,10 @@ public void onJobClusterInitialize(JobClusterProto.InitializeJobClusterRequest i | |
cronManager = new CronManager(name, getSelf(), jobClusterMetadata.getJobClusterDefinition().getSLA()); | ||
} catch (Exception e) { | ||
logger.warn("Exception initializing cron", e); | ||
getSender().tell(new JobClusterManagerProto.CreateJobClusterResponse( | ||
initReq.requestId, e instanceof SchedulerException?CLIENT_ERROR:SERVER_ERROR, | ||
"Job Cluster " + jobClusterName + " could not be created due to cron initialization error" + e.getMessage(), | ||
jobClusterName), getSelf()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in this case don't you want to stop here and not initRunning workers? |
||
} | ||
initRunningJobs(initReq, sender); | ||
|
||
|
@@ -916,7 +921,7 @@ public void onJobClusterUpdate(final UpdateJobClusterRequest request) { | |
} catch (Exception e) { | ||
logger.error("job cluster not created"); | ||
sender.tell(new UpdateJobClusterResponse(request.requestId, SERVER_ERROR, name | ||
+ " Job cluster updation failed " + e.getMessage()), getSelf()); | ||
+ " Job cluster update failed " + e.getMessage()), getSelf()); | ||
numJobClusterUpdateErrors.increment(); | ||
} | ||
} | ||
|
@@ -1271,13 +1276,13 @@ public void onJobClusterEnable(final EnableJobClusterRequest req) { | |
.withLastJobCount(this.jobClusterMetadata.getLastJobCount()) | ||
.withJobClusterDefinition((JobClusterDefinitionImpl)this.jobClusterMetadata.getJobClusterDefinition()) | ||
.build(); | ||
//update store | ||
jobStore.updateJobCluster(jobClusterMetadata); | ||
this.jobClusterMetadata = jobClusterMetadata; | ||
if (cronManager == null) { | ||
cronManager = new CronManager(name, getSelf(), jobClusterMetadata.getJobClusterDefinition().getSLA()); | ||
} | ||
this.cronManager.initCron(); | ||
//update store after cron init | ||
jobStore.updateJobCluster(jobClusterMetadata); | ||
this.jobClusterMetadata = jobClusterMetadata; | ||
// change behavior to enabled | ||
getContext().become(initializedBehavior); | ||
|
||
|
@@ -1294,7 +1299,7 @@ public void onJobClusterEnable(final EnableJobClusterRequest req) { | |
} catch(Exception e) { | ||
String errorMsg = String.format("Exception enabling cluster %s due to %s", name, e.getMessage()); | ||
logger.error(errorMsg,e); | ||
sender.tell(new EnableJobClusterResponse(req.requestId, SERVER_ERROR, errorMsg), getSelf()); | ||
sender.tell(new EnableJobClusterResponse(req.requestId, e instanceof SchedulerException?CLIENT_ERROR:SERVER_ERROR, errorMsg), getSelf()); | ||
numJobClusterEnableErrors.increment(); | ||
} | ||
if(logger.isTraceEnabled()) { logger.trace("Enter onJobClusterEnable"); } | ||
|
@@ -2122,24 +2127,23 @@ public void onJobClusterUpdateSLA(UpdateJobClusterSLARequest slaRequest) { | |
.withJobClusterDefinition(updatedDefn) | ||
.build(); | ||
|
||
updateAndSaveJobCluster(jobCluster); | ||
if(cronManager != null) | ||
cronManager.destroyCron(); | ||
this.cronManager = new CronManager(name, getSelf(), newSla); | ||
|
||
updateAndSaveJobCluster(jobCluster); //update after cron succeeds | ||
sender.tell(new UpdateJobClusterSLAResponse(slaRequest.requestId, SUCCESS, name + " SLA updated"), getSelf()); | ||
|
||
eventPublisher.publishAuditEvent( | ||
new LifecycleEventsProto.AuditEvent(LifecycleEventsProto.AuditEvent.AuditEventType.JOB_CLUSTER_UPDATE, | ||
jobClusterMetadata.getJobClusterDefinition().getName(), name+" SLA update") | ||
); | ||
} catch(IllegalArgumentException e) { | ||
} catch(IllegalArgumentException | SchedulerException e) { | ||
logger.error("Invalid arguement job cluster not updated ", e); | ||
sender.tell(new UpdateJobClusterSLAResponse(slaRequest.requestId, CLIENT_ERROR, name + " Job cluster SLA updation failed " + e.getMessage()), getSelf()); | ||
sender.tell(new UpdateJobClusterSLAResponse(slaRequest.requestId, CLIENT_ERROR, name + " Job cluster SLA update failed " + e.getMessage()), getSelf()); | ||
|
||
} catch(Exception e) { | ||
logger.error("job cluster not updated ", e); | ||
sender.tell(new UpdateJobClusterSLAResponse(slaRequest.requestId, SERVER_ERROR, name + " Job cluster SLA updation failed " + e.getMessage()), getSelf()); | ||
sender.tell(new UpdateJobClusterSLAResponse(slaRequest.requestId, SERVER_ERROR, name + " Job cluster SLA update failed " + e.getMessage()), getSelf()); | ||
} | ||
if(logger.isTraceEnabled()) { logger.trace("Exit onJobClusterUpdateSLA {}", slaRequest); } | ||
} | ||
|
@@ -3217,7 +3221,7 @@ private void initCron() throws Exception{ | |
isCronActive = true; | ||
} catch (IllegalArgumentException e) { | ||
destroyCron(); | ||
logger.error("Failed to start cron for {}: {}", jobClusterName, e); | ||
logger.error("Failed to start cron for {}: {}. The format of the cron schedule may be incorrect.", jobClusterName, e.getStackTrace()); | ||
throw new SchedulerException(e.getMessage(), e); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe separate this catch to known error (SchedulerException) and other error (exception) and use different error code + message.