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