Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding status and lastPoll fields to CrStates #6612

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [unreleased]
### Added
- [#6448](https://github.com/apache/trafficcontrol/issues/6448) Added `status` and `lastPoll` fields to the `publish/CrStates` endpoint of Traffic Monitor (TM).
- Added a new Traffic Ops endpoint to `GET` capacity and telemetry data for CDNi integration.
- Added a Traffic Ops endpoints to `PUT` a requested configuration change for a full configuration or per host and an endpoint to approve or deny the request.
- Traffic Monitor config option `distributed_polling` which enables the ability for Traffic Monitor to poll a subset of the CDN and divide into "local peer groups" and "distributed peer groups". Traffic Monitors in the same group are local peers, while Traffic Monitors in other groups are distibuted peers. Each TM group polls the same set of cachegroups and gets availability data for the other cachegroups from other TM groups. This allows each TM to be responsible for polling a subset of the CDN while still having a full view of CDN availability. In order to use this, `stat_polling` must be disabled.
Expand Down
53 changes: 47 additions & 6 deletions docs/source/development/traffic_monitor/traffic_monitor_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -343,22 +343,63 @@ TODO

``/publish/CrStates``
=====================
The current state of this CDN per the ref:`health-proto`.
The current state of this CDN per the :ref:`health-proto`.

``GET``
-------
:Response Type: ?
:Response Type: Object

.. code-block:: http
:caption: Example Request

GET /publish/CrStates HTTP/1.1
Accept: */*
Content-Type: application/json

Response Structure
""""""""""""""""""
:caches: An object with keys that are the names of monitored :term:`cache servers`

TODO
:server name: The name of the server being monitored
srijeet0406 marked this conversation as resolved.
Show resolved Hide resolved

:isAvailable: Whether or not this cache is available for routing
:ipv4Available: Whether or not an IPV4 interface on this cache is available for routing
:ipv6Available: Whether or not an IPV6 interface on this cache is available for routing
:status: The status of this server, along with any additional reason for it to be marked as such
:lastPoll: The last time the health data for this server was polled by a traffic monitor

:deliveryServices: An object with keys as the names of monitored :term:`Delivery Services`

:delivery service name: The name of the delivery service being monitored
srijeet0406 marked this conversation as resolved.
Show resolved Hide resolved

..????
**raw**
:disabledLocations: A list of disabled locations for this delivery service
:isAvailable: Whether or not this delivery service is available for routing

The current state of this CDN per this Traffic Monitor only.
.. code-block:: http
:caption: Example Response

HTTP/1.1 200 OK
Content-Type: application/json
Date: Thu, 14 May 2020 15:54:35 GMT
Transfer-Encoding: chunked

{
"caches": {
"server-name-01": {
"isAvailable": true,
"ipv4Available": true,
"ipv6Available": true,
"status": "REPORTED - id server-name-01 url http://[2001:db8:3333:4444:5555:6666:7777:8888]:80 fetch error: bad HTTP status: 403; interface0: not found in polled data",
"lastPoll": "2022-03-03T12:26:02.78556-07:00"
},...
},
"deliveryServices": {
"ds-1": {
"disabledLocations": [],
"isAvailable": true
},...
}
}

``/publish/CrConfig``
=====================
Expand Down
11 changes: 7 additions & 4 deletions lib/go-tc/crstates.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package tc

import (
"encoding/json"
"time"
)

// CRStates includes availability data for caches and delivery services, as gathered and aggregated by this Traffic Monitor. It is designed to be served at an API endpoint primarily for Traffic Routers (Content Router) to consume.
Expand All @@ -37,10 +38,12 @@ type CRStatesDeliveryService struct {

// IsAvailable contains whether the given cache or delivery service is available. It is designed for JSON serialization, namely in the Traffic Monitor 1.0 API.
type IsAvailable struct {
IsAvailable bool `json:"isAvailable"`
Ipv4Available bool `json:"ipv4Available"`
Ipv6Available bool `json:"ipv6Available"`
DirectlyPolled bool `json:"-"`
IsAvailable bool `json:"isAvailable"`
Ipv4Available bool `json:"ipv4Available"`
Ipv6Available bool `json:"ipv6Available"`
DirectlyPolled bool `json:"-"`
Status string `json:"status"`
LastPoll time.Time `json:"lastPoll"`
}

// NewCRStates creates a new CR states object, initializing pointer members.
Expand Down
2 changes: 2 additions & 0 deletions traffic_monitor/health/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ func CalcAvailability(
Ipv4Available: availStatus.Available.IPv4,
Ipv6Available: availStatus.Available.IPv6,
DirectlyPolled: true, // we know this cache was directly polled because otherwise we wouldn't have a cache.Result for it
Status: availStatus.Why,
LastPoll: result.Time,
})

if available, ok := localStates.GetCache(tc.CacheName(result.ID)); !ok || available.IsAvailable != lastStatus.ProcessedAvailable {
Expand Down
2 changes: 1 addition & 1 deletion traffic_monitor/manager/statecombiner.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func combineCacheState(
IPv6Available: ipv6Available})
}

combinedStates.AddCache(cacheName, tc.IsAvailable{IsAvailable: available, Ipv4Available: ipv4Available, Ipv6Available: ipv6Available, DirectlyPolled: localCacheState.DirectlyPolled})
combinedStates.AddCache(cacheName, tc.IsAvailable{IsAvailable: available, Ipv4Available: ipv4Available, Ipv6Available: ipv6Available, DirectlyPolled: localCacheState.DirectlyPolled, Status: localCacheState.Status, LastPoll: localCacheState.LastPoll})
}

func combineDSState(
Expand Down