Skip to content

Commit

Permalink
Merge pull request #754 from freehan/flag-gate
Browse files Browse the repository at this point in the history
flag gate readiness reflector
  • Loading branch information
k8s-ci-robot committed Jun 14, 2019
2 parents e50d26d + c414b52 commit 37e1f91
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cmd/glbc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ func runControllers(ctx *ingctx.ControllerContext) {
fwc := firewalls.NewFirewallController(ctx, flags.F.NodePortRanges.Values())

// TODO: Refactor NEG to use cloud mocks so ctx.Cloud can be referenced within NewController.
negController := neg.NewController(negtypes.NewAdapter(ctx.Cloud), ctx, lbc.Translator, ctx.ClusterNamer, flags.F.ResyncPeriod, flags.F.NegGCPeriod, neg.NegSyncerType(flags.F.NegSyncerType))
negController := neg.NewController(negtypes.NewAdapter(ctx.Cloud), ctx, lbc.Translator, ctx.ClusterNamer, flags.F.ResyncPeriod, flags.F.NegGCPeriod, neg.NegSyncerType(flags.F.NegSyncerType), flags.F.EnableReadinessReflector)

go negController.Run(stopCh)
klog.V(0).Infof("negController started")

Expand Down
2 changes: 2 additions & 0 deletions pkg/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ var (
NodePortRanges PortRanges
NegGCPeriod time.Duration
NegSyncerType string
EnableReadinessReflector bool
FinalizerAdd bool
FinalizerRemove bool

Expand Down Expand Up @@ -191,6 +192,7 @@ L7 load balancing. CSV values accepted. Example: -node-port-ranges=80,8080,400-5
flag.DurationVar(&F.NegGCPeriod, "neg-gc-period", 120*time.Second,
`Relist and garbage collect NEGs this often.`)
flag.StringVar(&F.NegSyncerType, "neg-syncer-type", "transaction", "Define the NEG syncer type to use. Valid values are \"batch\" and \"transaction\"")
flag.BoolVar(&F.EnableReadinessReflector, "enable-readiness-reflector", true, "Enable NEG Readiness Reflector")
flag.BoolVar(&F.FinalizerAdd, "enable-finalizer-add",
F.FinalizerAdd, "Enable adding Finalizer to Ingress.")
flag.BoolVar(&F.FinalizerRemove, "enable-finalizer-remove",
Expand Down
11 changes: 9 additions & 2 deletions pkg/neg/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ func NewController(
namer negtypes.NetworkEndpointGroupNamer,
resyncPeriod time.Duration,
gcPeriod time.Duration,
negSyncerType NegSyncerType) *Controller {
negSyncerType NegSyncerType,
enableReadinessReflector bool,
) *Controller {
// init event recorder
// TODO: move event recorder initializer to main. Reuse it among controllers.
eventBroadcaster := record.NewBroadcaster()
Expand All @@ -93,7 +95,12 @@ func NewController(
apiv1.EventSource{Component: "neg-controller"})

manager := newSyncerManager(namer, recorder, cloud, zoneGetter, ctx.PodInformer.GetIndexer(), ctx.ServiceInformer.GetIndexer(), ctx.EndpointInformer.GetIndexer(), negSyncerType)
reflector := readiness.NewReadinessReflector(ctx, manager)
var reflector readiness.Reflector
if enableReadinessReflector {
reflector = readiness.NewReadinessReflector(ctx, manager)
} else {
reflector = &readiness.NoopReflector{}
}
manager.reflector = reflector

negController := &Controller{
Expand Down
2 changes: 2 additions & 0 deletions pkg/neg/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ func newTestController(kubeClient kubernetes.Interface) *Controller {
1*time.Second,
1*time.Second,
transactionSyncer,
// TODO(freehan): enable readiness reflector for unit tests
false,
)
return controller
}
Expand Down

0 comments on commit 37e1f91

Please sign in to comment.