Skip to content

Commit 85d1356

Browse files
authored
On non-oracle instances, http client for IMDS endpoint returns nil response. This commit handles the nil response.
1 parent 07ce5dd commit 85d1356

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

oracle/oracle.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,11 @@ func getRequest(endpoint string, headers map[string]string) (map[string]interfac
139139

140140
resp, err := client.Do(req)
141141
if err != nil {
142-
return metadata, resp.StatusCode,
143-
fmt.Errorf("metadata lookup from [%s] endpoint failed with error:[%v]", endpoint, err)
142+
errMsg := fmt.Errorf("metadata lookup from [%s] endpoint failed with error:[%v]", endpoint, err)
143+
if resp != nil {
144+
return metadata, resp.StatusCode, errMsg
145+
}
146+
return metadata, http.StatusNotFound, errMsg
144147
}
145148
if resp.StatusCode != http.StatusOK {
146149
return metadata, resp.StatusCode, nil

0 commit comments

Comments
 (0)