Merge pull request #17 from coreos/metadata-404
fix(metadata): Ignore non-2XX HTTP responses from metadata service
This commit is contained in:
commit
a8a3b10277
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user