@@ -577,21 +577,30 @@ func (c *KongClient) sendToClient(
577
577
c .updateStrategyResolver ,
578
578
c .configChangeDetector ,
579
579
)
580
-
581
- c .recordResourceFailureEvents (err .ResourceFailures , KongConfigurationApplyFailedEventReason )
582
580
// Only record events on applying configuration to Kong gateway here.
581
+ // Nil error is expected to be passed to indicate success.
583
582
if ! client .IsKonnect () {
584
583
c .recordApplyConfigurationEvents (err , client .BaseRootURL ())
585
584
}
586
- sendDiagnostic (err .Err != nil , err .RawBody )
585
+ if err != nil {
586
+ var updateErr sendconfig.UpdateError
587
+ if errors .As (err , & updateErr ) {
588
+ c .recordResourceFailureEvents (updateErr .ResourceFailures , KongConfigurationApplyFailedEventReason )
587
589
588
- if err .Err != nil {
589
- if expired , ok := timedCtx .Deadline (); ok && time .Now ().After (expired ) {
590
- logger .Error (nil , "Exceeded Kong API timeout, consider increasing --proxy-timeout-seconds" )
590
+ sendDiagnostic (updateErr .Err != nil , updateErr .RawBody )
591
+
592
+ if updateErr .Err != nil {
593
+ if err := ctx .Err (); err != nil {
594
+ logger .Error (err , "Exceeded Kong API timeout, consider increasing --proxy-timeout-seconds" )
595
+ }
596
+ return "" , fmt .Errorf ("performing update for %s failed: %w" , client .BaseRootURL (), updateErr )
597
+ }
598
+ } else {
599
+ // It should never happen.
600
+ return "" , fmt .Errorf ("performing update for %s failed with unexpected type of error: %w" , client .BaseRootURL (), err )
591
601
}
592
- return "" , fmt .Errorf ("performing update for %s failed: %w" , client .AdminAPIClient ().BaseRootURL (), err )
593
602
}
594
-
603
+ sendDiagnostic ( false , nil ) // No error occurred.
595
604
// update the lastConfigSHA with the new updated checksum
596
605
client .SetLastConfigSHA (newConfigSHA )
597
606
0 commit comments