Skip to content

Commit 70fd675

Browse files
Oskar Jagodzinskitomez
authored andcommitted
Print all tasks hostname and port
1 parent 0e3f57f commit 70fd675

File tree

12 files changed

+54
-30
lines changed

12 files changed

+54
-30
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sudo: false
44
services:
55
- docker
66
go:
7-
- 1.8
7+
- 1.12
88
before_install:
99
- go get github.com/mattn/goveralls
1010
script:

Makefile

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ deps:
2929
lint: deps lint-deps onlylint
3030

3131
lint-deps:
32-
go get -u github.com/alecthomas/gometalinter
33-
gometalinter --install
32+
@which golangci-lint > /dev/null || \
33+
(go get -u github.com/golangci/golangci-lint/cmd/golangci-lint)
3434

3535
release: lint test
3636
GOARCH=amd64 GOOS=linux $(GO_BUILD) -o build/appcop .
@@ -45,14 +45,7 @@ pack: test lint build
4545
docker build -t appcop . && mkdir -p dist && docker run -v ${PWD}/dist:/work/dist appcop
4646

4747
onlylint: build
48-
gometalinter \
49-
--deadline=720s \
50-
--disable=dupl \
51-
--disable=gotype \
52-
--disable=gas \
53-
--disable=golint \
54-
--enable=gofmt \
55-
--vendor
48+
golangci-lint run --config=golangcilinter.yaml web marathon metrics mgc score config
5649

5750
version: deps
5851
echo -n $(v) > VERSION

golangcilinter.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
run:
2+
aggregate: true
3+
concurrency: 2
4+
cyclo: 14
5+
deadline: "300s"
6+
skip-files:
7+
- ".*_string.go"
8+
- ".*_test.go"
9+
issues:
10+
max-same-issues: 0
11+
linters:
12+
disable-all: true
13+
enable:
14+
- stylecheck
15+
- deadcode
16+
- errcheck
17+
- gocyclo
18+
- goimports
19+
- golint
20+
- gosimple
21+
- govet

marathon/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (app *App) penalize() error {
4242
if app.Instances >= 1 {
4343
app.Instances--
4444
} else {
45-
return fmt.Errorf("Unable to scale down, zero instance")
45+
return fmt.Errorf("unable to scale down, zero instance")
4646
}
4747

4848
if app.Instances == 0 {

marathon/app_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ var penalizeTestCases = []struct {
252252
expectedApp: &App{ID: "testApp4",
253253
Instances: 0,
254254
Labels: map[string]string{"APPLABEL": "true"}},
255-
expectedErr: fmt.Errorf("Unable to scale down, zero instance"),
255+
expectedErr: fmt.Errorf("unable to scale down, zero instance"),
256256
},
257257
}
258258

marathon/marathon.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func (m Marathon) get(url string) ([]byte, error) {
165165
if response.StatusCode != 200 {
166166
metrics.Mark("marathon.get.error")
167167
metrics.Mark(fmt.Sprintf("marathon.get.error.%d", response.StatusCode))
168-
err = fmt.Errorf("Expected 200 but got %d for %s", response.StatusCode, response.Request.URL.Path)
168+
err = fmt.Errorf("expected 200 but got %d for %s", response.StatusCode, response.Request.URL.Path)
169169
m.logHTTPError(response, err)
170170
return nil, err
171171
}
@@ -202,7 +202,7 @@ func (m Marathon) update(url string, d []byte) ([]byte, error) {
202202
if response.StatusCode != 200 {
203203
metrics.Mark("marathon.put.error")
204204
metrics.Mark(fmt.Sprintf("marathon.put.error.%d", response.StatusCode))
205-
err = fmt.Errorf("Expected 200 but got %d for %s", response.StatusCode, response.Request.URL.Path)
205+
err = fmt.Errorf("expected 200 but got %d for %s", response.StatusCode, response.Request.URL.Path)
206206
m.logHTTPError(response, err)
207207
return nil, err
208208
}
@@ -239,7 +239,7 @@ func (m Marathon) delete(url string) ([]byte, error) {
239239
if response.StatusCode != 200 {
240240
metrics.Mark("marathon.delete.error")
241241
metrics.Mark(fmt.Sprintf("marathon.delete.error.%d", response.StatusCode))
242-
err = fmt.Errorf("Expected 200 but got %d for %s", response.StatusCode, response.Request.URL.Path)
242+
err = fmt.Errorf("expected 200 but got %d for %s", response.StatusCode, response.Request.URL.Path)
243243
m.logHTTPError(response, err)
244244
return nil, err
245245
}

marathon/marathon_stub.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type ScaleCounter struct {
3434
// AppsGet get stubbed apps
3535
func (m MStub) AppsGet() ([]*App, error) {
3636
if m.AppsGetFail {
37-
return nil, errors.New("Unable to get applications from marathon")
37+
return nil, errors.New("unable to get applications from marathon")
3838
}
3939
return m.Apps, nil
4040
}
@@ -79,7 +79,7 @@ func (m MStub) LeaderGet() (string, error) {
7979
// AppScaleDown by one instance
8080
func (m MStub) AppScaleDown(app *App) error {
8181
if m.AppScaleDownFail {
82-
return errors.New("Unable to scale down")
82+
return errors.New("unable to scale down")
8383
}
8484
m.ScaleCounter.Counter = 1
8585
return nil
@@ -88,12 +88,12 @@ func (m MStub) AppScaleDown(app *App) error {
8888
// AppDelete application by provided AppID
8989
func (m MStub) AppDelete(appID AppID) error {
9090
if m.AppDelFail {
91-
return errors.New("Unable to delete app")
91+
return errors.New("unable to delete app")
9292
}
9393
if m.AppDelHalfFail {
9494
if m.FailCounter.Counter%2 == 0 {
9595
m.FailCounter.Counter++
96-
return errors.New("Unable to delete app")
96+
return errors.New("unable to delete app")
9797
}
9898
m.FailCounter.Counter++
9999
}
@@ -103,7 +103,7 @@ func (m MStub) AppDelete(appID AppID) error {
103103
// GroupDelete by provided GroupID
104104
func (m MStub) GroupDelete(groupID GroupID) error {
105105
if m.GroupDelFail {
106-
return errors.New("Unable to delete group")
106+
return errors.New("unable to delete group")
107107
}
108108
return nil
109109
}

metrics/metrics.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ import (
1212
"time"
1313

1414
log "github.com/Sirupsen/logrus"
15-
"github.com/cyberdelia/go-metrics-graphite"
15+
graphite "github.com/cyberdelia/go-metrics-graphite"
1616
"github.com/rcrowley/go-metrics"
1717
)
1818

1919
const (
20-
PathSeparator = "/"
20+
// PathSeparator is separator of groups in app name
21+
PathSeparator = "/"
22+
// MetricSeparator is separator of groups in metrics system
2123
MetricSeparator = "."
2224
)
2325

@@ -28,6 +30,7 @@ var (
2830
appSubPrefix string
2931
)
3032

33+
// FilterOutEmptyStrings filters empty strings
3134
func FilterOutEmptyStrings(data []string) []string {
3235
var parts []string
3336
for _, part := range data {
@@ -57,7 +60,7 @@ func Mark(name string) {
5760
meter.Mark(1)
5861
}
5962

60-
// Mark or register Meter on graphite
63+
// MarkApp marks or register Meter on graphite
6164
func MarkApp(name string) {
6265
meter := metrics.GetOrRegisterMeter(
6366
appMetric(name),
@@ -124,7 +127,7 @@ func Init(cfg Config) error {
124127
log.Infof("Metrics disabled")
125128
return nil
126129
default:
127-
return fmt.Errorf("Invalid metrics target %s", cfg.Target)
130+
return fmt.Errorf("invalid metrics target %s", cfg.Target)
128131
}
129132
}
130133

score/score.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (s *Scorer) EvaluateApps() {
156156
if err != nil && i == 0 {
157157
log.WithError(err).Error("Failed to evaluate")
158158
}
159-
log.Debug("%d apps qualified for penalty", i)
159+
log.Debugf("%d apps qualified for penalty", i)
160160
}
161161

162162
func (s *Scorer) evaluateApps() (int, error) {
@@ -221,7 +221,7 @@ func (s *Scorer) scaleDown(appID marathon.AppID) error {
221221
if app.HasImmunity() {
222222
// returning error up makes sure rate limiting works,
223223
// otherwise AppCop could loop over immune apps
224-
return fmt.Errorf("App: %s has immunity", app.ID)
224+
return fmt.Errorf("app: %s has immunity", app.ID)
225225
}
226226

227227
err = s.service.AppScaleDown(app)

web/event.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func parseEvent(reader *bufio.Reader) (Event, error) {
9292
if err == io.EOF {
9393
dispatch = e.parseLine(line)
9494
if !dispatch {
95-
return e, errors.New("Unexpected EOF")
95+
return e, errors.New("unexpected EOF")
9696
}
9797
return e, io.EOF
9898
}

0 commit comments

Comments
 (0)