Add check for k8s condition (#1412)

This commit is contained in:
Asim Aslam 2020-03-25 19:32:41 +00:00 committed by GitHub
parent 378d03eb66
commit 8d0826a031
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -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

View File

@ -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"`