Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MESOS: derive driver's published address from LIBPROCESS_IP, if present #21612

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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