Skip to content

ROX-11070: Update group service and datastore to use ID instead of composite key.#2063

Merged
dhaus67 merged 10 commits intomasterfrom
dh/06-14-Update_service_and_datastore
Jul 4, 2022
Merged

ROX-11070: Update group service and datastore to use ID instead of composite key.#2063
dhaus67 merged 10 commits intomasterfrom
dh/06-14-Update_service_and_datastore

Conversation

@dhaus67
Copy link
Contributor

@dhaus67 dhaus67 commented Jun 14, 2022

Description

This is the second PR in a series of PRs regarding removing the composite key from the groups datastore, allowing users to specify different roles for the same group properties.

For full context, you can navigate to the previous PRs by using the comment created below.

This PR will cover the following:

  • Refactoring of the store interface and its implementations to use IDs instead of GroupProperties, as well as changing the key that is used within the bucket from a composite key to the ID.
  • Refactoring the datastore interface and its implementations to use IDs instead of GroupProperties, as well as moving the validation within the datastore instead of the service layer (similar to how other datastores behave currently).
  • Refactoring the service layer to use IDs instead of a composite key created out of the GroupProperties.

Checklist

  • Investigated and inspected CI test results
  • Unit test and regression tests added
  • Evaluated and added CHANGELOG entry if required
  • Determined and documented upgrade steps
  • Documented user facing changes (create PR based on openshift/openshift-docs and merge into rhacs-docs)

If any of these don't apply, please comment below.

Testing Performed

@openshift-ci
Copy link

openshift-ci bot commented Jun 14, 2022

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@dhaus67
Copy link
Contributor Author

dhaus67 commented Jun 14, 2022

@ghost
Copy link

ghost commented Jun 14, 2022

Tag for build #729986 is 3.70.x-573-gd2b50aecca.

💻 For deploying this image using the dev scripts, run the following first:

export MAIN_IMAGE_TAG='3.70.x-573-gd2b50aecca'

🕹️ A roxctl binary can be downloaded from the CircleCI artifacts.

@dhaus67 dhaus67 force-pushed the dh/06-14-Create_ID_for_groups branch from 3b92aac to 0dfa619 Compare June 14, 2022 23:39
@dhaus67 dhaus67 force-pushed the dh/06-14-Update_service_and_datastore branch from 7239011 to f4894c6 Compare June 14, 2022 23:39
@dhaus67 dhaus67 marked this pull request as ready for review June 14, 2022 23:58
@dhaus67 dhaus67 requested review from rukletsov and theencee June 14, 2022 23:58
@dhaus67 dhaus67 force-pushed the dh/06-14-Create_ID_for_groups branch from 0dfa619 to 048c22e Compare June 15, 2022 14:03
@dhaus67 dhaus67 force-pushed the dh/06-14-Update_service_and_datastore branch from f4894c6 to cf7585b Compare June 15, 2022 14:03
@dhaus67 dhaus67 force-pushed the dh/06-14-Create_ID_for_groups branch from 048c22e to 6d122bb Compare June 15, 2022 18:48
@dhaus67 dhaus67 force-pushed the dh/06-14-Update_service_and_datastore branch from cfccb5a to 9ac311b Compare June 15, 2022 18:48
@dhaus67 dhaus67 force-pushed the dh/06-14-Create_ID_for_groups branch from 6d122bb to 25526b3 Compare June 22, 2022 23:21
@dhaus67 dhaus67 force-pushed the dh/06-14-Update_service_and_datastore branch from 9ac311b to e4f75d9 Compare June 22, 2022 23:21
@dhaus67 dhaus67 requested a review from rukletsov June 23, 2022 01:36
@dhaus67 dhaus67 force-pushed the dh/06-14-Create_ID_for_groups branch from 25526b3 to deee13b Compare June 23, 2022 23:50
@dhaus67 dhaus67 force-pushed the dh/06-14-Update_service_and_datastore branch from e4f75d9 to f642da0 Compare June 23, 2022 23:52
@dhaus67 dhaus67 requested a review from a team June 30, 2022 00:58
Copy link
Member

@rukletsov rukletsov left a comment

Choose a reason for hiding this comment

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

Looks good to me modulo some questions for diffGroups(). Left a couple of comments on the cosmetics.

return errors.Wrap(err, "invalid group properties")
}
if group.GetRoleName() == "" {
return errox.InvalidArgs.New("groups must match to roles")
Copy link
Member

Choose a reason for hiding this comment

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

I highly suggest not using error classes in validation for two reasons:

  • At the point of the validation you can't really know the class because you don't know the origin of the validated object. Imagine we have some default groups we add upon startup — this clearly won't be 400.
  • It's much easier to follow error class conversions if we standardize on one level. Datastore (here probably Store) is usually a good candidate: it serves both to GraphQL and gRPC and usually possesses knowledge of objects' origin.

@0x656b694d maybe we can update the errox guidelines with this?

@dhaus67 dhaus67 force-pushed the dh/06-14-Create_ID_for_groups branch from deee13b to 3fa2c16 Compare June 30, 2022 21:03
@dhaus67 dhaus67 force-pushed the dh/06-14-Update_service_and_datastore branch from f642da0 to 6d061fe Compare June 30, 2022 21:03
@dhaus67 dhaus67 requested a review from rukletsov June 30, 2022 21:59
Copy link
Member

@rukletsov rukletsov left a comment

Choose a reason for hiding this comment

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

One last change and we're good to go. Thank you, Daniel!

Base automatically changed from dh/06-14-Create_ID_for_groups to master July 4, 2022 00:51
@ghost
Copy link

ghost commented Jul 4, 2022

Images are ready for the commit at d2b50ae.

To use with deploy scripts, first export MAIN_IMAGE_TAG=3.70.x-575-g8f3b3661ea.

@dhaus67
Copy link
Contributor Author

dhaus67 commented Jul 4, 2022

/retest

if err != nil {
return nil, err
}
if len(grps) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

You previously had an error case if more than one group has been found. I think you want to put it back here.

	if len(grps) > 1 {
		return nil, errox.InvalidArgs.Newf("multiple groups found for properties (auth provider id=%s, key=%s, "+
			"value=%s), provide an ID to retrieve a group unambiguously",
			props.GetAuthProviderId(), props.GetKey(), props.GetValue())

@dhaus67
Copy link
Contributor Author

dhaus67 commented Jul 4, 2022

/retest

@openshift-ci
Copy link

openshift-ci bot commented Jul 4, 2022

@dhaus67: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/gke-ui-e2e-tests d2b50ae link false /test gke-ui-e2e-tests

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@dhaus67
Copy link
Contributor Author

dhaus67 commented Jul 4, 2022

Will merge this now, the UI related tests are also sadly failing within nightlies.

@dhaus67 dhaus67 merged commit 4abdbfa into master Jul 4, 2022
@dhaus67 dhaus67 deleted the dh/06-14-Update_service_and_datastore branch July 4, 2022 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants