parent
60431804d8
commit
f4ed7b3520
1 changed files with 13 additions and 3 deletions
|
@ -636,14 +636,24 @@ func (c *Client) createAlertChunk(machineID string, owner *ent.Machine, alerts [
|
|||
if len(alertItem.Meta) > 0 {
|
||||
metaBulk := make([]*ent.MetaCreate, len(alertItem.Meta))
|
||||
for i, metaItem := range alertItem.Meta {
|
||||
key := metaItem.Key
|
||||
value := metaItem.Value
|
||||
if len(metaItem.Value) > 4095 {
|
||||
c.Log.Warningf("truncated meta %s : value too long", metaItem.Key)
|
||||
value = value[:4095]
|
||||
}
|
||||
if len(metaItem.Key) > 255 {
|
||||
c.Log.Warningf("truncated meta %s : key too long", metaItem.Key)
|
||||
key = key[:255]
|
||||
}
|
||||
metaBulk[i] = c.Ent.Meta.Create().
|
||||
SetKey(metaItem.Key).
|
||||
SetValue(metaItem.Value)
|
||||
SetKey(key).
|
||||
SetValue(value)
|
||||
}
|
||||
|
||||
metas, err = c.Ent.Meta.CreateBulk(metaBulk...).Save(c.CTX)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(BulkError, "creating alert meta: %s", err)
|
||||
c.Log.Warningf("error creating alert meta: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue