From c573f9d0b510efaf7c90f0bfb3d0cf8e0ee7b9d6 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 14 Jan 2015 14:52:45 -0800 Subject: [PATCH] dashboard/buildlet: fix start-up crash when TLS attributes aren't set I had never run the 44d7ecb402b7c on GCE, and never caught that it crashed on start-up if TLS attributes weren't defined. Updated to use the new NotDefinedError from the metadata package in https://code-review.googlesource.com/#/c/1790/ Change-Id: Iaec8df126e4cef8026c930e8cc0163ae088affb3 Reviewed-on: https://go-review.googlesource.com/2736 Reviewed-by: Burcu Dogan --- dashboard/buildlet/buildlet.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dashboard/buildlet/buildlet.go b/dashboard/buildlet/buildlet.go index a2d911c3..ad65b952 100644 --- a/dashboard/buildlet/buildlet.go +++ b/dashboard/buildlet/buildlet.go @@ -119,6 +119,7 @@ func main() { } // metadataValue returns the GCE metadata instance value for the given key. +// If the metadata is not defined, the returned string is empty. // // If not running on GCE, it falls back to using environment variables // for local development. @@ -126,6 +127,9 @@ func metadataValue(key string) string { // The common case: if metadata.OnGCE() { v, err := metadata.InstanceAttributeValue(key) + if _, notDefined := err.(metadata.NotDefinedError); notDefined { + return "" + } if err != nil { log.Fatalf("metadata.InstanceAttributeValue(%q): %v", key, err) }