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

Issue transfer ownership of service user #2393

Merged
merged 6 commits into from
Apr 4, 2024

Conversation

aindriu-aiven
Copy link
Contributor

@aindriu-aiven aindriu-aiven commented Apr 3, 2024

When claiming an ACL transfer the ownership of the service user to the new account.
If the existing team no longer has any acls with that service user remove it from their service user accounts.

What kind of change does this PR introduce?

  • Bug fix
  • New feature
  • Refactor
  • Docs update
  • CI update

What is the current behavior?

Describe the state of the application before this PR. Illustrations appreciated (videos, gifs, screenshots).

What is the new behavior?

Describe the state of the application after this PR. Illustrations appreciated (videos, gifs, screenshots).

Other information

Additional changes, explanations of the approach taken, unresolved issues, necessary follow ups, etc.

Requirements (all must be checked before review)

  • The pull request title follows our guidelines
  • Tests for the changes have been added (if relevant)
  • The latest changes from the main branch have been pulled
  • pnpm lint has been run successfully

Signed-off-by: Aindriu Lavelle <aindriu.lavelle@aiven.io>
Signed-off-by: Aindriu Lavelle <aindriu.lavelle@aiven.io>
@@ -44,6 +44,12 @@ boolean existsByTeamIdNotAndTenantIdAndConsumergroup(
boolean existsByEnvironmentAndTenantId(
@Param("envId") String envId, @Param("tenantId") Integer tenantId);

@Query(
value =
"select count(*) > 0 from kwacls where teamid = :teamId and tenantid = :tenantId and aclssl = :aclSsl",
Copy link
Contributor

Choose a reason for hiding this comment

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

could be better to use a jpa instead of native here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah thats what I wanted to do but we have a limitation with JPA.
Unfortunately acl_ssl in the aclRequest prevents us from using the JPA, I can refactor this in 2.10.0 was my plan though.
(The underscore in the variable name is not supported to be specific )

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we try this way, or may be in future

@column(name = "municipal_id", nullable = false)
private Integer municipalId; // <-- field was renamed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this is the way to fix it.
in AclRequests
@column(name = "aclssl")
private String acl_ssl; -> private String aclSsl;

I was going to leave it till a future PR but I can include in this one and then use JPA

Copy link
Contributor

Choose a reason for hiding this comment

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

But this rename leads to several changes. Lets try in 2.10

@Aiven-Open Aiven-Open deleted a comment from aindriu-aiven Apr 4, 2024
…wnership of a service account.

Signed-off-by: Aindriu Lavelle <aindriu.lavelle@aiven.io>
…m the team

Signed-off-by: Aindriu Lavelle <aindriu.lavelle@aiven.io>
// Update team with service account
manageDatabase.getHandleDbRequests().updateTeam(optionalTeam.get());
commonUtilsService.updateMetadata(
tenantId, EntityType.TEAM, MetadataOperationType.UPDATE, null);
}
}

private void removeServiceAccountOnTransferOfOwnership(AclRequests aclRequest, int tenantId) {
if (Objects.equals(RequestOperationType.CLAIM.value, aclRequest.getRequestOperationType())) {
if (manageDatabase
Copy link
Contributor

Choose a reason for hiding this comment

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

how about moving this condition to a higher level ? So transfer (remove/add) only for this condition.

if (!manageDatabase
.getHandleDbRequests()
.existsAclSslInTeam(
aclRequest.getTeamId(), aclRequest.getTenantId(), aclRequest.getAcl_ssl())) {
// Team still has other Acls left with service user so do not remove from here.
transferServiceUserOwnership(aclReq);
}

Copy link
Contributor

@muralibasani muralibasani left a comment

Choose a reason for hiding this comment

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

Tested, looks good.

@aindriu-aiven aindriu-aiven merged commit ed8e8f0 into main Apr 4, 2024
24 checks passed
@aindriu-aiven aindriu-aiven deleted the issue-transfer-ownership-of-service-user branch April 4, 2024 13:20
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