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

Drop tasks for CAs that are no longer present #1125 #1126

Merged
merged 1 commit into from
Sep 30, 2023
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
3 changes: 3 additions & 0 deletions src/daemon/ca/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1904,6 +1904,9 @@ impl CaManager {
self.ca_repo_sync(repo_manager, ca_handle, id, repo, objects).await?;
Ok(true)
}
} else if !self.has_ca(ca_handle)? {
debug!("Dropping task to sync removed CA '{ca_handle}' with its repository.");
Ok(true)
} else {
let ca = self.get_ca(ca_handle).await?;

Expand Down
82 changes: 43 additions & 39 deletions src/daemon/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,15 +357,20 @@ impl Scheduler {

/// Try to suspend children for a CA
async fn suspend_children_if_needed(&self, ca_handle: CaHandle) -> KrillResult<TaskResult> {
debug!("Verify if CA '{}' has children that need to be suspended", ca_handle);
self.ca_manager
.ca_suspend_inactive_children(&ca_handle, self.started, &self.system_actor)
.await;

Ok(TaskResult::FollowUp(
Task::SuspendChildrenIfNeeded { ca_handle },
in_hours(1),
))
if self.ca_manager.has_ca(&ca_handle)? {
debug!("Verify if CA '{}' has children that need to be suspended", ca_handle);
self.ca_manager
.ca_suspend_inactive_children(&ca_handle, self.started, &self.system_actor)
.await;

Ok(TaskResult::FollowUp(
Task::SuspendChildrenIfNeeded { ca_handle },
in_hours(1),
))
} else {
debug!("Drop task to suspend children for removed CA {ca_handle}");
Ok(TaskResult::Done)
}
}

/// Let CAs that need it republish their CRL/MFT
Expand Down Expand Up @@ -521,7 +526,8 @@ impl Scheduler {

let requests = HashMap::from([(rcn, revocation_requests)]);

if let Ok(ca) = self.ca_manager.get_ca(&ca_handle).await {
if self.ca_manager.has_ca(&ca_handle)? {
let ca = self.ca_manager.get_ca(&ca_handle).await?;
if ca.version() < ca_version {
// premature, we need to wait for the CA to be committed.
Ok(TaskResult::Reschedule(in_seconds(1)))
Expand All @@ -538,7 +544,7 @@ impl Scheduler {
Ok(TaskResult::Done)
}
} else {
// Ignoring resource class removed task for removed CA
debug!("Dropping task for removed resource class of removed CA {ca_handle}");
Ok(TaskResult::Done)
}
}
Expand All @@ -550,37 +556,35 @@ impl Scheduler {
rcn: ResourceClassName,
revocation_request: RevocationRequest,
) -> KrillResult<TaskResult> {
info!(
"Trigger sending revocation requests for unexpected key with id '{}' in RC '{}'",
revocation_request.key(),
rcn
);
match self.ca_manager.get_ca(&ca_handle).await {
Err(_e) => {
// Can't get CA - most likely because it's gone.

Ok(TaskResult::Done)
}
Ok(ca) => {
if ca.version() < ca_version {
debug!("reschedule premature task");
let next = in_seconds(100);
Ok(TaskResult::Reschedule(next))
} else {
if let Err(e) = self
.ca_manager
.send_revoke_unexpected_key(&ca_handle, rcn, revocation_request)
.await
{
warn!(
"Could not revoke surplus key, most likely already revoked by parent. Error was: {}",
e
);
}
if self.ca_manager.has_ca(&ca_handle)? {
info!(
"Trigger sending revocation requests for unexpected key with id '{}' in RC '{}'",
revocation_request.key(),
rcn
);
let ca = self.ca_manager.get_ca(&ca_handle).await?;

Ok(TaskResult::Done)
if ca.version() < ca_version {
debug!("reschedule premature task");
let next = in_seconds(100);
Ok(TaskResult::Reschedule(next))
} else {
if let Err(e) = self
.ca_manager
.send_revoke_unexpected_key(&ca_handle, rcn, revocation_request)
.await
{
warn!(
"Could not revoke surplus key, most likely already revoked by parent. Error was: {}",
e
);
}

Ok(TaskResult::Done)
}
} else {
debug!("Dropping task for surplus key for removed CA {ca_handle}");
Ok(TaskResult::Done)
}
}
}
Loading