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 conditional update methods for AccessList and AccessListMembers #40036

Merged
merged 4 commits into from
Apr 2, 2024

Conversation

tigrato
Copy link
Contributor

@tigrato tigrato commented Mar 29, 2024

This PR adds two new methods for conditionally update an AccessList and AccessListMember resources to avoid overriding changed resources.

This is a preparation for a ineligible status reconciler.

This PR adds two new methods for conditinally update an AccessList and
AccessListMember resources to avoid overriding changed resources.

This is a preparation for a ineligible status reconciler.

Signed-off-by: Tiago Silva <[email protected]>
@tigrato tigrato added backport/branch/v14 no-changelog Indicates that a PR does not require a changelog entry backport/branch/v15 labels Mar 29, 2024
@tigrato tigrato requested review from mdwn, tcsc and smallinsky March 29, 2024 16:54
@github-actions github-actions bot requested review from atburke and rosstimothy March 29, 2024 16:55
api/go.mod Outdated Show resolved Hide resolved
api/types/accesslist/member.go Outdated Show resolved Hide resolved
lib/services/simple/access_list.go Outdated Show resolved Hide resolved
Copy link
Contributor

@jakule jakule left a comment

Choose a reason for hiding this comment

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

Left a few comments + linter complains about formatting.

@@ -33,6 +33,8 @@ service AccessListService {
rpc GetAccessList(GetAccessListRequest) returns (AccessList);
// UpsertAccessList creates or updates an access list resource.
rpc UpsertAccessList(UpsertAccessListRequest) returns (AccessList);
// UpdateAccessList updates an access list resource.
rpc UpdateAccessList(UpdateAccessListRequest) returns (AccessList);
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the difference between update and upsert? Those two methods sound confusing when you want to modify an access list.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Upsert creates or unconditionally updates the access list - i,e. it doesn't care about revision. It will just replace whatever is in backend.

Update cares about revision and forces the revision to match before doing the update. If the revision doesn't match, it returns an error trace.CompareFailed

Copy link
Contributor

Choose a reason for hiding this comment

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

Update and Upsert are pretty standard RPCs for our resources. See RFD 153 for the semantics and expected behaviors.

lib/auth/api.go Show resolved Hide resolved
@@ -184,6 +184,44 @@ func (a *AccessListService) UpsertAccessList(ctx context.Context, accessList *ac
return upserted, nil
}

// UpdateAccessList updates an access list resource.
func (a *AccessListService) UpdateAccessList(ctx context.Context, accessList *accesslist.AccessList) (*accesslist.AccessList, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The body of this function is almost the same as UpsertAccessList. Creating a common implementation for both will make the maintenance simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will simplify

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in 854509c

@tigrato tigrato requested a review from jakule April 1, 2024 18:38
@tigrato tigrato force-pushed the tigrato/access-list-boilerplate branch from 854509c to 5cc5dfb Compare April 1, 2024 19:05
@tigrato tigrato added this pull request to the merge queue Apr 2, 2024
Merged via the queue into master with commit 8681546 Apr 2, 2024
39 checks passed
@tigrato tigrato deleted the tigrato/access-list-boilerplate branch April 2, 2024 17:10
@public-teleport-github-review-bot

@tigrato See the table below for backport results.

Branch Result
branch/v14 Failed
branch/v15 Failed

tigrato added a commit that referenced this pull request Apr 8, 2024
…s` (#40036)

* Add conditional update methods for `AccessList` and `AccessListMembers`

This PR adds two new methods for conditinally update an AccessList and
AccessListMember resources to avoid overriding changed resources.

This is a preparation for a ineligible status reconciler.

Signed-off-by: Tiago Silva <[email protected]>

* Update lib/services/simple/access_list.go

Co-authored-by: rosstimothy <[email protected]>

* handle review comments and drop copy methods

* simplify code

---------

Signed-off-by: Tiago Silva <[email protected]>
Co-authored-by: rosstimothy <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Apr 9, 2024
…s` (#40036) (#40317)

* Add conditional update methods for `AccessList` and `AccessListMembers`

This PR adds two new methods for conditinally update an AccessList and
AccessListMember resources to avoid overriding changed resources.

This is a preparation for a ineligible status reconciler.



* Update lib/services/simple/access_list.go



* handle review comments and drop copy methods

* simplify code

---------

Signed-off-by: Tiago Silva <[email protected]>
Co-authored-by: rosstimothy <[email protected]>
tigrato added a commit that referenced this pull request Apr 9, 2024
…s` (#40036)

* Add conditional update methods for `AccessList` and `AccessListMembers`

This PR adds two new methods for conditinally update an AccessList and
AccessListMember resources to avoid overriding changed resources.

This is a preparation for a ineligible status reconciler.

Signed-off-by: Tiago Silva <[email protected]>

* Update lib/services/simple/access_list.go

Co-authored-by: rosstimothy <[email protected]>

* handle review comments and drop copy methods

* simplify code

---------

Signed-off-by: Tiago Silva <[email protected]>
Co-authored-by: rosstimothy <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Apr 10, 2024
…s` (#40036) (#40318)

* Add conditional update methods for `AccessList` and `AccessListMembers`

This PR adds two new methods for conditinally update an AccessList and
AccessListMember resources to avoid overriding changed resources.

This is a preparation for a ineligible status reconciler.



* Update lib/services/simple/access_list.go



* handle review comments and drop copy methods

* simplify code

---------

Signed-off-by: Tiago Silva <[email protected]>
Co-authored-by: rosstimothy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v14 backport/branch/v15 no-changelog Indicates that a PR does not require a changelog entry size/md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants