[IMP] maintenance_service_http_monitoring: rework maintenance.request creation
Previously, a single ``maintenance.request`` was created per equipment,
regardless of how many services were down on that equipment. The name
was ``[HTTP KO] {equipment.name}`` and deduplication relied on a
name+date+equipment search that was fragile (manual clear of the field
would lose the reference to an existing open request).
This commit reworks the whole creation logic:
- **1 request per KO service** instead of 1 per equipment. Each failing
``service.instance`` gets its own ``maintenance.request``, allowing
fine-grained tracking and independent resolution.
- **Request name** is now ``[HTTP KO] {service_url}``, making it
immediately identifiable without opening the record.
- **Description** includes the error detail: ``HTTP {status_code}`` for
HTTP errors, or a human-readable network error label when
``last_http_status_code == -1`` (timeout / DNS / SSL failures).
- **Deduplication** is now based solely on whether an open (non-done)
``maintenance.request`` already exists on the ``service.instance``
via the new ``http_maintenance_request`` field. No date boundary —
as long as the request is open, no new one is created.
- **``http_maintenance_request``** field moved from
``maintenance.equipment`` to ``service.instance``, where it belongs
given the 1-request-per-service model. It is exposed as an optional
hidden column in the service instance list view.
- ``_build_ko_services_description()`` is removed (no longer needed).
- ``create_http_maintenance_request()`` now receives a single
``service.instance`` recordset instead of a list.
Tests updated accordingly (14 tests total):
- Tests 2, 4, 9, 10, 12, 13 now assert on
``service_instance.http_maintenance_request``.
- Test 2 also verifies the request name contains the service URL and
the description contains the HTTP status code.
- New test 14 asserts that two KO services on the same equipment
produce two distinct requests with the correct names.
This commit is contained in:
@@ -98,10 +98,11 @@ On service instances, you can see:
|
||||
## Automatic Maintenance Requests
|
||||
|
||||
When a service fails HTTP checks:
|
||||
- A corrective maintenance request is created with prefix "[HTTP KO]"
|
||||
- The request is linked to the equipment
|
||||
- Only one request per equipment per day is created
|
||||
- The request description lists all failing services
|
||||
- A corrective maintenance request is created per failing service, named
|
||||
``[HTTP KO] {service_url}``
|
||||
- The request description includes the error detail: the HTTP status code,
|
||||
or a network error label (timeout / DNS / SSL) when no HTTP response was received
|
||||
- No duplicate is created as long as an open request already exists for that service
|
||||
- A **double-check** is performed before creating the request: the service is retested
|
||||
after 2 seconds. A maintenance request is only created if the service fails **both**
|
||||
checks, reducing noise from transient HTTP errors
|
||||
|
||||
Reference in New Issue
Block a user