Add a ping time that gives the last time a node was pinged

Signed-off-by: Sachin Kamboj <skamboj1@bloomberg.net>
This commit is contained in:
Sachin Kamboj
2020-04-07 21:04:43 -04:00
parent 2a78a9cec5
commit d68d35bbab
4 changed files with 35 additions and 0 deletions
+3
View File
@@ -86,6 +86,7 @@ func (p *Pinger) getClient() (*apiclient.Goldpinger, error) {
p.resultsChan <- PingAllPodsResult{
podName: p.pod.Name,
podResult: models.PodResult{
PingTime: strfmt.DateTime(time.Now()),
PodIP: p.podIPv4,
HostIP: p.hostIPv4,
OK: &OK,
@@ -124,6 +125,7 @@ func (p *Pinger) Ping() {
p.resultsChan <- PingAllPodsResult{
podName: p.pod.Name,
podResult: models.PodResult{
PingTime: strfmt.DateTime(start),
PodIP: p.podIPv4,
HostIP: p.hostIPv4,
OK: &OK,
@@ -137,6 +139,7 @@ func (p *Pinger) Ping() {
p.resultsChan <- PingAllPodsResult{
podName: p.pod.Name,
podResult: models.PodResult{
PingTime: strfmt.DateTime(start),
PodIP: p.podIPv4,
HostIP: p.hostIPv4,
OK: &OK,
+21
View File
@@ -24,6 +24,10 @@ type PodResult struct {
// o k
OK *bool `json:"OK,omitempty"`
// ping time
// Format: date-time
PingTime strfmt.DateTime `json:"PingTime,omitempty"`
// pod IP
// Format: ipv4
PodIP strfmt.IPv4 `json:"PodIP,omitempty"`
@@ -49,6 +53,10 @@ func (m *PodResult) Validate(formats strfmt.Registry) error {
res = append(res, err)
}
if err := m.validatePingTime(formats); err != nil {
res = append(res, err)
}
if err := m.validatePodIP(formats); err != nil {
res = append(res, err)
}
@@ -76,6 +84,19 @@ func (m *PodResult) validateHostIP(formats strfmt.Registry) error {
return nil
}
func (m *PodResult) validatePingTime(formats strfmt.Registry) error {
if swag.IsZero(m.PingTime) { // not required
return nil
}
if err := validate.FormatOf("PingTime", "body", "date-time", m.PingTime.String(), formats); err != nil {
return err
}
return nil
}
func (m *PodResult) validatePodIP(formats strfmt.Registry) error {
if swag.IsZero(m.PodIP) { // not required
+8
View File
@@ -259,6 +259,10 @@ func init() {
"type": "boolean",
"default": false
},
"PingTime": {
"type": "string",
"format": "date-time"
},
"PodIP": {
"type": "string",
"format": "ipv4"
@@ -527,6 +531,10 @@ func init() {
"type": "boolean",
"default": false
},
"PingTime": {
"type": "string",
"format": "date-time"
},
"PodIP": {
"type": "string",
"format": "ipv4"
+3
View File
@@ -37,6 +37,9 @@ definitions:
OK:
type: boolean
default: false
PingTime:
format: date-time
type: string
PodIP:
type: string
format: ipv4