Skip to content

Commit

Permalink
fix status parsing (micro#1368)
Browse files Browse the repository at this point in the history
  • Loading branch information
asim committed Mar 18, 2020
1 parent 1bd3407 commit 99c3fe2
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions runtime/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,27 +124,33 @@ func (k *kubernetes) getService(labels map[string]string) ([]*service, error) {
svc.Service.Metadata[k] = v
}

// get the status from the pods
var status string
// parse out deployment status and inject into service metadata
if len(kdep.Status.Conditions) > 0 {
svc.Metadata["status"] = kdep.Status.Conditions[0].Type
delete(svc.Metadata, "error")
} else {
svc.Metadata["status"] = "n/a"
}

// get the real status
for _, item := range podList.Items {
var status string

// inspect the
if item.Metadata.Name != name {
continue
}

switch item.Status.Phase {
case "Failed":
status = item.Status.Reason
default:
status = item.Status.Phase
}
}

// unknown status
if len(status) == 0 {
status = "n/a"
svc.Metadata["status"] = status
}

if logger.V(logger.DebugLevel, logger.DefaultLogger) {
logger.Debugf("Runtime setting %s service deployment status: %v", name, status)
}
svc.Service.Metadata["status"] = status
// save deployment
svc.kdeploy = &kdep
}
Expand Down

0 comments on commit 99c3fe2

Please sign in to comment.