Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix entity group associations #10085

Merged
merged 1 commit into from Oct 1, 2021

Conversation

mdgreenfield
Copy link
Contributor

  • When two entities are merged, remove the from entity ID in any
    associated groups.
  • When two entities are merged, also merge their associated group
    memberships.

Fixes #10084

vault/identity_store_entities.go Show resolved Hide resolved
vault/identity_store_entities.go Show resolved Hide resolved
@@ -830,6 +847,14 @@ func (i *IdentityStore) mergeEntity(ctx context.Context, txn *memdb.Txn, toEntit
return nil, err
}

for _, group := range fromEntityGroups {
group.MemberEntityIDs = append(group.MemberEntityIDs, toEntity.ID)
err = i.UpsertGroupInTxn(ctx, txn, group, persist && !isPerfSecondaryOrStandby)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the usage of persist && !isPerfSecondaryOrStandby correct here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep!

@GitGarza13
Copy link

Don't want to be subscribe d

@mdgreenfield
Copy link
Contributor Author

Are there any edge cases that need to be handled for "external" groups?

Copy link
Member

@vishalnayak vishalnayak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @mdgreenfield. Thanks for catching the bug and for working on a fix. Apologies for getting back late on this. Would you be willing to take this forward?

Assuming you are, would you mind adding this behavior as part of the API docs as well?

vault/identity_store_entities.go Show resolved Hide resolved
@@ -830,6 +847,14 @@ func (i *IdentityStore) mergeEntity(ctx context.Context, txn *memdb.Txn, toEntit
return nil, err
}

for _, group := range fromEntityGroups {
group.MemberEntityIDs = append(group.MemberEntityIDs, toEntity.ID)
err = i.UpsertGroupInTxn(ctx, txn, group, persist && !isPerfSecondaryOrStandby)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep!

@mdgreenfield
Copy link
Contributor Author

Hi @vishalnayak, Not a problem. I can look at getting this PR in order next week.

- When two entities are merged, remove the from entity ID in any
  associated groups.
- When two entities are merged, also merge their associated group
  memberships.

Fixes hashicorp#10084
@mdgreenfield
Copy link
Contributor Author

PR has been rebased. API docs have been updated. Changelog file has been added.

@vishalnayak, very much related to this PR is #10101. Does it make sense to get that one in too?

@hghaf099
Copy link
Contributor

hghaf099 commented Oct 1, 2021

@mdgreenfield would you please work on this #10101 as well. Some tests in there are failing

@hghaf099 hghaf099 merged commit 2844dfa into hashicorp:main Oct 1, 2021
@mdgreenfield mdgreenfield deleted the identity-group-fixes branch October 1, 2021 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Identity groups not properly cleaned/merged with identity/entity/merge request
4 participants