Skip to content

Commit bbec2f6

Browse files
committed
fix(*): do not return error when reporter of gvk not found
1 parent 37b712e commit bbec2f6

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

pkg/agent/resourcemanager/reporter/manager.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ func (r *managerImpl) PushContents(ctx context.Context, responses map[string]*v1
9797
for gvk, fields := range reportFieldsByGVK {
9898
u, ok := r.reporters[gvk]
9999
if !ok || u == nil {
100-
return fmt.Errorf("reporter of gvk %s not found", gvk)
100+
klog.Warningf("reporter of gvk %s not found", gvk)
101+
continue
101102
}
102103

103104
sort.SliceStable(fields, func(i, j int) bool {

pkg/agent/resourcemanager/reporter/manager_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,33 @@ func Test_managerImpl_PushContents(t *testing.T) {
201201
},
202202
wantErr: false,
203203
},
204+
{
205+
name: "test-2",
206+
fields: fields{
207+
conf: generateTestConfiguration(t),
208+
reporters: map[v1.GroupVersionKind]Reporter{},
209+
},
210+
args: args{
211+
ctx: context.TODO(),
212+
responses: map[string]*v1alpha1.GetReportContentResponse{
213+
"agent-2": {
214+
Content: []*v1alpha1.ReportContent{
215+
{
216+
GroupVersionKind: &testGroupVersionKindFirst,
217+
Field: []*v1alpha1.ReportField{
218+
{
219+
FieldType: v1alpha1.FieldType_Spec,
220+
FieldName: "fieldName_b",
221+
Value: []byte("Value_b"),
222+
},
223+
},
224+
},
225+
},
226+
},
227+
},
228+
},
229+
wantErr: false,
230+
},
204231
}
205232
for _, tt := range tests {
206233
tt := tt

0 commit comments

Comments
 (0)