v0.1.35: фиксы — синхронные удаления в Redis (воскрешение очередей) + RedrivePolicy tenant-scoped DLQ
This commit is contained in:
@@ -71,7 +71,7 @@ func CreateQueueV1(req *http.Request) (int, interfaces.AbstractResponseBody) {
|
||||
if req.Header.Get("Content-Type") != "application/x-amz-json-1.0" {
|
||||
provided = utils.ExtractQueueAttributes(req.PostForm)
|
||||
}
|
||||
if err := setQueueAttributesV1(queue, requestBody.Attributes, provided); err != nil {
|
||||
if err := setQueueAttributesV1(queue, requestBody.Attributes, provided, t.AccessKey); err != nil {
|
||||
models.SyncQueues.Unlock()
|
||||
return utils.CreateErrorResponseV1(err.Error(), true)
|
||||
}
|
||||
|
||||
@@ -22,9 +22,11 @@ import (
|
||||
// обнулял все остальные атрибуты очереди.
|
||||
// 3. Значения вне диапазонов AWS → ошибка InvalidParameterValue
|
||||
// (раньше значения молча клэмпились в допустимый диапазон).
|
||||
// 4. RedrivePolicy: ARN DLQ разбирается, DLQ должна существовать, иначе
|
||||
// InvalidAttributeValue.
|
||||
func setQueueAttributesV1(q *models.Queue, attr models.QueueAttributes, provided map[string]string) error {
|
||||
// 4. RedrivePolicy: ARN DLQ разбирается, DLQ ищется по TENANT-SCOPED ключу
|
||||
// "{accessKey}:{queueName}" (раньше — по голому имени, а ключи в map
|
||||
// tenant-scoped → DLQ никогда не находилась, RedrivePolicy не работал).
|
||||
// DLQ должна принадлежать тому же тенанту.
|
||||
func setQueueAttributesV1(q *models.Queue, attr models.QueueAttributes, provided map[string]string, tenantAccessKey string) error {
|
||||
// Шаг 1: whitelist имён атрибутов (единый список — models.AttrNameWhitelist).
|
||||
for name := range provided {
|
||||
if !models.AttrNameWhitelist[name] {
|
||||
@@ -71,7 +73,9 @@ func setQueueAttributesV1(q *models.Queue, attr models.QueueAttributes, provided
|
||||
if attr.RedrivePolicy != (models.RedrivePolicy{}) {
|
||||
arnArray := strings.Split(attr.RedrivePolicy.DeadLetterTargetArn, ":")
|
||||
queueName := arnArray[len(arnArray)-1]
|
||||
deadLetterQueue, ok := models.SyncQueues.Queues[queueName]
|
||||
// DLQ ищем по tenant-scoped ключу — как хранятся все очереди.
|
||||
dlqKey := tenantAccessKey + ":" + queueName
|
||||
deadLetterQueue, ok := models.SyncQueues.Queues[dlqKey]
|
||||
if !ok {
|
||||
log.Error("Invalid RedrivePolicy Attribute")
|
||||
return fmt.Errorf("InvalidAttributeValue")
|
||||
|
||||
@@ -61,7 +61,7 @@ func SetQueueAttributesV1(req *http.Request) (int, interfaces.AbstractResponseBo
|
||||
provided = utils.ExtractQueueAttributes(req.PostForm)
|
||||
}
|
||||
|
||||
if err := setQueueAttributesV1(queue, requestBody.Attributes, provided); err != nil {
|
||||
if err := setQueueAttributesV1(queue, requestBody.Attributes, provided, t.AccessKey); err != nil {
|
||||
return utils.CreateErrorResponseV1(err.Error(), true)
|
||||
}
|
||||
// Сохраняем атрибуты в Redis пока держим Lock (через defer)
|
||||
|
||||
Reference in New Issue
Block a user