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

feat(iam): add iam bindings to crds #191

Merged
merged 12 commits into from
Mar 26, 2024
Merged

feat(iam): add iam bindings to crds #191

merged 12 commits into from
Mar 26, 2024

Conversation

tpokki
Copy link
Contributor

@tpokki tpokki commented Dec 25, 2023

Is there interest to add IAM bindings into the Topic and Subscription specs? I was thinking to add them as part of the topics and subs, rather than own separate CRD. But I suppose that would work as well.

The testing part is not ideal unfortunately. I did not find any good way to register additional servers into pstest.Server, that hides the grpc.Server behind unexposed variable. I had to hack the IAMPolicyServer into it thru reflection, and it randomly fails if the registration happens after grpc.Server.Serve()...

@tpokki
Copy link
Contributor Author

tpokki commented Jan 19, 2024

Is there something I can do for those failed checks?

Comment on lines 112 to 120
// try to get access to `Gsrv` thru `*testutil.Server`, that's on first field of `pstest.Server`
rs := reflect.ValueOf(psServer).Elem()

// *testutil.Server
tsrv := rs.Field(0)
tsrv = reflect.NewAt(tsrv.Type(), unsafe.Pointer(tsrv.UnsafeAddr())).Elem()

// *grpc.Server is found from the exported field `Gsrv`
gsrv := reflect.Indirect(tsrv).FieldByName("Gsrv").Interface().(*grpc.Server)
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for the great work! I really understand why the reflection is needed and hope pstest package exports the internal *grpc.Server.

If the integration test is broken due to the change of pstest structure, it may be difficult to investigate the root cause. I'd like to suggest to extract this part to a separated function and write a unit test against the function. It ensures that the reflection works as we expect.

For example,

package pubsubtest

func GetInternalGrpcServer(psServer *pstest.Server) *grpc.Server {
  //...
}

func TestGetInternalGrpcServer(t *testing.T) {
  psServer := pstest.NewServer()
  gSrv := GetInternalGrpcServer(psServer)
  //...
}

@int128
Copy link
Member

int128 commented Jan 25, 2024

It seems due to the permissions of forked repository. make test passes perfectly on my laptop.

@tpokki
Copy link
Contributor Author

tpokki commented Jan 25, 2024

It seems due to the permissions of forked repository. make test passes perfectly on my laptop.

The fork should be public repo. Should I add write access to someone / something?

@tpokki tpokki requested a review from int128 February 27, 2024 06:35
Copy link
Member

@int128 int128 left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution!

@int128 int128 merged commit bfbecf0 into quipper:main Mar 26, 2024
@tpokki tpokki deleted the iam branch April 7, 2024 09:03
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.

2 participants