Skip to content

Commit

Permalink
derive drivers published address from LIBPROCESS_IP, if present
Browse files Browse the repository at this point in the history
  • Loading branch information
James DeFelice committed Feb 20, 2016
1 parent ca35f96 commit d367eff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
7 changes: 5 additions & 2 deletions contrib/mesos/pkg/scheduler/service/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const (
SCHEDULER_SERVICE_NAME = "k8sm-scheduler"
)

func (m *SchedulerServer) newServiceWriter(stop <-chan struct{}) func() {
func (m *SchedulerServer) newServiceWriter(publishedAddress net.IP, stop <-chan struct{}) func() {
return func() {
for {
// Update service & endpoint records.
Expand All @@ -42,7 +42,10 @@ func (m *SchedulerServer) newServiceWriter(stop <-chan struct{}) func() {
glog.Errorf("Can't create scheduler service: %v", err)
}

if err := m.setEndpoints(SCHEDULER_SERVICE_NAME, net.IP(m.address), m.port); err != nil {
if publishedAddress == nil {
publishedAddress = net.IP(m.address)
}
if err := m.setEndpoints(SCHEDULER_SERVICE_NAME, publishedAddress, m.port); err != nil {
glog.Errorf("Can't create scheduler endpoints: %v", err)
}

Expand Down
13 changes: 12 additions & 1 deletion contrib/mesos/pkg/scheduler/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -771,13 +771,24 @@ func (s *SchedulerServer) bootstrap(hks hyperkube.Interface, sc *schedcfg.Config
}

schedulerProcess := ha.New(framework)

// try publishing on the same IP as the slave
var publishedAddress net.IP
if libprocessIP := os.Getenv("LIBPROCESS_IP"); libprocessIP != "" {
publishedAddress = net.ParseIP(libprocessIP)
}
if publishedAddress != nil {
log.V(1).Infof("driver will publish address %v", publishedAddress)
}

dconfig := &bindings.DriverConfig{
Scheduler: schedulerProcess,
Framework: info,
Master: masterUri,
Credential: cred,
BindingAddress: s.address,
BindingPort: uint16(s.driverPort),
PublishedAddress: publishedAddress,
HostnameOverride: s.hostnameOverride,
WithAuthContext: func(ctx context.Context) context.Context {
ctx = auth.WithLoginProvider(ctx, s.mesosAuthProvider)
Expand Down Expand Up @@ -826,7 +837,7 @@ func (s *SchedulerServer) bootstrap(hks hyperkube.Interface, sc *schedcfg.Config
)

runtime.On(framework.Registration(), func() { sched.Run(schedulerProcess.Terminal()) })
runtime.On(framework.Registration(), s.newServiceWriter(schedulerProcess.Terminal()))
runtime.On(framework.Registration(), s.newServiceWriter(publishedAddress, schedulerProcess.Terminal()))
runtime.On(framework.Registration(), func() { nodeCtl.Run(schedulerProcess.Terminal()) })

driverFactory := ha.DriverFactory(func() (drv bindings.SchedulerDriver, err error) {
Expand Down

0 comments on commit d367eff

Please sign in to comment.