Skip to content

Commit b3a13ad

Browse files
ivanmatmatioktalz
authored andcommitted
MINOR: update status if ingressclass is accepted after an ingress modification
1 parent dd1711a commit b3a13ad

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ func main() {
113113
WithHaproxyCfgFile(haproxyConf).
114114
WithEventChan(eventChan).
115115
WithStore(s).
116-
WithPublishService(publishService).
117116
WithUpdatePublishServiceFunc(k.UpdatePublishService).
118117
WithClientSet(k.GetClientset()).
119118
WithRestClientSet(k.GetRestClientset()).

pkg/controller/builder.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ type Builder struct {
4747
haproxyProcess process.Process
4848
haproxyRules rules.Rules
4949
restClientSet client.Client
50-
publishService *utils.NamespaceValue
5150
updatePublishServiceFunc func(ingresses []*ingress.Ingress, publishServiceAddresses []string)
5251
eventChan chan k8s.SyncDataEvent
5352
clientSet *kubernetes.Clientset
@@ -124,11 +123,6 @@ func (builder *Builder) WithArgs(osArgs utils.OSArgs) *Builder {
124123
return builder
125124
}
126125

127-
func (builder *Builder) WithPublishService(publishService *utils.NamespaceValue) *Builder {
128-
builder.publishService = publishService
129-
return builder
130-
}
131-
132126
func (builder *Builder) WithUpdatePublishServiceFunc(updatePublishServiceFunc func(ingresses []*ingress.Ingress, publishServiceAddresses []string)) *Builder {
133127
builder.updatePublishServiceFunc = updatePublishServiceFunc
134128
return builder
@@ -183,7 +177,6 @@ func (builder *Builder) Build() *HAProxyController {
183177
podPrefix: prefix,
184178
store: builder.store,
185179
eventChan: builder.eventChan,
186-
publishService: builder.publishService,
187180
annotations: builder.annotations,
188181
chShutdown: chShutdown,
189182
updatePublishServiceFunc: builder.updatePublishServiceFunc,

pkg/controller/controller.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ var logger = utils.GetLogger()
3737
type HAProxyController struct {
3838
gatewayManager gateway.GatewayManager
3939
annotations annotations.Annotations
40-
publishService *utils.NamespaceValue
4140
eventChan chan k8s.SyncDataEvent
4241
updatePublishServiceFunc func(ingresses []*ingress.Ingress, publishServiceAddresses []string)
4342
chShutdown chan struct{}
@@ -124,7 +123,7 @@ func (c *HAProxyController) updateHAProxy() {
124123
logger.Debugf("ingress '%s/%s' ignored: no matching IngressClass", ingResource.Namespace, ingResource.Name)
125124
continue
126125
}
127-
if ingResource.Status == store.ADDED {
126+
if ingResource.Status == store.ADDED || ingResource.ClassUpdated {
128127
ingresses = append(ingresses, i)
129128
}
130129
c.reload = i.Update(c.store, c.haproxy, c.annotations) || c.reload

pkg/store/events.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ func (k *K8s) EventIngress(ns *Namespace, data *Ingress) (updateRequired bool) {
6262
updateRequired = false
6363
data.Status = EMPTY
6464
}
65+
for _, update := range updated {
66+
if strings.HasPrefix(update, "Class:") {
67+
data.ClassUpdated = true
68+
break
69+
}
70+
}
71+
if data.Annotations["ingress.class"] != oldIngress.Annotations["ingress.class"] {
72+
data.ClassUpdated = true
73+
}
6574
}
6675
ns.Ingresses[data.Name] = data
6776
}

pkg/store/types.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,10 @@ type IngressRule struct {
134134
// Ingress is useful data from k8s structures about ingress
135135
type Ingress struct {
136136
IngressCore
137-
Status Status // Used for store purpose
138-
Addresses []string
139-
Ignored bool // true if resource ignored because of non matching Controller Class
137+
Status Status // Used for store purpose
138+
Addresses []string
139+
Ignored bool // true if resource ignored because of non matching Controller Class
140+
ClassUpdated bool
140141
}
141142

142143
// IngressTLS describes the transport layer security associated with an Ingress.

0 commit comments

Comments
 (0)