Skip to content

Commit

Permalink
Add a few log messages to exporter process (#367)
Browse files Browse the repository at this point in the history
Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>
  • Loading branch information
antoninbas committed Sep 12, 2024
1 parent 85a9bbd commit 63a547f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/exporter/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,14 @@ func InitExportingProcess(input ExporterInput) (*ExportingProcess, error) {
case <-expProc.stopCh:
return
case <-ticker.C:
klog.V(2).Info("Sending refreshed templates to the collector")
err := expProc.sendRefreshedTemplates()
if err != nil {
klog.Errorf("Error when sending refreshed templates, closing the connection to the collector: %v", err)
expProc.closeConnToCollector()
return
}
klog.V(2).Info("Sent refreshed templates to the collector")
}
}
}()
Expand Down Expand Up @@ -278,11 +280,12 @@ func (ep *ExportingProcess) closeConnToCollector() {
if ep.isClosed.Swap(true) {
return
}
klog.Info("Closing connection to the collector")
close(ep.stopCh)
if err := ep.connToCollector.Close(); err != nil {
// Just log the error that happened when closing the connection. Not returning error
// as we do not expect library consumers to exit their programs with this error.
klog.Errorf("Error when closing connection to collector: %v", err)
klog.Errorf("Error when closing connection to the collector: %v", err)
}
}

Expand Down

0 comments on commit 63a547f

Please sign in to comment.