Add check for k8s condition (#1412)
This commit is contained in:
parent
378d03eb66
commit
8d0826a031
@ -129,6 +129,7 @@ func (k *kubernetes) getService(labels map[string]string) ([]*service, error) {
|
||||
// parse out deployment status and inject into service metadata
|
||||
if len(kdep.Status.Conditions) > 0 {
|
||||
svc.Metadata["status"] = kdep.Status.Conditions[0].Type
|
||||
svc.Metadata["started"] = kdep.Status.Conditions[0].LastUpdate
|
||||
delete(svc.Metadata, "error")
|
||||
} else {
|
||||
svc.Metadata["status"] = "n/a"
|
||||
@ -154,6 +155,11 @@ func (k *kubernetes) getService(labels map[string]string) ([]*service, error) {
|
||||
status = item.Status.Phase
|
||||
}
|
||||
|
||||
// skip if we can't get the container
|
||||
if len(item.Status.Containers) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
// now try get a deeper status
|
||||
state := item.Status.Containers[0].State
|
||||
|
||||
|
@ -39,6 +39,7 @@ type DeploymentSpec struct {
|
||||
|
||||
// DeploymentCondition describes the state of deployment
|
||||
type DeploymentCondition struct {
|
||||
LastUpdate string `json:lastUpdateTime`
|
||||
Type string `json:"type"`
|
||||
reason string `json:"reason,omitempty"`
|
||||
message string `json:"message,omitempty"`
|
||||
|
Loading…
x
Reference in New Issue
Block a user