2020-08-11 12:10:01 +00:00
|
|
|
package container
|
|
|
|
|
|
|
|
import (
|
2024-10-21 07:22:54 +00:00
|
|
|
"context"
|
2020-08-11 12:10:01 +00:00
|
|
|
"crypto/sha256"
|
|
|
|
|
2023-04-12 14:35:10 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
2023-05-26 10:24:41 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors"
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event"
|
|
|
|
containerEvent "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event/container"
|
2020-08-11 12:10:01 +00:00
|
|
|
"github.com/mr-tron/base58"
|
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (cp *Processor) handlePut(ev event.Event) {
|
2021-10-12 14:56:17 +00:00
|
|
|
put := ev.(putEvent)
|
2020-08-11 12:10:01 +00:00
|
|
|
|
|
|
|
id := sha256.Sum256(put.Container())
|
2024-10-21 07:22:54 +00:00
|
|
|
cp.log.Info(context.Background(), logs.Notification,
|
2020-08-11 12:10:01 +00:00
|
|
|
zap.String("type", "container put"),
|
|
|
|
zap.String("id", base58.Encode(id[:])))
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// send an event to the worker pool
|
2020-08-11 12:10:01 +00:00
|
|
|
|
2023-05-26 10:24:41 +00:00
|
|
|
err := processors.SubmitEvent(cp.pool, cp.metrics, "container_put", func() bool {
|
|
|
|
return cp.processContainerPut(put)
|
|
|
|
})
|
2020-08-11 12:10:01 +00:00
|
|
|
if err != nil {
|
2020-09-08 09:09:08 +00:00
|
|
|
// there system can be moved into controlled degradation stage
|
2024-10-21 07:22:54 +00:00
|
|
|
cp.log.Warn(context.Background(), logs.ContainerContainerProcessorWorkerPoolDrained,
|
2020-08-11 12:10:01 +00:00
|
|
|
zap.Int("capacity", cp.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|
2020-09-02 16:04:29 +00:00
|
|
|
|
|
|
|
func (cp *Processor) handleDelete(ev event.Event) {
|
2020-09-08 09:09:08 +00:00
|
|
|
del := ev.(containerEvent.Delete)
|
2024-10-21 07:22:54 +00:00
|
|
|
cp.log.Info(context.Background(), logs.Notification,
|
2020-09-02 16:04:29 +00:00
|
|
|
zap.String("type", "container delete"),
|
|
|
|
zap.String("id", base58.Encode(del.ContainerID())))
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// send an event to the worker pool
|
2020-09-02 16:04:29 +00:00
|
|
|
|
2023-05-26 10:24:41 +00:00
|
|
|
err := processors.SubmitEvent(cp.pool, cp.metrics, "container_delete", func() bool {
|
|
|
|
return cp.processContainerDelete(del)
|
|
|
|
})
|
2020-09-02 16:04:29 +00:00
|
|
|
if err != nil {
|
2020-09-08 09:09:08 +00:00
|
|
|
// there system can be moved into controlled degradation stage
|
2024-10-21 07:22:54 +00:00
|
|
|
cp.log.Warn(context.Background(), logs.ContainerContainerProcessorWorkerPoolDrained,
|
2020-09-02 16:04:29 +00:00
|
|
|
zap.Int("capacity", cp.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|