Skip to content

Commit 6223e90

Browse files
authored
use IP for MDS (#115)
1 parent 0fa7703 commit 6223e90

File tree

2 files changed

+1
-18
lines changed

2 files changed

+1
-18
lines changed

google_guest_agent/main.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ func run(ctx context.Context) {
130130
opts.Writers = []io.Writer{&serialPort{"COM1"}}
131131
}
132132

133-
setMetadataURL()
134-
135133
var err error
136134
newMetadata, err = getMetadata(ctx, false)
137135
if err == nil {
@@ -173,9 +171,6 @@ func run(ctx context.Context) {
173171
// not to spam the log on network failures.
174172
if webError == 1 {
175173
if urlErr, ok := err.(*url.Error); ok {
176-
if _, ok := urlErr.Err.(*net.DNSError); ok {
177-
logger.Errorf("DNS error when requesting metadata, check DNS settings and ensure metadata.internal.google is setup in your hosts file.")
178-
}
179174
if _, ok := urlErr.Err.(*net.OpError); ok {
180175
logger.Errorf("Network error when requesting metadata, make sure your instance has an active network and can reach the metadata server.")
181176
}

google_guest_agent/metadata.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"encoding/json"
2121
"fmt"
2222
"io/ioutil"
23-
"net"
2423
"net/http"
2524
"strconv"
2625
"strings"
@@ -32,24 +31,13 @@ import (
3231
const defaultEtag = "NONE"
3332

3433
var (
35-
metadataURL = ""
36-
metadataHost = "metadata.google.internal"
37-
metadataFallback = "169.254.169.254"
38-
metadataPath = "/computeMetadata/v1/"
34+
metadataURL = "http://169.254.169.254/computeMetadata/v1/"
3935
metadataRecursive = "/?recursive=true&alt=json"
4036
metadataHang = "&wait_for_change=true&timeout_sec=60"
4137
defaultTimeout = 70 * time.Second
4238
etag = defaultEtag
4339
)
4440

45-
func setMetadataURL() {
46-
host := metadataHost
47-
if _, err := net.LookupIP(host); err != nil {
48-
host = metadataFallback
49-
}
50-
metadataURL = "http://" + host + metadataPath
51-
}
52-
5341
type metadata struct {
5442
Instance instance
5543
Project project

0 commit comments

Comments
 (0)