Compare commits
1 Commits
perplexity
...
groq/issue
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9fc4722a9e |
44
bin/rollback_command.py
Normal file
44
bin/rollback_command.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import os
|
||||
import subprocess
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
DEPLOYMENT_HISTORY_DIR = os.path.expanduser("~/deployment_history")
|
||||
|
||||
def rollback(service_name: str):
|
||||
"""Rollback to last known good version of a service"""
|
||||
deployments = sorted(
|
||||
[f for f in os.listdir(DEPLOYMENT_HISTORY_DIR) if f.startswith(f"{service_name}_")],
|
||||
reverse=True
|
||||
)
|
||||
|
||||
if not deployments:
|
||||
print(f"No deployment history found for {service_name}")
|
||||
return
|
||||
|
||||
last_success = None
|
||||
for dep in deployments:
|
||||
path = os.path.join(DEPLOYMENT_HISTORY_DIR, dep)
|
||||
with open(path, 'r') as f:
|
||||
data = json.load(f)
|
||||
if data.get('status') == 'success':
|
||||
last_success = data
|
||||
break
|
||||
|
||||
if not last_success:
|
||||
print(f"No successful deployment found for {service_name}")
|
||||
return
|
||||
|
||||
print(f"Rolling back {service_name} to {last_success['version']}")
|
||||
subprocess.run([
|
||||
"kubectl", "set", "image", "deployment/"+service_name,
|
||||
f"{service_name}={last_success['image']}"
|
||||
])
|
||||
print(f"Rolled back {service_name} to {last_success['version']}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: bezalel-rollback <service>")
|
||||
else:
|
||||
rollback(sys.argv[1])
|
||||
@@ -7,6 +7,15 @@ import secrets
|
||||
class L402Handler(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
if self.path == '/api/cost-estimate':
|
||||
# Original implementation continues...
|
||||
|
||||
def do_POST(self):
|
||||
if self.path == '/api/staging-verify':
|
||||
content_length = int(self.headers['Content-Length'])
|
||||
payload = self.rfile.read(content_length)
|
||||
self.send_response(200)
|
||||
self.end_headers()
|
||||
self.wfile.write(b'Staging verification received')
|
||||
# Simulate L402 Challenge
|
||||
macaroon = secrets.token_hex(16)
|
||||
invoice = "lnbc1..." # Mock invoice
|
||||
|
||||
Reference in New Issue
Block a user