@@ -192,7 +192,18 @@ func (n *NGINXController) syncIngress(interface{}) error {
192192 n .metricCollector .SetSSLExpireTime (servers )
193193 n .metricCollector .SetSSLInfo (servers )
194194
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+
195202 if n .runningConfig .Equal (pcfg ) {
203+ if ! n .lastConfigSuccess {
204+ n .metricCollector .ConfigSuccess (hash , true )
205+ n .lastConfigSuccess = true
206+ }
196207 klog .V (3 ).Infof ("No configuration change detected, skipping backend reload" )
197208 return nil
198209 }
@@ -202,19 +213,13 @@ func (n *NGINXController) syncIngress(interface{}) error {
202213 if ! utilingress .IsDynamicConfigurationEnough (pcfg , n .runningConfig ) {
203214 klog .InfoS ("Configuration changes detected, backend reload required" )
204215
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-
212216 pcfg .ConfigurationChecksum = fmt .Sprintf ("%v" , hash )
213217
214218 err = n .OnUpdate (* pcfg )
215219 if err != nil {
216220 n .metricCollector .IncReloadErrorCount ()
217221 n .metricCollector .ConfigSuccess (hash , false )
222+ n .lastConfigSuccess = false
218223 klog .Errorf ("Unexpected failure reloading the backend:\n %v" , err )
219224 n .recorder .Eventf (k8s .IngressPodDetails , apiv1 .EventTypeWarning , "RELOAD" , fmt .Sprintf ("Error reloading NGINX: %v" , err ))
220225 return err
@@ -223,6 +228,7 @@ func (n *NGINXController) syncIngress(interface{}) error {
223228 klog .InfoS ("Backend successfully reloaded" )
224229 n .metricCollector .ConfigSuccess (hash , true )
225230 n .metricCollector .IncReloadCount ()
231+ n .lastConfigSuccess = true
226232
227233 n .recorder .Eventf (k8s .IngressPodDetails , apiv1 .EventTypeNormal , "RELOAD" , "NGINX reload triggered due to a change in configuration" )
228234 }
@@ -243,7 +249,7 @@ func (n *NGINXController) syncIngress(interface{}) error {
243249 }
244250
245251 retriesRemaining := retry .Steps
246- err : = wait .ExponentialBackoff (retry , func () (bool , error ) {
252+ err = wait .ExponentialBackoff (retry , func () (bool , error ) {
247253 err := n .configureDynamically (pcfg )
248254 if err == nil {
249255 klog .V (2 ).Infof ("Dynamic reconfiguration succeeded." )
0 commit comments