MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / request_new_cert

Method request_new_cert

gateway/src/distributed_certbot.rs:152–180  ·  view source on GitHub ↗
(&self, domain: &str)

Source from the content-addressed store, hash-verified

150 /// Request new certificate for a domain
151 #[tracing::instrument(skip(self))]
152 async fn request_new_cert(&self, domain: &str) -> Result<()> {
153 let config = self
154 .kv_store
155 .get_zt_domain_config(domain)
156 .context("ZT-Domain config not found")?;
157
158 // Try to acquire lock first
159 if !self
160 .kv_store
161 .try_acquire_cert_lock(domain, RENEW_LOCK_TIMEOUT_SECS)
162 {
163 // Another node is requesting, wait for it
164 info!("another node is requesting, waiting...");
165 tokio::time::sleep(Duration::from_secs(30)).await;
166 if let Some(cert_data) = self.kv_store.get_cert_data(domain) {
167 self.cert_resolver.update_cert(domain, &cert_data)?;
168 return Ok(());
169 }
170 bail!("failed to get certificate from KvStore after waiting");
171 }
172
173 let result = self.do_request_new(domain, &config).await;
174
175 if let Err(err) = self.kv_store.release_cert_lock(domain) {
176 error!("failed to release lock: {err:?}");
177 }
178
179 result
180 }
181
182 async fn do_request_new(&self, domain: &str, config: &ZtDomainConfig) -> Result<()> {
183 let acme_client = self.get_or_create_acme_client(domain, config).await?;

Callers 1

init_domainMethod · 0.80

Calls 6

get_zt_domain_configMethod · 0.80
try_acquire_cert_lockMethod · 0.80
update_certMethod · 0.80
do_request_newMethod · 0.80
release_cert_lockMethod · 0.80
get_cert_dataMethod · 0.45

Tested by

no test coverage detected