Skip to content

Commit cd5d159

Browse files
committed
MINOR: removal of unused ingresschan
1 parent ccff59b commit cd5d159

File tree

5 files changed

+11
-25
lines changed

5 files changed

+11
-25
lines changed

main.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333

3434
"github.com/haproxytech/kubernetes-ingress/pkg/annotations"
3535
"github.com/haproxytech/kubernetes-ingress/pkg/controller"
36-
"github.com/haproxytech/kubernetes-ingress/pkg/ingress"
3736
"github.com/haproxytech/kubernetes-ingress/pkg/k8s"
3837
"github.com/haproxytech/kubernetes-ingress/pkg/store"
3938
"github.com/haproxytech/kubernetes-ingress/pkg/utils"
@@ -93,7 +92,6 @@ func main() {
9392
chanSize = osArgs.ChannelSize
9493
}
9594
eventChan := make(chan k8s.SyncDataEvent, chanSize)
96-
ingressChan := make(chan ingress.Sync, chanSize)
9795
stop := make(chan struct{})
9896

9997
publishService := getNamespaceValue(osArgs.PublishService)
@@ -108,14 +106,13 @@ func main() {
108106
c := controller.NewBuilder().
109107
WithHaproxyCfgFile(haproxyConf).
110108
WithEventChan(eventChan).
111-
WithIngressChan(ingressChan).
112109
WithStore(s).
113110
WithPublishService(publishService).
114111
WithUpdatePublishServiceFunc(k.UpdatePublishService).
115112
WithClientSet(k.GetClientset()).
116113
WithArgs(osArgs).Build()
117114

118-
go k.MonitorChanges(eventChan, ingressChan, stop)
115+
go k.MonitorChanges(eventChan, stop)
119116
go c.Start()
120117

121118
// Catch QUIT signals

pkg/controller/builder.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ type Builder struct {
4949
store store.K8s
5050
publishService *utils.NamespaceValue
5151
eventChan chan k8s.SyncDataEvent
52-
ingressChan chan ingress.Sync
5352
updatePublishServiceFunc func(ingresses []*ingress.Ingress, publishServiceAddresses []string)
5453
clientSet *kubernetes.Clientset
5554
}
@@ -101,11 +100,6 @@ func (builder *Builder) WithEventChan(eventChan chan k8s.SyncDataEvent) *Builder
101100
return builder
102101
}
103102

104-
func (builder *Builder) WithIngressChan(ingressChan chan ingress.Sync) *Builder {
105-
builder.ingressChan = ingressChan
106-
return builder
107-
}
108-
109103
func (builder *Builder) WithStore(store store.K8s) *Builder {
110104
builder.store = store
111105
return builder
@@ -170,7 +164,6 @@ func (builder *Builder) Build() *HAProxyController {
170164
podPrefix: prefix,
171165
store: builder.store,
172166
eventChan: builder.eventChan,
173-
ingressChan: builder.ingressChan,
174167
publishService: builder.publishService,
175168
annotations: builder.annotations,
176169
chShutdown: chShutdown,

pkg/controller/controller.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ type HAProxyController struct {
4141
publishService *utils.NamespaceValue
4242
auxCfgModTime int64
4343
eventChan chan k8s.SyncDataEvent
44-
ingressChan chan ingress.Sync
4544
ready bool
4645
reload bool
4746
restart bool

pkg/k8s/informers.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515

1616
"github.com/haproxytech/client-native/v3/models"
1717

18-
"github.com/haproxytech/kubernetes-ingress/pkg/ingress"
1918
"github.com/haproxytech/kubernetes-ingress/pkg/store"
2019
"github.com/haproxytech/kubernetes-ingress/pkg/utils"
2120
)
@@ -109,7 +108,7 @@ func (k k8s) getNamespaceInfomer(eventChan chan SyncDataEvent, factory informers
109108
return informer
110109
}
111110

112-
func (k k8s) getServiceInformer(eventChan chan SyncDataEvent, ingressChan chan ingress.Sync, factory informers.SharedInformerFactory, publishSvc *utils.NamespaceValue) cache.SharedIndexInformer { //nolint:ireturn
111+
func (k k8s) getServiceInformer(eventChan chan SyncDataEvent, factory informers.SharedInformerFactory) cache.SharedIndexInformer { //nolint:ireturn
113112
informer := factory.Core().V1().Services().Informer()
114113
informer.AddEventHandler(cache.ResourceEventHandlerFuncs{
115114
AddFunc: func(obj interface{}) {
@@ -146,7 +145,7 @@ func (k k8s) getServiceInformer(eventChan chan SyncDataEvent, ingressChan chan i
146145
}
147146
logger.Tracef("%s %s: %s", SERVICE, item.Status, item.Name)
148147
eventChan <- SyncDataEvent{SyncType: SERVICE, Namespace: item.Namespace, Data: item}
149-
if publishSvc != nil && publishSvc.Namespace == item.Namespace && publishSvc.Name == item.Name {
148+
if k.publishSvc != nil && k.publishSvc.Namespace == item.Namespace && k.publishSvc.Name == item.Name {
150149
// item copy because of ADDED handler in events.go which must modify the STATUS based solely on addresses
151150
itemCopy := *item
152151
itemCopy.Addresses = getServiceAddresses(data)
@@ -174,7 +173,7 @@ func (k k8s) getServiceInformer(eventChan chan SyncDataEvent, ingressChan chan i
174173
}
175174
logger.Tracef("%s %s: %s", SERVICE, item.Status, item.Name)
176175
eventChan <- SyncDataEvent{SyncType: SERVICE, Namespace: item.Namespace, Data: item}
177-
if publishSvc != nil && publishSvc.Namespace == item.Namespace && publishSvc.Name == item.Name {
176+
if k.publishSvc != nil && k.publishSvc.Namespace == item.Namespace && k.publishSvc.Name == item.Name {
178177
item.Addresses = getServiceAddresses(data)
179178
eventChan <- SyncDataEvent{SyncType: PUBLISH_SERVICE, Namespace: data.Namespace, Data: item}
180179
}
@@ -198,9 +197,7 @@ func (k k8s) getServiceInformer(eventChan chan SyncDataEvent, ingressChan chan i
198197
logger.Tracef("forwarding to ExternalName Services for %v is disabled", data2)
199198
return
200199
}
201-
if k.publishSvc != nil && k.publishSvc.Namespace == data2.Namespace && k.publishSvc.Name == data2.Name {
202-
ingressChan <- ingress.Sync{Service: data2}
203-
}
200+
204201
status := store.MODIFIED
205202
item1 := &store.Service{
206203
Namespace: data1.GetNamespace(),
@@ -243,7 +240,7 @@ func (k k8s) getServiceInformer(eventChan chan SyncDataEvent, ingressChan chan i
243240
logger.Tracef("%s %s: %s", SERVICE, item2.Status, item2.Name)
244241
eventChan <- SyncDataEvent{SyncType: SERVICE, Namespace: item2.Namespace, Data: item2}
245242

246-
if publishSvc != nil && publishSvc.Namespace == item2.Namespace && publishSvc.Name == item2.Name {
243+
if k.publishSvc != nil && k.publishSvc.Namespace == item2.Namespace && k.publishSvc.Name == item2.Name {
247244
item2.Addresses = getServiceAddresses(data2)
248245
eventChan <- SyncDataEvent{SyncType: PUBLISH_SERVICE, Namespace: item2.Namespace, Data: item2}
249246
}

pkg/k8s/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var ErrIgnored = errors.New("ignored resource")
4646

4747
type K8s interface {
4848
GetClientset() *k8sclientset.Clientset
49-
MonitorChanges(eventChan chan SyncDataEvent, ingressChan chan ingress.Sync, stop chan struct{})
49+
MonitorChanges(eventChan chan SyncDataEvent, stop chan struct{})
5050
UpdatePublishService(ingresses []*ingress.Ingress, publishServiceAddresses []string)
5151
}
5252

@@ -121,12 +121,12 @@ func (k k8s) UpdatePublishService(ingresses []*ingress.Ingress, publishServiceAd
121121
}
122122
}
123123

124-
func (k k8s) MonitorChanges(eventChan chan SyncDataEvent, ingressChan chan ingress.Sync, stop chan struct{}) {
124+
func (k k8s) MonitorChanges(eventChan chan SyncDataEvent, stop chan struct{}) {
125125
informersSynced := &[]cache.InformerSynced{}
126126

127127
k.runPodInformer(eventChan, stop, informersSynced)
128128
for _, namespace := range k.whiteListedNS {
129-
k.runInformers(eventChan, ingressChan, stop, namespace, informersSynced)
129+
k.runInformers(eventChan, stop, namespace, informersSynced)
130130
k.runCRInformers(eventChan, stop, namespace, informersSynced)
131131
}
132132

@@ -167,12 +167,12 @@ func (k k8s) runCRInformers(eventChan chan SyncDataEvent, stop chan struct{}, na
167167
}
168168
}
169169

170-
func (k k8s) runInformers(eventChan chan SyncDataEvent, ingressChan chan ingress.Sync, stop chan struct{}, namespace string, informersSynced *[]cache.InformerSynced) {
170+
func (k k8s) runInformers(eventChan chan SyncDataEvent, stop chan struct{}, namespace string, informersSynced *[]cache.InformerSynced) {
171171
factory := k8sinformers.NewSharedInformerFactoryWithOptions(k.builtInClient, k.cacheResyncPeriod, k8sinformers.WithNamespace(namespace))
172172
// Core.V1 Resources
173173
nsi := k.getNamespaceInfomer(eventChan, factory)
174174
go nsi.Run(stop)
175-
svci := k.getServiceInformer(eventChan, ingressChan, factory, k.publishSvc)
175+
svci := k.getServiceInformer(eventChan, factory)
176176
go svci.Run(stop)
177177
seci := k.getSecretInformer(eventChan, factory)
178178
go seci.Run(stop)

0 commit comments

Comments
 (0)