Skip to content

Commit 1d80d8f

Browse files
ivanmatmatioktalz
authored andcommitted
MINOR: removal of unused ingresschan
1 parent dd6c493 commit 1d80d8f

File tree

5 files changed

+11
-25
lines changed

5 files changed

+11
-25
lines changed

main.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232

3333
"github.com/haproxytech/kubernetes-ingress/pkg/annotations"
3434
"github.com/haproxytech/kubernetes-ingress/pkg/controller"
35-
"github.com/haproxytech/kubernetes-ingress/pkg/ingress"
3635
"github.com/haproxytech/kubernetes-ingress/pkg/k8s"
3736
"github.com/haproxytech/kubernetes-ingress/pkg/store"
3837
"github.com/haproxytech/kubernetes-ingress/pkg/utils"
@@ -92,7 +91,6 @@ func main() {
9291
chanSize = osArgs.ChannelSize
9392
}
9493
eventChan := make(chan k8s.SyncDataEvent, chanSize)
95-
ingressChan := make(chan ingress.Sync, chanSize)
9694
stop := make(chan struct{})
9795

9896
publishService := getNamespaceValue(osArgs.PublishService)
@@ -107,14 +105,13 @@ func main() {
107105
c := controller.NewBuilder().
108106
WithHaproxyCfgFile(haproxyConf).
109107
WithEventChan(eventChan).
110-
WithIngressChan(ingressChan).
111108
WithStore(s).
112109
WithPublishService(publishService).
113110
WithUpdatePublishServiceFunc(k.UpdatePublishService).
114111
WithClientSet(k.GetClientset()).
115112
WithArgs(osArgs).Build()
116113

117-
go k.MonitorChanges(eventChan, ingressChan, stop)
114+
go k.MonitorChanges(eventChan, stop)
118115
go c.Start()
119116

120117
// Catch QUIT signals

pkg/controller/builder.go

-7
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ type Builder struct {
3535
store store.K8s
3636
publishService *utils.NamespaceValue
3737
eventChan chan k8s.SyncDataEvent
38-
ingressChan chan ingress.Sync
3938
updatePublishServiceFunc func(ingresses []*ingress.Ingress, publishServiceAddresses []string)
4039
clientSet *kubernetes.Clientset
4140
}
@@ -87,11 +86,6 @@ func (builder *Builder) WithEventChan(eventChan chan k8s.SyncDataEvent) *Builder
8786
return builder
8887
}
8988

90-
func (builder *Builder) WithIngressChan(ingressChan chan ingress.Sync) *Builder {
91-
builder.ingressChan = ingressChan
92-
return builder
93-
}
94-
9589
func (builder *Builder) WithStore(store store.K8s) *Builder {
9690
builder.store = store
9791
return builder
@@ -156,7 +150,6 @@ func (builder *Builder) Build() *HAProxyController {
156150
podPrefix: prefix,
157151
store: builder.store,
158152
eventChan: builder.eventChan,
159-
ingressChan: builder.ingressChan,
160153
publishService: builder.publishService,
161154
annotations: builder.annotations,
162155
chShutdown: chShutdown,

pkg/controller/controller.go

-1
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

+5-8
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 {
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

+5-5
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

@@ -116,12 +116,12 @@ func (k k8s) UpdatePublishService(ingresses []*ingress.Ingress, publishServiceAd
116116
}
117117
}
118118

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

122122
k.runPodInformer(eventChan, stop, informersSynced)
123123
for _, namespace := range k.whiteListedNS {
124-
k.runInformers(eventChan, ingressChan, stop, namespace, informersSynced)
124+
k.runInformers(eventChan, stop, namespace, informersSynced)
125125
k.runCRInformers(eventChan, stop, namespace, informersSynced)
126126
}
127127

@@ -162,12 +162,12 @@ func (k k8s) runCRInformers(eventChan chan SyncDataEvent, stop chan struct{}, na
162162
}
163163
}
164164

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

0 commit comments

Comments
 (0)