Skip to content

Commit

Permalink
update: added operation_job_status
Browse files Browse the repository at this point in the history
  • Loading branch information
heemankv committed Dec 19, 2024
1 parent 9e67649 commit 085d6bc
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions crates/orchestrator/src/jobs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,12 @@ pub async fn verify_job(id: Uuid, config: Arc<Config>) -> Result<(), JobError> {
let verification_status = job_handler.verify_job(config.clone(), &mut job).await?;
tracing::Span::current().record("verification_status", format!("{:?}", &verification_status));

let attributes = [
let mut attributes = vec![
KeyValue::new("operation_job_type", format!("{:?}", job.job_type)),
KeyValue::new("operation_type", "verify_job"),
KeyValue::new("operation_verification_status", format!("{:?}", &verification_status)),
];
let mut operation_job_status: Option<JobStatus> = None;

match verification_status {
JobVerificationStatus::Verified => {
Expand Down Expand Up @@ -380,12 +381,13 @@ pub async fn verify_job(id: Uuid, config: Arc<Config>) -> Result<(), JobError> {
tracing::error!(job_id = ?id, error = ?e, "Failed to update job status to Completed");
JobError::Other(OtherError(e))
})?;
operation_job_status = Some(JobStatus::Completed);
}
JobVerificationStatus::Rejected(e) => {
tracing::warn!(job_id = ?id, error = ?e, "Job verification rejected");
let mut new_job = job.clone();
new_job.metadata.insert(JOB_METADATA_ERROR.to_string(), e);
new_job.status = JobStatus::VerificationFailed;
let mut new_job_metadata = job.metadata.clone();
new_job_metadata.insert(JOB_METADATA_ERROR.to_string(), e);
operation_job_status = Some(JobStatus::VerificationFailed);

let process_attempts = get_u64_from_metadata(&job.metadata, JOB_PROCESS_ATTEMPT_METADATA_KEY)
.map_err(|e| JobError::Other(OtherError(e)))?;
Expand All @@ -402,7 +404,7 @@ pub async fn verify_job(id: Uuid, config: Arc<Config>) -> Result<(), JobError> {
&job,
JobItemUpdates::new()
.update_status(JobStatus::VerificationFailed)
.update_metadata(new_job.metadata)
.update_metadata(new_job_metadata)
.build(),
)
.await
Expand Down Expand Up @@ -437,6 +439,7 @@ pub async fn verify_job(id: Uuid, config: Arc<Config>) -> Result<(), JobError> {
tracing::error!(job_id = ?id, error = ?e, "Failed to update job status to VerificationTimeout");
JobError::Other(OtherError(e))
})?;
operation_job_status = Some(JobStatus::VerificationTimeout);
return Ok(());
}
let metadata = increment_key_in_metadata(&job.metadata, JOB_VERIFICATION_ATTEMPT_METADATA_KEY)?;
Expand All @@ -463,6 +466,8 @@ pub async fn verify_job(id: Uuid, config: Arc<Config>) -> Result<(), JobError> {
}
};

attributes.push(KeyValue::new("operation_job_status", format!("{:?}", operation_job_status)));

tracing::info!(log_type = "completed", category = "general", function_type = "verify_job", block_no = %internal_id, "General verify job completed for block");
let duration = start.elapsed();
ORCHESTRATOR_METRICS.successful_job_operations.add(1.0, &attributes);
Expand Down

0 comments on commit 085d6bc

Please sign in to comment.