From 6a8d8f34a564a1945fd1e8249a2722a9bc06d8f1 Mon Sep 17 00:00:00 2001 From: Anis Eleuch Date: Fri, 1 Sep 2023 16:37:22 +0100 Subject: [PATCH] kafka: Do not require key when sending a message (#17962) Keys are helpful to ensure the strict ordering of messages, however currently the code uses a random request id for every log, hence using the request-id as a Kafka key is not serve any purpose; This commit removes the usage of the key, to also fix the audit issue from internal subsystem that does not have a request ID. --- cmd/os-rename_nolinux.go | 2 +- internal/logger/target/kafka/kafka.go | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/cmd/os-rename_nolinux.go b/cmd/os-rename_nolinux.go index d4a3284b8..836d140f6 100644 --- a/cmd/os-rename_nolinux.go +++ b/cmd/os-rename_nolinux.go @@ -22,7 +22,7 @@ package cmd import "errors" -// Rename captures time taken to call os.Rename +// Rename2 is not implemented in a non linux environment func Rename2(src, dst string) (err error) { defer updateOSMetrics(osMetricRename2, src, dst)(errors.New("not implemented, skipping")) return errSkipFile diff --git a/internal/logger/target/kafka/kafka.go b/internal/logger/target/kafka/kafka.go index b7265d494..0b26ab197 100644 --- a/internal/logger/target/kafka/kafka.go +++ b/internal/logger/target/kafka/kafka.go @@ -27,14 +27,12 @@ import ( "net" "os" "path/filepath" - "reflect" "sync" "sync/atomic" "time" "github.com/IBM/sarama" saramatls "github.com/IBM/sarama/tools/tls" - "github.com/tidwall/gjson" "github.com/minio/minio/internal/logger/target/types" "github.com/minio/minio/internal/once" @@ -241,14 +239,8 @@ func (h *Target) send(entry interface{}) error { if err != nil { return err } - requestID := gjson.GetBytes(logJSON, "requestID").Str - if requestID == "" { - // unsupported data structure - return fmt.Errorf("unsupported data structure: %s must be either audit.Entry or log.Entry", reflect.TypeOf(entry)) - } msg := sarama.ProducerMessage{ Topic: h.kconfig.Topic, - Key: sarama.StringEncoder(requestID), Value: sarama.ByteEncoder(logJSON), } _, _, err = h.producer.SendMessage(&msg)