fix(metadata): Ignore non-2XX HTTP responses from metadata service
This commit is contained in:
parent
e3741a0fa3
commit
c1173346c1
@ -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…
Reference in New Issue
Block a user