Skip to content

Commit bb9c4ee

Browse files
committed
fix
1 parent 3c12166 commit bb9c4ee

File tree

1 file changed

+37
-8
lines changed

1 file changed

+37
-8
lines changed

custom-domain/dstack-ingress/scripts/certman.py

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,25 @@ def install_plugin(self) -> bool:
6363
print(f"Plugin {self.provider.CERTBOT_PLUGIN} successfully imported")
6464

6565
# Try to create a simple test to see if the plugin works
66+
print(f"Testing if plugin {self.provider.CERTBOT_PLUGIN} is available...")
6667
test_cmd = ["certbot", "plugins"]
6768
test_result = subprocess.run(test_cmd, capture_output=True, text=True, timeout=10)
69+
70+
print(f"Certbot plugins command returned: {test_result.returncode}")
71+
if test_result.stdout:
72+
print(f"Available plugins:")
73+
print(test_result.stdout)
74+
75+
if test_result.stderr:
76+
print(f"Plugin test stderr: {test_result.stderr}")
77+
6878
if test_result.returncode == 0 and "dns-namecheap" in test_result.stdout:
69-
print(f"Plugin {self.provider.CERTBOT_PLUGIN} is working correctly")
79+
print(f"Plugin {self.provider.CERTBOT_PLUGIN} is available and working correctly")
7080
return True
7181
else:
72-
print(f"Plugin {self.provider.CERTBOT_PLUGIN} test failed: {test_result.stderr}")
82+
print(f"Plugin {self.provider.CERTBOT_PLUGIN} may not be properly installed")
83+
if "dns-namecheap" not in test_result.stdout:
84+
print(f"Warning: dns-namecheap plugin not found in certbot plugins list")
7385
# In Docker environments, this might still work in practice
7486
print("Continuing anyway - plugin may work in actual certbot execution")
7587
return True
@@ -114,6 +126,7 @@ def _build_certbot_command(self, action: str, domain: str, email: str) -> List[s
114126
[
115127
"-a", plugin,
116128
"--non-interactive",
129+
"-v", # Add verbose flag for detailed output
117130
]
118131
)
119132
print(f"Added plugin and non-interactive flags")
@@ -162,6 +175,17 @@ def obtain_certificate(self, domain: str, email: str) -> bool:
162175
return False
163176
print(f"Credentials setup completed")
164177

178+
# Check certbot version for debugging
179+
try:
180+
version_cmd = ["certbot", "--version"]
181+
version_result = subprocess.run(version_cmd, capture_output=True, text=True, timeout=10)
182+
if version_result.returncode == 0:
183+
print(f"Certbot version: {version_result.stdout.strip()}")
184+
else:
185+
print(f"Could not determine certbot version")
186+
except Exception as e:
187+
print(f"Error checking certbot version: {e}")
188+
165189
cmd = self._build_certbot_command("certonly", domain, email)
166190
print(f"Executing certbot command...")
167191

@@ -170,15 +194,20 @@ def obtain_certificate(self, domain: str, email: str) -> bool:
170194

171195
print(f"Certbot command completed with return code: {result.returncode}")
172196

173-
if result.stdout:
174-
print(f"Certbot stdout: {result.stdout}")
197+
# Always print stdout if available
198+
if result.stdout.strip():
199+
print(f"=== Certbot stdout ===")
200+
print(result.stdout)
201+
print(f"=== End stdout ===")
202+
203+
# Always print stderr if available
204+
if result.stderr.strip():
205+
print(f"=== Certbot stderr ===", file=sys.stderr)
206+
print(result.stderr, file=sys.stderr)
207+
print(f"=== End stderr ===", file=sys.stderr)
175208

176209
if result.returncode != 0:
177210
print(f"Certificate obtaining failed with return code {result.returncode}")
178-
if result.stderr:
179-
print(f"Certificate obtaining failed: {result.stderr}", file=sys.stderr)
180-
if result.stdout:
181-
print(f"Certificate stdout on failure: {result.stdout}", file=sys.stderr)
182211
return False
183212

184213
print(f"Certificate obtained successfully for {domain}")

0 commit comments

Comments
 (0)