2020-08-11 12:10:01 +00:00
|
|
|
package container
|
|
|
|
|
|
|
|
import (
|
|
|
|
"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())
|
2023-04-13 12:51:36 +00:00
|
|
|
cp.log.Info(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
|
2023-04-12 14:35:10 +00:00
|
|
|
cp.log.Warn(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)
|
2023-04-13 12:51:36 +00:00
|
|
|
cp.log.Info(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
|
2023-04-12 14:35:10 +00:00
|
|
|
cp.log.Warn(logs.ContainerContainerProcessorWorkerPoolDrained,
|
2020-09-02 16:04:29 +00:00
|
|
|
zap.Int("capacity", cp.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|
2021-05-19 12:18:07 +00:00
|
|
|
|
|
|
|
func (cp *Processor) handleSetEACL(ev event.Event) {
|
|
|
|
e := ev.(containerEvent.SetEACL)
|
|
|
|
|
2023-04-13 12:51:36 +00:00
|
|
|
cp.log.Info(logs.Notification,
|
2021-05-19 12:18:07 +00:00
|
|
|
zap.String("type", "set EACL"),
|
|
|
|
)
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// send an event to the worker pool
|
2021-05-19 12:18:07 +00:00
|
|
|
|
2023-05-26 10:24:41 +00:00
|
|
|
err := processors.SubmitEvent(cp.pool, cp.metrics, "container_set_eacl", func() bool {
|
|
|
|
return cp.processSetEACL(e)
|
2021-05-19 12:18:07 +00:00
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
// there system can be moved into controlled degradation stage
|
2023-04-12 14:35:10 +00:00
|
|
|
cp.log.Warn(logs.ContainerContainerProcessorWorkerPoolDrained,
|
2021-05-19 12:18:07 +00:00
|
|
|
zap.Int("capacity", cp.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|