Merge pull request #21612 from mesosphere/jdef_scheduler_uses_libprocess_ip

Auto commit by PR queue bot
pull/6/head
k8s-merge-robot 2016-02-20 09:24:34 -08:00
commit 423215fdc6
2 changed files with 17 additions and 3 deletions

View File

@ -32,7 +32,7 @@ const (
SCHEDULER_SERVICE_NAME = "k8sm-scheduler" 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() { return func() {
for { for {
// Update service & endpoint records. // Update service & endpoint records.
@ -42,7 +42,10 @@ func (m *SchedulerServer) newServiceWriter(stop <-chan struct{}) func() {
glog.Errorf("Can't create scheduler service: %v", err) 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) glog.Errorf("Can't create scheduler endpoints: %v", err)
} }

View File

@ -771,6 +771,16 @@ func (s *SchedulerServer) bootstrap(hks hyperkube.Interface, sc *schedcfg.Config
} }
schedulerProcess := ha.New(framework) 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{ dconfig := &bindings.DriverConfig{
Scheduler: schedulerProcess, Scheduler: schedulerProcess,
Framework: info, Framework: info,
@ -778,6 +788,7 @@ func (s *SchedulerServer) bootstrap(hks hyperkube.Interface, sc *schedcfg.Config
Credential: cred, Credential: cred,
BindingAddress: s.address, BindingAddress: s.address,
BindingPort: uint16(s.driverPort), BindingPort: uint16(s.driverPort),
PublishedAddress: publishedAddress,
HostnameOverride: s.hostnameOverride, HostnameOverride: s.hostnameOverride,
WithAuthContext: func(ctx context.Context) context.Context { WithAuthContext: func(ctx context.Context) context.Context {
ctx = auth.WithLoginProvider(ctx, s.mesosAuthProvider) ctx = auth.WithLoginProvider(ctx, s.mesosAuthProvider)
@ -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(), 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()) }) runtime.On(framework.Registration(), func() { nodeCtl.Run(schedulerProcess.Terminal()) })
driverFactory := ha.DriverFactory(func() (drv bindings.SchedulerDriver, err error) { driverFactory := ha.DriverFactory(func() (drv bindings.SchedulerDriver, err error) {