Merge pull request #17 from coreos/metadata-404

fix(metadata): Ignore non-2XX HTTP responses from metadata service
This commit is contained in:
polvi 2014-03-13 21:44:35 -07:00
commit a8a3b10277
2 changed files with 10 additions and 1 deletions

View File

@ -19,8 +19,12 @@ func (ms *metadataService) UserData() ([]byte, error) {
if err != nil {
return []byte{}, err
}
defer resp.Body.Close()
if resp/100 != 2 {
return []byte{}, nil
}
respBytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err

View File

@ -61,6 +61,11 @@ func main() {
os.Exit(1)
}
if userdata == "" {
log.Printf("No user data to handle, exiting.")
os.Exit(0)
}
parsed, err := cloudinit.ParseUserData(userdata)
if err != nil {
log.Fatalf("Failed parsing user-data: %v", err)