From 851c9d0d41d7591b1b1f382c5479a706d59b0304 Mon Sep 17 00:00:00 2001 From: Nick Sardo Date: Tue, 6 Jun 2017 13:02:57 -0700 Subject: [PATCH] Fix backend status out of bounds --- controllers/gce/backends/backends.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/controllers/gce/backends/backends.go b/controllers/gce/backends/backends.go index 4cb797731..5c66b3dfa 100644 --- a/controllers/gce/backends/backends.go +++ b/controllers/gce/backends/backends.go @@ -419,9 +419,11 @@ func (b *Backends) Shutdown() error { // Status returns the status of the given backend by name. func (b *Backends) Status(name string) string { backend, err := b.cloud.GetBackendService(name) - if err != nil { + if err != nil || len(backend.Backends) == 0 { return "Unknown" } + + // TODO: Look at more than one backend's status // TODO: Include port, ip in the status, since it's in the health info. hs, err := b.cloud.GetHealth(name, backend.Backends[0].Group) if err != nil || len(hs.HealthStatus) == 0 || hs.HealthStatus[0] == nil {