Commit
·
914fff5
1
Parent(s):
033b487
Update app/streamlit_app.py
Browse filesAdding Blue-Green Deployment Strategy
- app/streamlit_app.py +50 -0
app/streamlit_app.py
CHANGED
|
@@ -256,6 +256,28 @@ class StreamlitAppManager:
|
|
| 256 |
logger.warning(f"Could not fetch automation status: {e}")
|
| 257 |
return None
|
| 258 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
|
| 260 |
|
| 261 |
# Initialize app manager
|
|
@@ -1568,6 +1590,8 @@ def main():
|
|
| 1568 |
render_monitoring_alerts()
|
| 1569 |
st.divider()
|
| 1570 |
render_automation_status()
|
|
|
|
|
|
|
| 1571 |
|
| 1572 |
def render_system_status():
|
| 1573 |
"""Render system status tab"""
|
|
@@ -1764,6 +1788,32 @@ def render_automation_status():
|
|
| 1764 |
else:
|
| 1765 |
st.warning("Automation status not available")
|
| 1766 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1767 |
# Auto-refresh logic
|
| 1768 |
if st.session_state.auto_refresh:
|
| 1769 |
time_since_refresh = datetime.now() - st.session_state.last_refresh
|
|
|
|
| 256 |
logger.warning(f"Could not fetch automation status: {e}")
|
| 257 |
return None
|
| 258 |
|
| 259 |
+
# Blue-Green Deployment
|
| 260 |
+
def get_deployment_status_from_api(self):
|
| 261 |
+
"""Get deployment status from API"""
|
| 262 |
+
try:
|
| 263 |
+
if not self.api_available:
|
| 264 |
+
return None
|
| 265 |
+
response = self.session.get(f"{self.config['api_url']}/deployment/status", timeout=10)
|
| 266 |
+
return response.json() if response.status_code == 200 else None
|
| 267 |
+
except Exception as e:
|
| 268 |
+
logger.warning(f"Could not fetch deployment status: {e}")
|
| 269 |
+
return None
|
| 270 |
+
|
| 271 |
+
def get_traffic_status_from_api(self):
|
| 272 |
+
"""Get traffic routing status from API"""
|
| 273 |
+
try:
|
| 274 |
+
if not self.api_available:
|
| 275 |
+
return None
|
| 276 |
+
response = self.session.get(f"{self.config['api_url']}/deployment/traffic", timeout=10)
|
| 277 |
+
return response.json() if response.status_code == 200 else None
|
| 278 |
+
except Exception as e:
|
| 279 |
+
logger.warning(f"Could not fetch traffic status: {e}")
|
| 280 |
+
return None
|
| 281 |
|
| 282 |
|
| 283 |
# Initialize app manager
|
|
|
|
| 1590 |
render_monitoring_alerts()
|
| 1591 |
st.divider()
|
| 1592 |
render_automation_status()
|
| 1593 |
+
st.divider()
|
| 1594 |
+
render_deployment_status()
|
| 1595 |
|
| 1596 |
def render_system_status():
|
| 1597 |
"""Render system status tab"""
|
|
|
|
| 1788 |
else:
|
| 1789 |
st.warning("Automation status not available")
|
| 1790 |
|
| 1791 |
+
|
| 1792 |
+
def render_deployment_status():
|
| 1793 |
+
"""Render deployment system status"""
|
| 1794 |
+
st.subheader("🚀 Blue-Green Deployment Status")
|
| 1795 |
+
|
| 1796 |
+
deployment_data = app_manager.get_deployment_status_from_api()
|
| 1797 |
+
traffic_data = app_manager.get_traffic_status_from_api()
|
| 1798 |
+
|
| 1799 |
+
if deployment_data:
|
| 1800 |
+
current_deployment = deployment_data.get('current_deployment')
|
| 1801 |
+
active_version = deployment_data.get('active_version')
|
| 1802 |
+
traffic_split = deployment_data.get('traffic_split', {})
|
| 1803 |
+
|
| 1804 |
+
col1, col2, col3 = st.columns(3)
|
| 1805 |
+
with col1:
|
| 1806 |
+
st.metric("Active Version", active_version['version_id'] if active_version else "None")
|
| 1807 |
+
with col2:
|
| 1808 |
+
st.metric("Blue Traffic", f"{traffic_split.get('blue', 0)}%")
|
| 1809 |
+
with col3:
|
| 1810 |
+
st.metric("Green Traffic", f"{traffic_split.get('green', 0)}%")
|
| 1811 |
+
|
| 1812 |
+
if current_deployment:
|
| 1813 |
+
st.info(f"Current deployment: {current_deployment['deployment_id']} ({current_deployment['status']})")
|
| 1814 |
+
else:
|
| 1815 |
+
st.warning("Deployment status not available")
|
| 1816 |
+
|
| 1817 |
# Auto-refresh logic
|
| 1818 |
if st.session_state.auto_refresh:
|
| 1819 |
time_since_refresh = datetime.now() - st.session_state.last_refresh
|