Skip to content

Remove assigning by default first alphabetical kube cluster to a user.#37242

Merged
AntonAM merged 7 commits intomasterfrom
anton/remove-default-kube-cluster
Jan 29, 2024
Merged

Remove assigning by default first alphabetical kube cluster to a user.#37242
AntonAM merged 7 commits intomasterfrom
anton/remove-default-kube-cluster

Conversation

@AntonAM
Copy link
Copy Markdown
Contributor

@AntonAM AntonAM commented Jan 25, 2024

As a leftover of initial kube access implementation, we were setting first alphabetical kube cluster to a user's certificate, even if they didn't have access to it. It lead to unnecessary leaking of a name of existing kube cluster. This PR removes assignment of a default cluster and we only check if specified cluster is available. Also removes redundant check from kube forwarder, since kube cluster name should never be empty there (and kube cluster presence is checked further in the code).

Changelog: Do not add alphabetically first Kube cluster's name to a user certificate on login.

Fixes https://github.com/gravitational/teleport-private/issues/1319

@AntonAM AntonAM force-pushed the anton/remove-default-kube-cluster branch 3 times, most recently from 2503915 to f43e781 Compare January 25, 2024 08:09
@AntonAM AntonAM requested a review from tigrato January 25, 2024 08:10
@AntonAM AntonAM marked this pull request as ready for review January 25, 2024 08:10
@github-actions github-actions Bot requested review from kimlisa and lxea January 25, 2024 08:10
@github-actions github-actions Bot added size/sm tctl tctl - Teleport admin tool labels Jan 25, 2024
Copy link
Copy Markdown
Contributor

@tigrato tigrato left a comment

Choose a reason for hiding this comment

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

This looks good to me.
Did you tested with legacy kubernetes proxy?

Comment thread lib/auth/auth.go Outdated
Comment thread lib/auth/auth_test.go
Comment thread lib/kube/proxy/forwarder.go Outdated
@@ -740,21 +739,6 @@ func (f *Forwarder) setupContext(
}

kubeCluster := identity.KubernetesCluster
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.

this block can move the the var now that's not used anymore

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.

It's still useful as a shorthand, since it's used several times down the code.

@AntonAM AntonAM force-pushed the anton/remove-default-kube-cluster branch from 0e9258f to 6484994 Compare January 25, 2024 20:10
Comment thread e2e/aws/eks_test.go Outdated
Comment thread e2e/aws/eks_test.go Outdated
Comment thread lib/auth/auth_test.go Outdated
Comment thread lib/auth/auth_test.go Outdated
Comment thread lib/kube/utils/utils.go Outdated
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.

Suggested change
return trace.BadParameter("Kubernetes cluster %q is not registered in this teleport cluster; you can list registered kubernetes clusters using 'tsh kube ls'", kubeClusterName)
return trace.BadParameter("kubernetes cluster %q is not registered in this teleport cluster; you can list registered kubernetes clusters using 'tsh kube ls'", kubeClusterName)

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.

In this case it's capitalization of a proper name.

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.

How come we aren't capitalizing Kubernetes the second time it appears in the message then?

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.

Oh, we should. 😅 I moved the error and didn't notice it had second usage down the text. Fixed.

Comment thread lib/kube/utils/utils_test.go Outdated
@AntonAM AntonAM force-pushed the anton/remove-default-kube-cluster branch from 6484994 to 33e61ff Compare January 25, 2024 21:03
@kimlisa kimlisa removed their request for review January 26, 2024 03:45
@AntonAM AntonAM force-pushed the anton/remove-default-kube-cluster branch 3 times, most recently from 33ef58e to cad4924 Compare January 26, 2024 05:19
@AntonAM
Copy link
Copy Markdown
Contributor Author

AntonAM commented Jan 26, 2024

@tigrato yep, I tried with legacy kube proxy config and it works.

@AntonAM
Copy link
Copy Markdown
Contributor Author

AntonAM commented Jan 26, 2024

Flaky test detector is failing because of 10 minutes timeout.

@AntonAM AntonAM force-pushed the anton/remove-default-kube-cluster branch from bdf1f39 to 0b9d5b8 Compare January 26, 2024 18:52
Comment thread tool/tctl/common/auth_command_test.go Outdated
Comment thread lib/kube/proxy/forwarder.go Outdated
@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from lxea January 29, 2024 09:29
AntonAM and others added 6 commits January 29, 2024 14:50
Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
@AntonAM AntonAM force-pushed the anton/remove-default-kube-cluster branch from 97ef1f1 to f9f4bfc Compare January 29, 2024 19:50
@AntonAM
Copy link
Copy Markdown
Contributor Author

AntonAM commented Jan 29, 2024

@r0mant @zmb3 can I get a flaky tests skip? It always gets timeout.

@zmb3
Copy link
Copy Markdown
Collaborator

zmb3 commented Jan 29, 2024

/excludeflake *

@AntonAM AntonAM enabled auto-merge January 29, 2024 20:47
@AntonAM AntonAM added this pull request to the merge queue Jan 29, 2024
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jan 29, 2024
@AntonAM AntonAM added this pull request to the merge queue Jan 29, 2024
Merged via the queue into master with commit a576cb2 Jan 29, 2024
@AntonAM AntonAM deleted the anton/remove-default-kube-cluster branch January 29, 2024 23:08
@public-teleport-github-review-bot
Copy link
Copy Markdown

@AntonAM See the table below for backport results.

Branch Result
branch/v13 Failed
branch/v14 Failed
branch/v15 Create PR

AntonAM added a commit that referenced this pull request Jan 30, 2024
#37242)

* Remove assigning by default first alphabetical kube cluster to a user.

* Fix tests.

* Address review comments

* Fix tests.

* Fix error message.

* Use default value.

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

* Fix error message.

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
AntonAM added a commit that referenced this pull request Jan 30, 2024
#37242)

* Remove assigning by default first alphabetical kube cluster to a user.

* Fix tests.

* Address review comments

* Fix tests.

* Fix error message.

* Use default value.

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

* Fix error message.

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
github-merge-queue Bot pushed a commit that referenced this pull request Jan 30, 2024
#37242) (#37503)

* Remove assigning by default first alphabetical kube cluster to a user.

* Fix tests.

* Address review comments

* Fix tests.

* Fix error message.

* Use default value.



* Fix error message.



---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
github-merge-queue Bot pushed a commit that referenced this pull request Jan 30, 2024
#37242) (#37501)

* Remove assigning by default first alphabetical kube cluster to a user.

* Fix tests.

* Address review comments

* Fix tests.

* Fix error message.

* Use default value.



* Fix error message.



---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kubernetes-access size/sm tctl tctl - Teleport admin tool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants