Skip to content

Commit

Permalink
Add check before calling SliceK8sObjectToChunks method
Browse files Browse the repository at this point in the history
  • Loading branch information
patilsuraj767 committed Sep 11, 2023
1 parent 2712c00 commit 5002c74
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/services/report_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/go-gota/gota/dataframe"
"github.com/go-playground/validator/v10"

"github.com/redhatinsights/ros-ocp-backend/internal/config"
"github.com/redhatinsights/ros-ocp-backend/internal/logging"
"github.com/redhatinsights/ros-ocp-backend/internal/model"
"github.com/redhatinsights/ros-ocp-backend/internal/types"
Expand All @@ -20,6 +21,7 @@ import (

func ProcessReport(msg *kafka.Message) {
log := logging.GetLogger()
cfg := config.GetConfig()
validate := validator.New()
var kafkaMsg types.KafkaMsg
if !json.Valid([]byte(msg.Value)) {
Expand Down Expand Up @@ -117,7 +119,12 @@ func ProcessReport(msg *kafka.Message) {
continue
}

k8s_object_chunks := utils.SliceK8sObjectToChunks(k8s_object)
var k8s_object_chunks [][]map[string]interface{}
if len(k8s_object) > cfg.KruizeMaxBulkChunkSize {
k8s_object_chunks = utils.SliceK8sObjectToChunks(k8s_object)
} else {
k8s_object_chunks = append(k8s_object_chunks, k8s_object)
}

for _, chunk := range k8s_object_chunks {
usage_data_byte, err := kruize.Update_results(experiment_name, chunk)
Expand Down

0 comments on commit 5002c74

Please sign in to comment.