mirror of
https://github.com/minio/minio.git
synced 2025-03-29 00:33:42 -04:00
fix: crash when audit webhook queue_dir is not writable (#19854)
This is regression introduced in #19275 refactor
This commit is contained in:
parent
2a75225569
commit
ba54b39c02
@ -193,7 +193,20 @@ func (h *Target) initDiskStore(ctx context.Context) (err error) {
|
|||||||
h.storeCtxCancel = cancel
|
h.storeCtxCancel = cancel
|
||||||
h.lastStarted = time.Now()
|
h.lastStarted = time.Now()
|
||||||
go h.startQueueProcessor(ctx, true)
|
go h.startQueueProcessor(ctx, true)
|
||||||
|
|
||||||
|
queueStore := store.NewQueueStore[interface{}](
|
||||||
|
filepath.Join(h.config.QueueDir, h.Name()),
|
||||||
|
uint64(h.config.QueueSize),
|
||||||
|
httpLoggerExtension,
|
||||||
|
)
|
||||||
|
|
||||||
|
if err := queueStore.Open(); err != nil {
|
||||||
|
return fmt.Errorf("unable to initialize the queue store of %s webhook: %w", h.Name(), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
h.store = queueStore
|
||||||
store.StreamItems(h.store, h, ctx.Done(), h.config.LogOnceIf)
|
store.StreamItems(h.store, h, ctx.Done(), h.config.LogOnceIf)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,10 +327,7 @@ func (h *Target) startQueueProcessor(ctx context.Context, mainWorker bool) {
|
|||||||
enc := jsoniter.ConfigCompatibleWithStandardLibrary.NewEncoder(buf)
|
enc := jsoniter.ConfigCompatibleWithStandardLibrary.NewEncoder(buf)
|
||||||
defer bytebufferpool.Put(buf)
|
defer bytebufferpool.Put(buf)
|
||||||
|
|
||||||
isDirQueue := false
|
isDirQueue := h.config.QueueDir != ""
|
||||||
if h.config.QueueDir != "" {
|
|
||||||
isDirQueue = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// globalBuffer is always created or adjusted
|
// globalBuffer is always created or adjusted
|
||||||
// before this method is launched.
|
// before this method is launched.
|
||||||
@ -504,23 +514,6 @@ func New(config Config) (*Target, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
h.client = &http.Client{Transport: h.config.Transport}
|
h.client = &http.Client{Transport: h.config.Transport}
|
||||||
|
|
||||||
if h.config.QueueDir != "" {
|
|
||||||
|
|
||||||
queueStore := store.NewQueueStore[interface{}](
|
|
||||||
filepath.Join(h.config.QueueDir, h.Name()),
|
|
||||||
uint64(h.config.QueueSize),
|
|
||||||
httpLoggerExtension,
|
|
||||||
)
|
|
||||||
|
|
||||||
if err := queueStore.Open(); err != nil {
|
|
||||||
return h, fmt.Errorf("unable to initialize the queue store of %s webhook: %w", h.Name(), err)
|
|
||||||
}
|
|
||||||
|
|
||||||
h.store = queueStore
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return h, nil
|
return h, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,9 +169,8 @@ func (h *Target) Init(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *Target) initQueueStore(ctx context.Context) (err error) {
|
func (h *Target) initQueueStore(ctx context.Context) (err error) {
|
||||||
var queueStore store.Store[interface{}]
|
|
||||||
queueDir := filepath.Join(h.kconfig.QueueDir, h.Name())
|
queueDir := filepath.Join(h.kconfig.QueueDir, h.Name())
|
||||||
queueStore = store.NewQueueStore[interface{}](queueDir, uint64(h.kconfig.QueueSize), kafkaLoggerExtension)
|
queueStore := store.NewQueueStore[interface{}](queueDir, uint64(h.kconfig.QueueSize), kafkaLoggerExtension)
|
||||||
if err = queueStore.Open(); err != nil {
|
if err = queueStore.Open(); err != nil {
|
||||||
return fmt.Errorf("unable to initialize the queue store of %s webhook: %w", h.Name(), err)
|
return fmt.Errorf("unable to initialize the queue store of %s webhook: %w", h.Name(), err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user