Skip to content

Connect: return logged in user in ListRootClusters#20809

Merged
gzdunek merged 11 commits into
masterfrom
gzdunek/fix-logged-in-user-in-list-clusters
Feb 8, 2023
Merged

Connect: return logged in user in ListRootClusters#20809
gzdunek merged 11 commits into
masterfrom
gzdunek/fix-logged-in-user-in-list-clusters

Conversation

@gzdunek
Copy link
Copy Markdown
Contributor

@gzdunek gzdunek commented Jan 27, 2023

Closes #20670

This PR adds two integration tests for Connect RPC service to make sure we will not break it accidentally in the future.

To fix the actual issue, I add new cluster type ClusterWithDetails. It is quite similar to the struct that Michael introduced here, but then it was replaced with enriching the Cluster struct during the review.
IMO having one type that is enriched with some methods is problematic. You can't easily tell which fields are available and which are not.
I'm not 100% happy with having RequestableRoles and SuggestedReviewers directly in ClusterWithDetails, but I didn't want to complicate it by adding another UserDetails (?) struct. We can do it later when we have more fields.

@gzdunek gzdunek requested review from avatus and ravicious January 27, 2023 12:10
@github-actions github-actions Bot requested a review from lxea January 27, 2023 12:10
config.Auth.NetworkingConfig.SetProxyListenerMode(types.ProxyListenerMode_Multiplex)
}),
)
pack.WaitForLeaf(t)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TODO: remove leaf cluster

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's skip that. I was thinking about it but sooner or later we'll need a test which needs a leaf cluster anyway and so far no other test suite would benefit from being able to skip setting up a leaf cluster (AFAIR).

apiCluster := newAPIRootCluster(cluster.Cluster)

// Only include if they exist on the supplied cluster
if cluster.Features != nil {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think we can get rid of this if now?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yeah seems appropriate now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed

@gzdunek gzdunek changed the title Return logged in user in ListRootClusters Connect: return logged in user in ListRootClusters Jan 27, 2023
@ravicious
Copy link
Copy Markdown
Member

To fix the actual issue, I add new cluster type ClusterWithDetails. It is quite similar to the struct that Michael introduced here, but then it was replaced with enriching the Cluster struct during the review.
IMO having one type that is enriched with some methods is problematic. You can't easily tell which fields are available and which are not.

We had a discussion about it here: #17497 (comment)

@gzdunek
Copy link
Copy Markdown
Contributor Author

gzdunek commented Jan 27, 2023

Thanks for the link, I completely forgot about it.
The discussion there was also about the RPC API which remained unchanged here (I added only a new struct for our "internal" API). Also at that time we had only one optional field and now we have 4 😏. Because of this, it seemed to me that adding a new type made more sense.
But I'm fine with removing the new struct; I'm only wondering where to put suggestedReviewers and requestableRoles (as loggedInUser is quite confusing).

Copy link
Copy Markdown
Contributor

@avatus avatus left a comment

Choose a reason for hiding this comment

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

This is fine and was another option to do it this way originally. I think your logic makes sense that we were adding a few more fields. Honestly, this kind of just comes down to dev preference at this point. I'm ok with it either way and must admit, it's a bit neater/cleaner this way.

apiCluster := newAPIRootCluster(cluster.Cluster)

// Only include if they exist on the supplied cluster
if cluster.Features != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yeah seems appropriate now

Copy link
Copy Markdown
Member

@ravicious ravicious left a comment

Choose a reason for hiding this comment

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

I like the new approach, I left some comments mostly related to code comments and small improvements in tests.

Comment thread lib/teleterm/daemon/daemon.go Outdated
Comment thread lib/teleterm/clusters/cluster.go Outdated
Comment thread lib/teleterm/clusters/cluster.go Outdated
Comment thread integration/teleterm_test.go Outdated
Comment thread integration/teleterm_test.go Outdated
Comment thread integration/teleterm_test.go Outdated
Comment thread integration/teleterm_test.go Outdated
Comment thread integration/teleterm_test.go Outdated
Comment thread lib/teleterm/clusters/cluster.go Outdated
Comment thread integration/teleterm_test.go Outdated
Copy link
Copy Markdown
Member

@ravicious ravicious left a comment

Choose a reason for hiding this comment

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

We should probably backport it to v11 too, don't we? In theory it fixes a "bug" that was introduced in v11.

@gzdunek
Copy link
Copy Markdown
Contributor Author

gzdunek commented Feb 8, 2023

@avatus or @lxea ping :)

@avatus
Copy link
Copy Markdown
Contributor

avatus commented Feb 8, 2023

I'm sorry, I thought I approved this last week. Looks awesome

@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from lxea February 8, 2023 16:45
@gzdunek gzdunek added this pull request to the merge queue Feb 8, 2023
Merged via the queue into master with commit 7ed92c1 Feb 8, 2023
@public-teleport-github-review-bot
Copy link
Copy Markdown

@gzdunek See the table below for backport results.

Branch Result
branch/v11 Failed
branch/v12 Create PR

gzdunek added a commit that referenced this pull request Feb 9, 2023
* Add integration/teleterm_test with tests for get* and list* clusters

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>

* Move `testAddingRootCluster to integration/teleterm_test

* Add `ClusterWithDetails` type instead of enriching existing `Cluster` with optional properties

* Remove unnecessary condition

* Add license

* Bunch of renames

* Do more in mustLogin

* Remove watcher

---------

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>

(cherry picked from commit 7ed92c1)
avatus pushed a commit that referenced this pull request Mar 3, 2023
* Add integration/teleterm_test with tests for get* and list* clusters

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>

* Move `testAddingRootCluster to integration/teleterm_test

* Add `ClusterWithDetails` type instead of enriching existing `Cluster` with optional properties

* Remove unnecessary condition

* Add license

* Bunch of renames

* Do more in mustLogin

* Remove watcher

---------

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>
@gzdunek gzdunek deleted the gzdunek/fix-logged-in-user-in-list-clusters branch March 20, 2023 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Connect: ListRootClusters RPC does not return LoggedInUser

3 participants