mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
Add missing return to ingestKubequeryInfo
(#8178)
* Add missing return to ingestKubequeryInfo * No need to log error twice
This commit is contained in:
parent
8de3e9f258
commit
42c47a6fa7
1
changes/8161-fix-kubequery-rows-check
Normal file
1
changes/8161-fix-kubequery-rows-check
Normal file
@ -0,0 +1 @@
|
||||
- Fixed panic in `ingestKubequeryInfo` query ingestion.
|
@ -1201,8 +1201,7 @@ func directIngestMunkiInfo(ctx context.Context, logger log.Logger, host *fleet.H
|
||||
|
||||
func ingestKubequeryInfo(ctx context.Context, logger log.Logger, host *fleet.Host, rows []map[string]string) error {
|
||||
if len(rows) != 1 {
|
||||
logger.Log("component", "service", "method", "ingestKubequeryInfo", "warn",
|
||||
fmt.Sprintf("kubernetes_info expected single result got %d", len(rows)))
|
||||
return fmt.Errorf("kubernetes_info expected single result got: %d", len(rows))
|
||||
}
|
||||
|
||||
host.Hostname = fmt.Sprintf("kubequery %s", rows[0]["cluster_name"])
|
||||
|
@ -813,3 +813,16 @@ func TestDirectIngestWindowsUpdateHistory(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.True(t, ds.InsertWindowsUpdatesFuncInvoked)
|
||||
}
|
||||
|
||||
func TestIngestKubequeryInfo(t *testing.T) {
|
||||
err := ingestKubequeryInfo(context.Background(), log.NewNopLogger(), &fleet.Host{}, nil)
|
||||
require.Error(t, err)
|
||||
err = ingestKubequeryInfo(context.Background(), log.NewNopLogger(), &fleet.Host{}, []map[string]string{})
|
||||
require.Error(t, err)
|
||||
err = ingestKubequeryInfo(context.Background(), log.NewNopLogger(), &fleet.Host{}, []map[string]string{
|
||||
{
|
||||
"cluster_name": "foo",
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user