Skip to content

Commit d27a5c1

Browse files
committed
Merge pull request flynn#991 from flynn/remove-ports
host: Remove unused port allocator
2 parents c12ffc5 + 279aa72 commit d27a5c1

File tree

3 files changed

+3
-78
lines changed

3 files changed

+3
-78
lines changed

host/host.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/flynn/flynn/discoverd/client"
1515
"github.com/flynn/flynn/host/cli"
1616
"github.com/flynn/flynn/host/config"
17-
"github.com/flynn/flynn/host/ports"
1817
"github.com/flynn/flynn/host/sampi"
1918
"github.com/flynn/flynn/host/types"
2019
"github.com/flynn/flynn/host/volume"
@@ -152,11 +151,6 @@ func runDaemon(args *docopt.Args) {
152151
}
153152
}
154153

155-
portAlloc := map[string]*ports.Allocator{
156-
"tcp": ports.NewAllocator(55000, 65535),
157-
"udp": ports.NewAllocator(55000, 65535),
158-
}
159-
160154
state := NewState(hostID, stateFile)
161155
var backend Backend
162156
var err error
@@ -209,7 +203,6 @@ func runDaemon(args *docopt.Args) {
209203
backend: backend,
210204
state: state,
211205
vman: vman,
212-
ports: portAlloc,
213206
}
214207

215208
discURL := os.Getenv("DISCOVERD")

host/manifest.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"text/template"
1212

1313
"github.com/flynn/flynn/Godeps/_workspace/src/github.com/technoweenie/grohl"
14-
"github.com/flynn/flynn/host/ports"
1514
"github.com/flynn/flynn/host/types"
1615
"github.com/flynn/flynn/host/volume/manager"
1716
"github.com/flynn/flynn/pkg/cluster"
@@ -43,7 +42,6 @@ type ManifestData struct {
4342
Env map[string]string
4443
Services map[string]*ManifestData
4544

46-
ports *ports.Allocator
4745
readonly bool
4846
}
4947

@@ -57,12 +55,9 @@ func (m *ManifestData) TCPPort(id int) (int, error) {
5755
return 0, fmt.Errorf("host: invalid TCPPort(%d), expecting id <= %d", id, len(m.TCPPorts))
5856
}
5957

60-
port, err := m.ports.Get()
61-
if err != nil {
62-
return 0, err
63-
}
64-
m.TCPPorts = append(m.TCPPorts, int(port))
65-
return int(port), nil
58+
port := 5000 + len(m.TCPPorts)
59+
m.TCPPorts = append(m.TCPPorts, port)
60+
return port, nil
6661
}
6762

6863
func (m *ManifestData) Volume(volName string, mntPath string) string {
@@ -80,7 +75,6 @@ type manifestRunner struct {
8075
backend Backend
8176
state *State
8277
vman *volumemanager.Manager
83-
ports map[string]*ports.Allocator
8478
}
8579

8680
type manifestService struct {
@@ -124,7 +118,6 @@ func (m *manifestRunner) runManifest(r io.Reader) (map[string]*ManifestData, err
124118
InternalIP: job.InternalIP,
125119
Env: job.Job.Config.Env,
126120
Services: serviceData,
127-
ports: m.ports["tcp"],
128121
readonly: true,
129122
}
130123
data.TCPPorts = make([]int, 0, len(job.Job.Config.Ports))
@@ -150,7 +143,6 @@ func (m *manifestRunner) runManifest(r io.Reader) (map[string]*ManifestData, err
150143
ExternalIP: m.externalAddr,
151144
BridgeIP: netInfo.BridgeAddr,
152145
Nameservers: strings.Join(netInfo.Nameservers, ","),
153-
ports: m.ports["tcp"],
154146
}
155147

156148
// Add explicit tcp ports to data.TCPPorts

host/ports/allocator.go

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)