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

Add xDS group service. #981

Merged
merged 8 commits into from
Aug 4, 2024
Merged

Add xDS group service. #981

merged 8 commits into from
Aug 4, 2024

Conversation

minwoox
Copy link
Contributor

@minwoox minwoox commented Jul 15, 2024

Motivation:
A user might want to manage her own xDS resources with a group of people who have permission to create and update these resources. By creating an xDS group (a Central Dogma repository), she can easily manage these xDS resources and grant write permissions to specific people, allowing them to manage the resources under Central Dogma's authorization system.

Modifications:

  • Added XdsGroupService to create a group, which is a Central Dogma repository.
    • With this group, a user can easily manage privileged people under the Central Dogma authorization system.
    • xds_group.proto file is also added.
      • All proto files might be published in a separate module later for other clients such as LEGY.
  • Removed MetadataServiceInjector.
    • MetadataService is injected when a decorator is created using a DependencyInjector.

Result:

  • You can now create xDS groups to manage your xDS resources under the Central Dogma authorization system.

Motivation:
A user might want to manage her own xDS resources with a group of people who have the permission to create and update these resources.
By creating an xDS application (a Central Dogma repository), she can easily manage these xDS resources and grant write permissions
to specific people, allowing them to manage the resources under Central Dogma's authorization system.

Modifications:
- Added `XdsApplicationService` to create an application, which is a Central Dogma repository.
  - With this application, a user can easily manage privileged people under the Central Dogma authorization system.

Result:
- You can now create xDS applications to manage your xDS resources under the Central Dogma authorization system.
@minwoox minwoox added this to the 0.68.0 milestone Jul 15, 2024
@minwoox minwoox changed the title Add xDS application service. [WIP] Add xDS application service. Jul 15, 2024
@minwoox minwoox changed the title [WIP] Add xDS application service. Add xDS application service. Jul 16, 2024
@minwoox minwoox changed the title Add xDS application service. Add xDS group service. Jul 17, 2024
Copy link
Contributor

@jrhee17 jrhee17 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 overall, the /groups prefix is the only issue bothering me. The rest looks good 👍

public void createGroup(CreateGroupRequest request,
StreamObserver<Group> responseObserver) {
final String groupName = request.getGroup().getName();
final String name = removePrefix("groups/", groupName);
Copy link
Contributor

Choose a reason for hiding this comment

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

Taking another look at this PR, it seems like we're going need to extra logic to remove/add groups/ in all user-facing locations. i.e. API paths, DTOs, UI, metrics, etc.. I'm not sure if it's realistic and worth it to ensure this.

Do you mind explaining why we need this prefix again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like I said before, I'm trying to adhere to the AIP as much as possible:
https://google.aip.dev/122
It recommends in this way:

publishers/123/books/les-miserables
users/vhugo1802

Resource name components should usually alternate between collection identifiers (example: publishers, books, users) and resource IDs (example: 123, les-miserables, vhugo1802).

we're going need to extra logic to remove/add groups/ in all user-facing locations.

Yeah, that is true. But the logic isn't so many, and we still need that logic for validating and removing group name from the cluster name.
I thought the format (groups/{group}/clusters/{cluster}), which follows the guideline, was much better than the original format ({group}/{cluster}).

Copy link
Contributor

Choose a reason for hiding this comment

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

If you're strong on following the AIP, then sure. Ideally I prefer that there is a cross-cutting solution to apply this, but I guess we'll be doing this manually then.

e.g. If a new API is added where groupName is the parameter, we should be conscious to add/remove the prefix.

Copy link
Contributor Author

@minwoox minwoox Jul 19, 2024

Choose a reason for hiding this comment

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

Ideally I prefer that there is a cross-cutting solution to apply this

I also prefer applying the cross-cutting solution, which is why I hesitated to follow the AIP at first. 😕 However, I've decided to try using gRPC for this API, and it’s not easy to apply AOP even if I don’t follow AIP because it needs parameters in the message.
I also considered abandoning gRPC and just using REST, but decided against it. So, I followed the AIP.

.addService(new XdsGroupService(
projectManager, pluginInitContext.commandExecutor()))
.enableHttpJsonTranscoding(true).build();
sb.service(xdsApplicationService, pluginInitContext.authService());
Copy link
Contributor

Choose a reason for hiding this comment

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

Question) Just so I understand the current state, IIUC only admins have access to internal projects. Hence, am I understanding correctly that only admins will be able to use XdsGroupService for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Anyone can use the XdsGroupService for now as I talked before.
https://github.com/line/centraldogma/pull/981/files#diff-6530b293347a15e8133c26cfb4221f0b565c32f0a6cccb8c1d44c0d78108c8bfR62

After modifying the authorization system similar to GitHub, anyone can create a group, and the one who created the group can add anyone or tokens to the group who will have the write permission for the resources in the group.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, I must have glanced through the diffset. I understood that for now, anyone can create/delete anyone's group 👍

responseObserver.onError(alreadyExistsException(name));
} else {
responseObserver.onError(
Status.INTERNAL.withCause(cause).asRuntimeException());
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: I'm curious on how we'll deal with handling exceptions later on as sometimes we perform special operations like in ReplicationLagTolerantCentralDogma for RevisionNotFoundException.

For now, I assume creating a repository and getting the repository immediately won't necessary succeed if the get is from a different replica.

Anyways, I guess the current approach is fine for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good question. I will add the gRPC exception handler for the xDS services after I all set up the services.

}

// Deletes an group.
rpc DeleteGroup(DeleteGroupRequest) returns (google.protobuf.Empty) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: This is a red flag personally since I think there is always the possibility that additional fields will need to be added. Having said this, I guess it's fine to try adhering to the AIP like you proposed for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a red flag personally since I think there is always the possibility that additional fields will need to be added.

Would you mind explaining which fields are likely to be added later?
If that's reasonable, I will define a message and return it instead of the Empty.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's just follow the AIP for now since the point is to ease these types of discussions.

Copy link
Contributor

@jrhee17 jrhee17 left a comment

Choose a reason for hiding this comment

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

👍 👍 👍

Copy link
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

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

Thanks!


@Override
public void createGroup(CreateGroupRequest request,
StreamObserver<Group> responseObserver) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional) What do you think of using Reactive-gRPC instead of the vanilla gRPC? It is only used for server modules so we are relatively free of dependencies. Reactive-gRPC could remove boilerplate code such as .onNext() + .onCopmlete().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion. 👍
Well, honestly, I didn't want to use any other gRPC libraries because the logic is relatively simple (All methods are unary) and it might take more time (maybe just for me) when troubleshooting.

However, that doesn't mean that I will never use grpc-reactor. I will definitely use it when I think it gives more advantages or when I want to use it. 🤣

@minwoox minwoox modified the milestones: 0.68.0, 0.69.0 Jul 23, 2024
@minwoox minwoox merged commit 5912bf7 into line:main Aug 4, 2024
8 of 10 checks passed
@minwoox minwoox deleted the xds_application branch August 4, 2024 07:50
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.

3 participants