diff --git a/Makefile b/Makefile index b6ba009a6..5d020de7a 100644 --- a/Makefile +++ b/Makefile @@ -323,15 +323,7 @@ install-golint: errcheck: install-errcheck errcheck -exclude=errcheck_excludes.txt ./lib/... - errcheck -exclude=errcheck_excludes.txt ./app/vminsert/... - errcheck -exclude=errcheck_excludes.txt ./app/vmselect/... - errcheck -exclude=errcheck_excludes.txt ./app/vmstorage/... - errcheck -exclude=errcheck_excludes.txt ./app/vmagent/... - errcheck -exclude=errcheck_excludes.txt ./app/vmalert/... - errcheck -exclude=errcheck_excludes.txt ./app/vmauth/... - errcheck -exclude=errcheck_excludes.txt ./app/vmbackup/... - errcheck -exclude=errcheck_excludes.txt ./app/vmrestore/... - errcheck -exclude=errcheck_excludes.txt ./app/vmctl/... + errcheck -exclude=errcheck_excludes.txt ./app/... install-errcheck: which errcheck || go install github.com/kisielk/errcheck@latest diff --git a/app/victoria-metrics/main_test.go b/app/victoria-metrics/main_test.go index 805a5567a..d5f27b0a4 100644 --- a/app/victoria-metrics/main_test.go +++ b/app/victoria-metrics/main_test.go @@ -138,7 +138,7 @@ func setUp() { if err != nil { return false } - resp.Body.Close() + _ = resp.Body.Close() return resp.StatusCode == 200 } if err := waitFor(testStorageInitTimeout, readyStorageCheckFunc); err != nil { @@ -337,7 +337,9 @@ func tcpWrite(t *testing.T, address string, data string) { s := newSuite(t) conn, err := net.Dial("tcp", address) s.noError(err) - defer conn.Close() + defer func() { + _ = conn.Close() + }() n, err := conn.Write([]byte(data)) s.noError(err) s.equalInt(n, len(data)) @@ -348,7 +350,9 @@ func httpReadMetrics(t *testing.T, address, query string) []Metric { s := newSuite(t) resp, err := http.Get(address + query) s.noError(err) - defer resp.Body.Close() + defer func() { + _ = resp.Body.Close() + }() s.equalInt(resp.StatusCode, 200) var rows []Metric for dec := json.NewDecoder(resp.Body); dec.More(); { @@ -363,7 +367,9 @@ func httpReadStruct(t *testing.T, address, query string, dst interface{}) { s := newSuite(t) resp, err := http.Get(address + query) s.noError(err) - defer resp.Body.Close() + defer func() { + _ = resp.Body.Close() + }() s.equalInt(resp.StatusCode, 200) s.noError(json.NewDecoder(resp.Body).Decode(dst)) } diff --git a/app/victoria-metrics/self_scraper.go b/app/victoria-metrics/self_scraper.go index fb544a009..e8540eddd 100644 --- a/app/victoria-metrics/self_scraper.go +++ b/app/victoria-metrics/self_scraper.go @@ -85,7 +85,9 @@ func selfScraper(scrapeInterval time.Duration) { mr.Timestamp = currentTimestamp mr.Value = r.Value } - vmstorage.AddRows(mrs) + if err := vmstorage.AddRows(mrs); err != nil { + logger.Errorf("cannot store self-scraped metrics: %s", err) + } } }