Skip to content

Commit fff0f9b

Browse files
authored
Merge pull request #51 from liu-cong/no-fatal-on-metric-error
Do not fail Init if fetch metrics fails. It can recover gracefully.
2 parents a55f870 + 22b63e1 commit fff0f9b

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

pkg/ext-proc/backend/provider.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,10 @@ func (p *Provider) GetPodMetrics(pod Pod) (*PodMetrics, bool) {
5959

6060
func (p *Provider) Init(refreshPodsInterval, refreshMetricsInterval time.Duration) error {
6161
if err := p.refreshPodsOnce(); err != nil {
62-
return fmt.Errorf("failed to init pods: %v", err)
62+
klog.Errorf("Failed to init pods: %v", err)
6363
}
64-
err := p.refreshMetricsOnce()
65-
if err != nil {
66-
return fmt.Errorf("failed to init metrics: %v", err)
64+
if err := p.refreshMetricsOnce(); err != nil {
65+
klog.Errorf("Failed to init metrics: %v", err)
6766
}
6867

6968
klog.Infof("Initialized pods and metrics: %+v", p.AllPodMetrics())

pkg/ext-proc/backend/provider_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,10 @@ func TestProvider(t *testing.T) {
7171
datastore: &K8sDatastore{
7272
Pods: populateMap(pod1.Pod, pod2.Pod),
7373
},
74-
initErr: true,
7574
want: []*PodMetrics{
7675
pod1,
7776
// Failed to fetch pod2 metrics so it remains the default values.
78-
&PodMetrics{
77+
{
7978
Pod: Pod{Name: "pod2"},
8079
Metrics: Metrics{
8180
WaitingQueueSize: 0,

0 commit comments

Comments
 (0)