Skip to content

Commit 865549c

Browse files
Fix: do not assign to nil resp.Annotations map (#289)
* Return nil results map when server response is nil * Increase app engine build timeout
1 parent 66746c9 commit 865549c

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ script:
7474
# Run all tests and gather and submit coverage information.
7575
- GCLOUD_PROJECT=mlab-testing go test -v -coverpkg=./... -coverprofile=coverage.cov ./...
7676

77-
- $HOME/gopath/bin/goveralls -coverprofile=coverage.cov -service=travis-ci
77+
- $HOME/gopath/bin/goveralls -coverprofile=coverage.cov -service=travis-ci || true
7878
# Run benchmarks
7979
- go test -bench . ./geolite2v2/...
8080

@@ -96,6 +96,7 @@ deploy:
9696
# branch to sandbox for pre-review testing.
9797
- provider: script
9898
script:
99+
gcloud config set app/cloud_build_timeout 1200 &&
99100
$TRAVIS_BUILD_DIR/travis/deploy_app_legacy_keyfile.sh mlab-sandbox /tmp/mlab-sandbox.json $TRAVIS_BUILD_DIR annotator.yaml
100101
skip_cleanup: true
101102
on:
@@ -107,6 +108,7 @@ deploy:
107108
# STAGING: Should trigger AFTER code review and commit to master branch.
108109
- provider: script
109110
script:
111+
gcloud config set app/cloud_build_timeout 1200 &&
110112
$TRAVIS_BUILD_DIR/travis/deploy_app_legacy_keyfile.sh mlab-staging /tmp/mlab-staging.json $TRAVIS_BUILD_DIR annotator.yaml
111113
skip_cleanup: true
112114
on:
@@ -117,6 +119,7 @@ deploy:
117119
# when tagged with prod-*.
118120
- provider: script
119121
script:
122+
gcloud config set app/cloud_build_timeout 1200 &&
120123
$TRAVIS_BUILD_DIR/travis/deploy_app_legacy_keyfile.sh mlab-oti /tmp/mlab-oti.json $TRAVIS_BUILD_DIR annotator.yaml
121124
skip_cleanup: true
122125
on:

api/v2/api-v2.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,10 @@ func annotateServerIPs(ips []string) ([]string, map[string]*api.Annotations) {
202202
results[ip] = convert(s)
203203
}
204204
}
205-
return clients, results
205+
if len(results) > 0 {
206+
return clients, results
207+
}
208+
return clients, nil
206209
}
207210

208211
// GetAnnotations takes a url, and Request, makes remote call, and returns parsed ResponseV2
@@ -287,8 +290,12 @@ func GetAnnotations(ctx context.Context, url string, date time.Time, ips []strin
287290
decodeLogEvery.Println("Decode error:", ErrMoreJSON)
288291
}
289292
// Append server annotations to results from annotation-service server.
290-
for ip, ann := range serverAnn {
291-
resp.Annotations[ip] = ann
293+
if resp.Annotations == nil {
294+
resp.Annotations = serverAnn
295+
} else {
296+
for ip, ann := range serverAnn {
297+
resp.Annotations[ip] = ann
298+
}
292299
}
293300
return &resp, nil
294301
}

0 commit comments

Comments
 (0)