@@ -185,7 +185,18 @@ func (n *NGINXController) syncIngress(interface{}) error {
185185 n .metricCollector .SetSSLExpireTime (servers )
186186 n .metricCollector .SetSSLInfo (servers )
187187
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+
188195 if n .runningConfig .Equal (pcfg ) {
196+ if ! n .lastConfigSuccess {
197+ n .metricCollector .ConfigSuccess (hash , true )
198+ n .lastConfigSuccess = true
199+ }
189200 klog .V (3 ).Infof ("No configuration change detected, skipping backend reload" )
190201 return nil
191202 }
@@ -195,19 +206,13 @@ func (n *NGINXController) syncIngress(interface{}) error {
195206 if ! utilingress .IsDynamicConfigurationEnough (pcfg , n .runningConfig ) {
196207 klog .InfoS ("Configuration changes detected, backend reload required" )
197208
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-
205209 pcfg .ConfigurationChecksum = fmt .Sprintf ("%v" , hash )
206210
207211 err = n .OnUpdate (* pcfg )
208212 if err != nil {
209213 n .metricCollector .IncReloadErrorCount ()
210214 n .metricCollector .ConfigSuccess (hash , false )
215+ n .lastConfigSuccess = false
211216 klog .Errorf ("Unexpected failure reloading the backend:\n %v" , err )
212217 n .recorder .Eventf (k8s .IngressPodDetails , apiv1 .EventTypeWarning , "RELOAD" , fmt .Sprintf ("Error reloading NGINX: %v" , err ))
213218 return err
@@ -216,6 +221,7 @@ func (n *NGINXController) syncIngress(interface{}) error {
216221 klog .InfoS ("Backend successfully reloaded" )
217222 n .metricCollector .ConfigSuccess (hash , true )
218223 n .metricCollector .IncReloadCount ()
224+ n .lastConfigSuccess = true
219225
220226 n .recorder .Eventf (k8s .IngressPodDetails , apiv1 .EventTypeNormal , "RELOAD" , "NGINX reload triggered due to a change in configuration" )
221227 }
@@ -236,7 +242,7 @@ func (n *NGINXController) syncIngress(interface{}) error {
236242 }
237243
238244 retriesRemaining := retry .Steps
239- err : = wait .ExponentialBackoff (retry , func () (bool , error ) {
245+ err = wait .ExponentialBackoff (retry , func () (bool , error ) {
240246 err := n .configureDynamically (pcfg )
241247 if err == nil {
242248 klog .V (2 ).Infof ("Dynamic reconfiguration succeeded." )
0 commit comments