Skip to content
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
24 changes: 14 additions & 10 deletions dstack/gateway/src/distributed_certbot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ impl DistributedCertBot {
}

fn release_rotation_lock(&self, lock: &crate::kv::CertRenewLock) -> Result<()> {
self.kv_store.release_rotation_lock(lock)?;
self.kv_store
.release_rotation_lock(lock, ROTATION_LOCK_TIMEOUT_SECS)?;
self.notify_lock_write();
Ok(())
}
Expand All @@ -174,7 +175,8 @@ impl DistributedCertBot {
}

fn release_cert_lock(&self, domain: &str, lock: &crate::kv::CertRenewLock) -> Result<()> {
self.kv_store.release_cert_lock(domain, lock)?;
self.kv_store
.release_cert_lock(domain, lock, RENEW_LOCK_TIMEOUT_SECS)?;
self.notify_lock_write();
Ok(())
}
Expand Down Expand Up @@ -832,12 +834,13 @@ impl DistributedCertBot {
Ok(Some(client))
}

/// Register the cluster's shared ACME account, or adopt the one that
/// appeared while this call was waiting for the lock.
/// Register the cluster's shared ACME account, or adopt the one the
/// previous lock holder registered after this call last looked.
///
/// Called with the ACME lock held. The re-read is the point: without it
/// every waiter registers an account of its own the moment it is let
/// through, which is the race the lock was taken to avoid.
/// Called with the ACME lock held. The re-read is the point: without it a
/// caller that found no account, then took the lock once it was released,
/// would register one of its own, which is the race the lock was taken to
/// avoid.
async fn register_or_adopt_account(
&self,
domain: &str,
Expand Down Expand Up @@ -1224,7 +1227,7 @@ mod tests {
/// built only after the lock is granted, so an unreachable provider (as
/// configured here) cannot be what this run fails on.
#[tokio::test]
async fn first_use_registration_waits_for_the_rotation_lock() {
async fn first_use_registration_is_refused_while_the_rotation_lock_is_held() {
let data_dir = tempfile::tempdir().expect("failed to create temp dir");
let certbot = certbot_with_domain(data_dir.path());
let config = test_zt_domain_config();
Expand Down Expand Up @@ -1453,10 +1456,11 @@ mod tests {
let stale = crate::kv::CertRenewLock {
started_at: current.started_at.saturating_sub(100),
started_by: 99,
nonce: 0,
};
certbot
.kv_store
.release_rotation_lock(&stale)
.release_rotation_lock(&stale, ROTATION_LOCK_TIMEOUT_SECS)
.expect("stale release should be a no-op, not an error");
assert!(
certbot
Expand All @@ -1467,7 +1471,7 @@ mod tests {
);
certbot
.kv_store
.release_rotation_lock(&current)
.release_rotation_lock(&current, ROTATION_LOCK_TIMEOUT_SECS)
.expect("owner release should succeed");
assert!(certbot
.kv_store
Expand Down
Loading
Loading