mirror of
https://github.com/prometheus/prometheus
synced 2024-12-28 17:52:22 +00:00
Merge pull request #1731 from prometheus/release-0.19
Forward-merge 0.19 fixes to master
This commit is contained in:
commit
2ea3a837c3
@ -216,6 +216,9 @@ func createTargetGroup(app *App) *config.TargetGroup {
|
|||||||
func targetsForApp(app *App) []model.LabelSet {
|
func targetsForApp(app *App) []model.LabelSet {
|
||||||
targets := make([]model.LabelSet, 0, len(app.Tasks))
|
targets := make([]model.LabelSet, 0, len(app.Tasks))
|
||||||
for _, t := range app.Tasks {
|
for _, t := range app.Tasks {
|
||||||
|
if len(t.Ports) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
target := targetForTask(&t)
|
target := targetForTask(&t)
|
||||||
targets = append(targets, model.LabelSet{
|
targets = append(targets, model.LabelSet{
|
||||||
model.AddressLabel: model.LabelValue(target),
|
model.AddressLabel: model.LabelValue(target),
|
||||||
|
@ -175,3 +175,49 @@ func TestMarathonSDRunAndStop(t *testing.T) {
|
|||||||
t.Fatalf("Channel not closed.")
|
t.Fatalf("Channel not closed.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func marathonTestZeroTaskPortAppList(labels map[string]string, runningTasks int) *AppList {
|
||||||
|
task := Task{
|
||||||
|
ID: "test-task-2",
|
||||||
|
Host: "mesos-slave-2",
|
||||||
|
Ports: []uint32{},
|
||||||
|
}
|
||||||
|
docker := DockerContainer{Image: "repo/image:tag"}
|
||||||
|
container := Container{Docker: docker}
|
||||||
|
app := App{
|
||||||
|
ID: "test-service-zero-ports",
|
||||||
|
Tasks: []Task{task},
|
||||||
|
RunningTasks: runningTasks,
|
||||||
|
Labels: labels,
|
||||||
|
Container: container,
|
||||||
|
}
|
||||||
|
return &AppList{
|
||||||
|
Apps: []App{app},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMarathonZeroTaskPorts(t *testing.T) {
|
||||||
|
ch, md := newTestDiscovery(func(url string) (*AppList, error) {
|
||||||
|
return marathonTestZeroTaskPortAppList(marathonValidLabel, 1), nil
|
||||||
|
})
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
select {
|
||||||
|
case tgs := <-ch:
|
||||||
|
tg := tgs[0]
|
||||||
|
|
||||||
|
if tg.Source != "test-service-zero-ports" {
|
||||||
|
t.Fatalf("Wrong target group name: %s", tg.Source)
|
||||||
|
}
|
||||||
|
if len(tg.Targets) != 0 {
|
||||||
|
t.Fatalf("Wrong number of targets: %v", tg.Targets)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
t.Fatal("Did not get a target group.")
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
err := md.updateServices(context.Background(), ch)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Got error: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user