Skip to content

Commit 2cdf44d

Browse files
committed
Rebase hybrid proxy onto event-driven proxy code
This commit moves the hybrid proxier onto the event-driven model adopted upstream by the iptables and userspace proxiers.
1 parent 7a48deb commit 2cdf44d

File tree

3 files changed

+688
-596
lines changed

3 files changed

+688
-596
lines changed

pkg/cmd/server/kubernetes/node/node.go

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
dockerclient "github.com/fsouza/go-dockerclient"
1414
"github.com/golang/glog"
1515

16-
// "github.com/openshift/origin/pkg/proxy/hybrid"
17-
// "github.com/openshift/origin/pkg/proxy/unidler"
16+
"github.com/openshift/origin/pkg/proxy/hybrid"
17+
"github.com/openshift/origin/pkg/proxy/unidler"
1818
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1919
utilnet "k8s.io/apimachinery/pkg/util/net"
2020
utilwait "k8s.io/apimachinery/pkg/util/wait"
@@ -430,37 +430,38 @@ func (c *NodeConfig) RunProxy() {
430430
c.ProxyConfig.ConfigSyncPeriod.Duration,
431431
)
432432

433-
// if c.EnableUnidling {
434-
// unidlingLoadBalancer := userspace.NewLoadBalancerRR()
435-
// signaler := unidler.NewEventSignaler(recorder)
436-
// unidlingUserspaceProxy, err := unidler.NewUnidlerProxier(unidlingLoadBalancer, bindAddr, iptInterface, execer, *portRange, c.ProxyConfig.IPTablesSyncPeriod.Duration, c.ProxyConfig.IPTablesMinSyncPeriod.Duration, c.ProxyConfig.UDPIdleTimeout.Duration, signaler)
437-
// if err != nil {
438-
// if c.Containerized {
439-
// glog.Fatalf("error: Could not initialize Kubernetes Proxy: %v\n When running in a container, you must run the container in the host network namespace with --net=host and with --privileged", err)
440-
// } else {
441-
// glog.Fatalf("error: Could not initialize Kubernetes Proxy. You must run this process as root to use the service proxy: %v", err)
442-
// }
443-
// }
444-
// hybridProxier, err := hybrid.NewHybridProxier(
445-
// unidlingLoadBalancer,
446-
// unidlingUserspaceProxy,
447-
// endpointsHandler,
448-
// proxier,
449-
// servicesHandler,
450-
// c.ProxyConfig.IPTablesSyncPeriod.Duration,
451-
// c.InternalKubeInformers.Core().InternalVersion().Services().Lister(),
452-
// )
453-
// if err != nil {
454-
// if c.Containerized {
455-
// glog.Fatalf("error: Could not initialize Kubernetes Proxy: %v\n When running in a container, you must run the container in the host network namespace with --net=host and with --privileged", err)
456-
// } else {
457-
// glog.Fatalf("error: Could not initialize Kubernetes Proxy. You must run this process as root to use the service proxy: %v", err)
458-
// }
459-
// }
460-
// endpointsHandler = hybridProxier
461-
// servicesHandler = hybridProxier
462-
// proxier = hybridProxier
463-
// }
433+
if c.EnableUnidling {
434+
unidlingLoadBalancer := userspace.NewLoadBalancerRR()
435+
signaler := unidler.NewEventSignaler(recorder)
436+
unidlingUserspaceProxy, err := unidler.NewUnidlerProxier(unidlingLoadBalancer, bindAddr, iptInterface, execer, *portRange, c.ProxyConfig.IPTables.SyncPeriod.Duration, c.ProxyConfig.IPTables.MinSyncPeriod.Duration, c.ProxyConfig.UDPIdleTimeout.Duration, signaler)
437+
if err != nil {
438+
if c.Containerized {
439+
glog.Fatalf("error: Could not initialize Kubernetes Proxy: %v\n When running in a container, you must run the container in the host network namespace with --net=host and with --privileged", err)
440+
} else {
441+
glog.Fatalf("error: Could not initialize Kubernetes Proxy. You must run this process as root to use the service proxy: %v", err)
442+
}
443+
}
444+
hybridProxier, err := hybrid.NewHybridProxier(
445+
unidlingLoadBalancer,
446+
unidlingUserspaceProxy,
447+
endpointsHandler,
448+
servicesHandler,
449+
proxier,
450+
unidlingUserspaceProxy,
451+
c.ProxyConfig.IPTables.SyncPeriod.Duration,
452+
c.InternalKubeInformers.Core().InternalVersion().Services().Lister(),
453+
)
454+
if err != nil {
455+
if c.Containerized {
456+
glog.Fatalf("error: Could not initialize Kubernetes Proxy: %v\n When running in a container, you must run the container in the host network namespace with --net=host and with --privileged", err)
457+
} else {
458+
glog.Fatalf("error: Could not initialize Kubernetes Proxy. You must run this process as root to use the service proxy: %v", err)
459+
}
460+
}
461+
endpointsHandler = hybridProxier
462+
servicesHandler = hybridProxier
463+
proxier = hybridProxier
464+
}
464465

465466
iptInterface.AddReloadFunc(proxier.Sync)
466467
serviceConfig.RegisterEventHandler(servicesHandler)

0 commit comments

Comments
 (0)