@@ -185,7 +185,18 @@ func (n *NGINXController) syncIngress(interface{}) error {
185
185
n .metricCollector .SetSSLExpireTime (servers )
186
186
n .metricCollector .SetSSLInfo (servers )
187
187
188
+ hash , err := hashstructure .Hash (pcfg , hashstructure .FormatV1 , & hashstructure.HashOptions {
189
+ TagName : "json" ,
190
+ })
191
+ if err != nil {
192
+ klog .Errorf ("unexpected error hashing configuration: %v" , err )
193
+ }
194
+
188
195
if n .runningConfig .Equal (pcfg ) {
196
+ if ! n .lastConfigSuccess {
197
+ n .metricCollector .ConfigSuccess (hash , true )
198
+ n .lastConfigSuccess = true
199
+ }
189
200
klog .V (3 ).Infof ("No configuration change detected, skipping backend reload" )
190
201
return nil
191
202
}
@@ -195,19 +206,13 @@ func (n *NGINXController) syncIngress(interface{}) error {
195
206
if ! utilingress .IsDynamicConfigurationEnough (pcfg , n .runningConfig ) {
196
207
klog .InfoS ("Configuration changes detected, backend reload required" )
197
208
198
- hash , err := hashstructure .Hash (pcfg , hashstructure .FormatV1 , & hashstructure.HashOptions {
199
- TagName : "json" ,
200
- })
201
- if err != nil {
202
- klog .Errorf ("unexpected error hashing configuration: %v" , err )
203
- }
204
-
205
209
pcfg .ConfigurationChecksum = fmt .Sprintf ("%v" , hash )
206
210
207
211
err = n .OnUpdate (* pcfg )
208
212
if err != nil {
209
213
n .metricCollector .IncReloadErrorCount ()
210
214
n .metricCollector .ConfigSuccess (hash , false )
215
+ n .lastConfigSuccess = false
211
216
klog .Errorf ("Unexpected failure reloading the backend:\n %v" , err )
212
217
n .recorder .Eventf (k8s .IngressPodDetails , apiv1 .EventTypeWarning , "RELOAD" , fmt .Sprintf ("Error reloading NGINX: %v" , err ))
213
218
return err
@@ -216,6 +221,7 @@ func (n *NGINXController) syncIngress(interface{}) error {
216
221
klog .InfoS ("Backend successfully reloaded" )
217
222
n .metricCollector .ConfigSuccess (hash , true )
218
223
n .metricCollector .IncReloadCount ()
224
+ n .lastConfigSuccess = true
219
225
220
226
n .recorder .Eventf (k8s .IngressPodDetails , apiv1 .EventTypeNormal , "RELOAD" , "NGINX reload triggered due to a change in configuration" )
221
227
}
@@ -236,7 +242,7 @@ func (n *NGINXController) syncIngress(interface{}) error {
236
242
}
237
243
238
244
retriesRemaining := retry .Steps
239
- err : = wait .ExponentialBackoff (retry , func () (bool , error ) {
245
+ err = wait .ExponentialBackoff (retry , func () (bool , error ) {
240
246
err := n .configureDynamically (pcfg )
241
247
if err == nil {
242
248
klog .V (2 ).Infof ("Dynamic reconfiguration succeeded." )
0 commit comments