2 x containers Working through cloudflare!
This commit is contained in:
@@ -240,7 +240,7 @@ def update_container_workload(system_container_id):
|
||||
data = request.json
|
||||
|
||||
# Validate new_status
|
||||
valid_statuses = ["running", "deleted", "stopped"]
|
||||
valid_statuses = ["running", "deleted", "stopped","dead"]
|
||||
if data.get("new_status") not in valid_statuses:
|
||||
error_message = f"Invalid status. Must be one of: {', '.join(valid_statuses)}"
|
||||
logger.error(error_message)
|
||||
|
||||
@@ -227,11 +227,12 @@ class Workload(BaseModel):
|
||||
None: ["pending", "pending-allocation", "error"], # Initial state
|
||||
"pending": ["provisioning", "error"],
|
||||
"provisioning": ["running", "error"],
|
||||
"running": ["stopping", "error","pending-deleted"],
|
||||
"running": ["stopping", "error","pending-deleted","dead"],
|
||||
"pending-allocation": ["running", "error","allocated","pending-deleted"],
|
||||
"allocated":["pending-deleted","running"],
|
||||
"allocated":["pending-deleted","running","dead"],
|
||||
"pending-allocated": ["*"],
|
||||
"pending-deleted": ["running","deleted"] # A container can go from pending-deleted to running if there is a race between a deletion and a creation event
|
||||
"dead": ["*"],
|
||||
"pending-deleted": ["running","deleted","dead"] # A container can go from pending-deleted to running if there is a race between a deletion and a creation event
|
||||
# ... other valid transitions
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
export CFToken=eyJhIjoiNTA5NWE3NGI2MmZlZTUzY2M1ZDk5N2M2NzQ0M2JhYzUiLCJ0IjoiNzdlMmE4N2QtYTNiOC00OWVhLWIzY2MtOGVkOTFlNzhlMmY0IiwicyI6Ik5HRXpObUpqWVRZdE4yTTJNeTAwWW1NeExXRTNNVFl0WVdabE1UUmtaalJrT0RJMiJ9
|
||||
|
||||
docker run --rm --network container:NSCONTROLLER_864657c1-aa98-4d77-a5d0-6119a94c6d37_0f4fd733-e64a-4005-b64b-53e8413dc233 --name cftunel cloudflare/cloudflared:latest tunnel --no-autoupdate run --token $CFToken
|
||||
|
||||
@@ -172,7 +172,7 @@ def render_detail():
|
||||
# Edit Container Workload Form
|
||||
with st.expander("Edit Container Workload"):
|
||||
with st.form("edit_container"):
|
||||
new_status = st.selectbox("Status", ["running", "stopped", "pending","failed-deleted","pending-deleted","pending-allocation","failed-allocation","pending-allocated"], index=["running", "stopped", "pending","failed-deleted","pending-deleted","pending-allocation","failed-allocation","pending-allocated"].index(container['status']))
|
||||
new_status = st.selectbox("Status", ["running", "stopped", "pending","failed-deleted","pending-deleted","pending-allocation","failed-allocation","pending-allocated","dead"], index=["running", "stopped", "pending","failed-deleted","pending-deleted","pending-allocation","failed-allocation","pending-allocated","dead"].index(container['status']))
|
||||
new_launch_params = st.text_input("Launch Parameters", value=container.get('launch_params', ''))
|
||||
submit = st.form_submit_button("Update Container Workload")
|
||||
|
||||
|
||||
@@ -669,6 +669,27 @@ def handle_docker_event(data):
|
||||
websocket_server_response = requests.put(f"{api_server_url}{action_URL}", data=json.dumps(payload), headers=headers)
|
||||
logger.debug( websocket_server_response)
|
||||
logger.info("Update complete")
|
||||
|
||||
if event_type=="docker_die":
|
||||
#Send the update to the API Server
|
||||
# system_container_id
|
||||
# worker_id
|
||||
# state="started"
|
||||
# timestamp
|
||||
action_URL=f"workloads/containers/status_update/{system_container_id}"
|
||||
logger.debug(f"Sending task update payload to API server for Container ID {system_container_id}")
|
||||
|
||||
payload = {
|
||||
"new_status": "dead",
|
||||
"system_container_id": system_container_id,
|
||||
"worker_id": worker_id,
|
||||
"timestamp": timestamp
|
||||
}
|
||||
|
||||
headers = {"Content-Type": "application/json"}
|
||||
websocket_server_response = requests.put(f"{api_server_url}{action_URL}", data=json.dumps(payload), headers=headers)
|
||||
logger.debug( websocket_server_response)
|
||||
logger.info("Update complete")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error processing Docker event: {e}")
|
||||
|
||||
@@ -163,7 +163,8 @@ class ContainerTask:
|
||||
"image": container['NSController_launchparams']['docker_image'],
|
||||
"name": container['NSController_launchparams']['container_name'],
|
||||
"command": container['NSController_launchparams']['command'],
|
||||
"network": "none",
|
||||
"dns": ["1.1.1.1"],
|
||||
# "network": "none",
|
||||
"detach": True,
|
||||
"labels": {
|
||||
"managed_by": "worker_agent",
|
||||
|
||||
Reference in New Issue
Block a user