Backport of Replicate member_entity_ids and policies in identity/group across nodes identically into release/1.9.x #16177
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport
This PR is auto-generated from #16088 to be assessed for backporting due to the inclusion of the label backport/1.9.x.
WARNING automatic cherry-pick of commits failed. Commits will require human attention.
The below text is copied from the body of the original PR.
Addresses https://hashicorp.atlassian.net/browse/VAULT-2282
Example of reading an identity/group from a standby node:
{ "request_id": "4015c4c6-ee28-eec9-a42d-a0be91970dbc", "lease_id": "", "lease_duration": 0, "renewable": false, "data": { "alias": {}, "creation_time": "2022-06-21T05:56:12.378602Z", "id": "6a769520-f4b5-59a1-d7d7-21a650c91343", "last_update_time": "2022-06-21T05:56:12.378602Z", "member_entity_ids": null, "member_group_ids": [ "66bcfa57-8aab-04c8-d9ed-263bb5d2e6b0", "b7919faf-0a16-6acd-9e4d-82ac6db946bc" ], "metadata": null, "modify_index": 1, "name": "testgroup3", "namespace_id": "root", "parent_group_ids": null, "policies": [ "default" ], "type": "internal" }, "warnings": [ "Endpoint ignored these unrecognized parameters: [-format]" ] }
A group is marshalled and persisted in the leader node and then replicated to standby nodes. In standby node, memDB is populated after unmarshalling the group entry. However, member_entity_ids is an initialized empty slice when marshalled, but become a nil entry upon unmarshalling. This creates an inconsistency on the way active/standby nodes return the results.
To fix that, it was noticed that
member_entity_ids
field is nil, then passed intostrutil.RemoveDuplicates
function so that the duplicated entries be removed. That function returns an initialized empty slice regardless of thenil
argument. The fix simply checks if themember_entity_ids
field is not nil before passing it to that function. A test is going to be added to the ENT repo. Further details can be found in the ticket.Overview of commits