Service Status in Detail Page #341

Closed
opened 2025-12-18 13:29:49 +00:00 by tobru · 1 comment
Owner

Stories

As a user, I want to know the current state of my service if it's healthy or not

Implementation Notes

As a follow-up to #333 add live status information about the service instance to the instance detail page. From the PR:

Currently, the best way to provide live status information is to query the Pod status of the service.

On a Claim on the Kubernetes API (e.g. VSHNForgejo), we can get the namespace where the actual service is deployed into by querying the field .status.instanceNamespace. We can then get some status information from the Pods running in this service specific namespace. It might be that there are no Pods, one Pod, multiple Pods; this has to be coped with.

I talked to Claude to ask about Pod status fields which could help us to communicate the Service Status: https://claude.ai/share/0d2ad9d5-6f22-4f4e-8df8-14775b0ecd40

From that conversation, I propose: Use the "1. Service Status - combine phase and ready condition" and "4. Health status" from the proposed get_user_friendly_status() function and display this information in the service detail page. The problem is that in a service namespace, multiple Pods can be available, and for that reason, we need to use a label selector for Pods in instance namespaces: "app,!job-name,!batch.kubernetes.io/controller-uid"

def get_user_friendly_status(pod_data):  
    status = pod_data.get('status', {})
    metadata = pod_data.get('metadata', {})
    
    # 1. Service Status - combine phase and ready condition
    phase = status.get('phase', 'Unknown')
    conditions = {c['type']: c['status'] for c in status.get('conditions', [])}
    
    if phase == 'Running' and conditions.get('Ready') == 'True':
        service_status = 'operational'
        status_label = 'Operational'
        status_icon = '🟢'
    elif phase == 'Running' and conditions.get('Ready') != 'True':
        service_status = 'degraded'
        status_label = 'Starting up'
        status_icon = '🟡'
    elif phase == 'Pending':
        service_status = 'starting'
        status_label = 'Starting'
        status_icon = '🟡'
    else:
        service_status = 'unavailable'
        status_label = 'Unavailable'
        status_icon = '🔴'
    
    
    # 4. Health status
    is_ready = container_statuses[0].get('ready', False) if container_statuses else False
    health = 'Healthy' if is_ready else 'Unhealthy'
    
    return {
        'status': service_status,
        'status_label': status_label,
        'status_icon': status_icon,
        'health': health,
    }

For now we will not use any streaming or Server-Sent Events (SSE), because this is quite a lot of work to make it right. We can use simple polling for now. Keywords for later: django-channels and django-eventstream.

Furthermore, let's display the Kubernetes events from the instance namespace as well, because this can be helpful information when something doesn't work. Let's put this information into the "Technical Details" section.

## Stories _As a user, I want to know the current state of my service if it's healthy or not_ ## Implementation Notes As a follow-up to #333 add live status information about the service instance to the instance detail page. From the PR: Currently, the best way to provide live status information is to query the Pod status of the service. On a Claim on the Kubernetes API (e.g. VSHNForgejo), we can get the namespace where the actual service is deployed into by querying the field `.status.instanceNamespace`. We can then get some status information from the Pods running in this service specific namespace. It might be that there are no Pods, one Pod, multiple Pods; this has to be coped with. I talked to Claude to ask about Pod status fields which could help us to communicate the Service Status: https://claude.ai/share/0d2ad9d5-6f22-4f4e-8df8-14775b0ecd40 From that conversation, I propose: Use the "1. Service Status - combine phase and ready condition" and "4. Health status" from the proposed `get_user_friendly_status()` function and display this information in the service detail page. The problem is that in a service namespace, multiple Pods can be available, and for that reason, we need to use a label selector for Pods in instance namespaces: `"app,!job-name,!batch.kubernetes.io/controller-uid"` ```python def get_user_friendly_status(pod_data): status = pod_data.get('status', {}) metadata = pod_data.get('metadata', {}) # 1. Service Status - combine phase and ready condition phase = status.get('phase', 'Unknown') conditions = {c['type']: c['status'] for c in status.get('conditions', [])} if phase == 'Running' and conditions.get('Ready') == 'True': service_status = 'operational' status_label = 'Operational' status_icon = '🟢' elif phase == 'Running' and conditions.get('Ready') != 'True': service_status = 'degraded' status_label = 'Starting up' status_icon = '🟡' elif phase == 'Pending': service_status = 'starting' status_label = 'Starting' status_icon = '🟡' else: service_status = 'unavailable' status_label = 'Unavailable' status_icon = '🔴' # 4. Health status is_ready = container_statuses[0].get('ready', False) if container_statuses else False health = 'Healthy' if is_ready else 'Unhealthy' return { 'status': service_status, 'status_label': status_label, 'status_icon': status_icon, 'health': health, } ``` For now we will not use any streaming or Server-Sent Events (SSE), because this is quite a lot of work to make it right. We can use simple polling for now. Keywords for later: `django-channels` and [`django-eventstream`](https://github.com/fanout/django-eventstream). Furthermore, let's display the Kubernetes events from the instance namespace as well, because this can be helpful information when something doesn't work. Let's put this information into the "Technical Details" section.
Author
Owner

And a small QoL improvement: When there are no secrets, we should still show the "Connection Credentials" section, but inform that the credentials aren't currently available or the service is still provisioning.

I did that in b9e9ba5fba

~~And a small QoL improvement: When there are no secrets, we should still show the "Connection Credentials" section, but inform that the credentials aren't currently available or the service is still provisioning.~~ I did that in b9e9ba5fbac1f55b086c90c90a7a701e3f2d5ee7
tobru self-assigned this 2026-01-16 15:54:41 +00:00
rixx closed this issue 2026-01-22 15:03:13 +00:00
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
servala/servala-portal#341
No description provided.