Replicate member_entity_ids and policies in identity/group across nodes identically (#16088)
* Replicate values of group member_entity_ids and policies across nodes identically * Adding CL * fixing tests
This commit is contained in:
parent
29cae725ce
commit
fa754c7fa5
|
@ -0,0 +1,3 @@
|
|||
```release-note:bug
|
||||
core/identity: Replicate member_entity_ids and policies in identity/group across nodes identically
|
||||
```
|
|
@ -628,8 +628,20 @@ func assertMember(t *testing.T, client *api.Client, entityID, groupName, groupID
|
|||
t.Fatal(err)
|
||||
}
|
||||
groupMap := secret.Data
|
||||
|
||||
groupEntityMembers, ok := groupMap["member_entity_ids"].([]interface{})
|
||||
if !ok && expectFound {
|
||||
t.Fatalf("expected member_entity_ids not to be nil")
|
||||
}
|
||||
|
||||
// if type assertion fails and expectFound is false, groupEntityMembers
|
||||
// is nil, then let's just return, nothing to be done!
|
||||
if !ok && !expectFound {
|
||||
return
|
||||
}
|
||||
|
||||
found := false
|
||||
for _, entityIDRaw := range groupMap["member_entity_ids"].([]interface{}) {
|
||||
for _, entityIDRaw := range groupEntityMembers {
|
||||
if entityIDRaw.(string) == entityID {
|
||||
found = true
|
||||
}
|
||||
|
|
|
@ -1473,6 +1473,7 @@ func (i *IdentityStore) sanitizeAndUpsertGroup(ctx context.Context, group *ident
|
|||
}
|
||||
|
||||
// Remove duplicate entity IDs and check if all IDs are valid
|
||||
if group.MemberEntityIDs != nil {
|
||||
group.MemberEntityIDs = strutil.RemoveDuplicates(group.MemberEntityIDs, false)
|
||||
for _, entityID := range group.MemberEntityIDs {
|
||||
entity, err := i.MemDBEntityByID(entityID, false)
|
||||
|
@ -1483,9 +1484,12 @@ func (i *IdentityStore) sanitizeAndUpsertGroup(ctx context.Context, group *ident
|
|||
return fmt.Errorf("invalid entity ID %q", entityID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicate policies
|
||||
if group.Policies != nil {
|
||||
group.Policies = strutil.RemoveDuplicates(group.Policies, false)
|
||||
}
|
||||
|
||||
txn := i.db.Txn(true)
|
||||
defer txn.Abort()
|
||||
|
|
Loading…
Reference in New Issue