Skip to content

remove (the never released) tsh kube prefix matching#31852

Merged
GavinFrazar merged 5 commits intomasterfrom
gavinfrazar/tsh-kube-remove-prefix-matching
Sep 18, 2023
Merged

remove (the never released) tsh kube prefix matching#31852
GavinFrazar merged 5 commits intomasterfrom
gavinfrazar/tsh-kube-remove-prefix-matching

Conversation

@GavinFrazar
Copy link
Copy Markdown
Contributor

@GavinFrazar GavinFrazar commented Sep 14, 2023

Related tsh db ux issue: #31286

changelog: none

While fixing that tsh db ux issue, we decided to remove the prefix matching logic altogether and instead only match by either full name or the shortened "discovered name".

I already added the "discovered name" matching in #31744 yesterday.

So this PR removes the kube cluster prefix match logic as well.
Clusters are chosen only by name or by an unambiguous discovered name.

It also:

  • fixes retry with relogin when selected cluster is not found
  • fixes tsh kube login access request auto-retry to request only the specified cluster name/discovered name when --all, --labels, --query are not given.
    • it was requesting all of them before
    • also covered by test case now.
  • consolidates the test setup for login/proxy kube selection tests
  • adds more test cases for kube selection
  • removes the obsolete prefix match testing

@github-actions github-actions Bot added size/sm tsh tsh - Teleport's command line tool for logging into nodes running Teleport. labels Sep 14, 2023
* fix retry with relogin for ambiguous clusters
* fix access request func to only request specified cluster
* consolidate test setup for login/proxy kube selection tests
* add more test cases for kube selection
* remove prefix testing
@GavinFrazar GavinFrazar force-pushed the gavinfrazar/tsh-kube-remove-prefix-matching branch from 85a0567 to ebcd7f6 Compare September 14, 2023 01:04
Comment thread tool/tsh/common/kube.go Outdated
Comment thread tool/tsh/common/tsh_helper_test.go
@GavinFrazar
Copy link
Copy Markdown
Contributor Author

@zmb3 flaky test detector timed out after 10m on TestKubeSelection, can we skip it?

@zmb3
Copy link
Copy Markdown
Collaborator

zmb3 commented Sep 18, 2023

/excludeflake TestKubeSelection

@GavinFrazar GavinFrazar added this pull request to the merge queue Sep 18, 2023
Merged via the queue into master with commit 259d32f Sep 18, 2023
@GavinFrazar GavinFrazar deleted the gavinfrazar/tsh-kube-remove-prefix-matching branch September 18, 2023 17:44
@public-teleport-github-review-bot
Copy link
Copy Markdown

@GavinFrazar See the table below for backport results.

Branch Result
branch/v13 Failed
branch/v14 Failed

GavinFrazar added a commit that referenced this pull request Sep 18, 2023
backports #31852 to branch/v14.

* remove tsh kube prefix matching
* fix retry with relogin for ambiguous clusters
* fix access request func to only request specified cluster
* consolidate test setup for login/proxy kube selection tests
* add more test cases for kube selection
* remove prefix testing
* add origin cloud label in tests
* refactor the check for multiple cluster login into a func
GavinFrazar added a commit that referenced this pull request Sep 19, 2023
* fix retry with relogin for ambiguous clusters
* consolidate test setup for login/proxy kube selection tests
* add more test cases for kube selection
* remove prefix testing
* add origin cloud label in tests
* refactor the check for multiple cluster login into a func
GavinFrazar added a commit that referenced this pull request Sep 19, 2023
* fix retry with relogin for ambiguous clusters
* consolidate test setup for login/proxy kube selection tests
* add more test cases for kube selection
* remove prefix testing
* add origin cloud label in tests
* refactor the check for multiple cluster login into a func
github-merge-queue Bot pushed a commit that referenced this pull request Sep 19, 2023
* [v13] Fix Kubernetes selected cluster

backports #30167 to branch/v13.

* Fix Kubernetes selected cluster

Kubeconfig context name can be customized using `--set-context-name`
flag. When using it, the selected Kubernetes cluster fails to correctly
identify the cluster name.

* [v13] tsh kube login by prefix, query, labels (#32088)

backports #30252 to branch/v13.

* fetch kube clusters once for login

* [v13] update `tsh proxy kube` cluster selection ux (#32089)

backports #30478 to branch/v13.

* select by labels, query predicate, name, and/or prefix of name.
* fix --cluster flag not being propagated

* [v13] simplify tsh db prefix predicate logic (#32090)

backports #30531 to branch/v13.

* [v13] check for discovered kube cluster name exact match (#32091)

backports #31744 to branch/v13.

* [v13] rework tsh database selection logic (#32092)

backports #31689 to branch/v13.

* disallow prefix matching
* select by exact name match first,
* otherwise look for unambiguous discovered name label match.
* look for an active db to resolve discovered name match ambiguity.
* add more predicate builder helpers
* check for db name in not found error for stale cert hint
* no error status on tsh db logout with no logged in dbs
* remove dead code
* refactor helper funcs to simplify code and make it easier to test
* test complex database selection
* test findActiveDatabase
* test choosing one db by discovered name
* add more resource selectors tests
* test formatDatabaseLoginCommand
* add debug logging for db selection

* [v13] Fix `tsh kube login` when creds are expired or doesn't exist (#32095)

Backports #31418 to branch/v13.

This PR uses `client.RetryWithRelogin` helper to deal with cases where user's
credentials don't exist or are already expired.

Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>

* remove tsh kube prefix matching (#31852) (#32097)

* fix retry with relogin for ambiguous clusters
* consolidate test setup for login/proxy kube selection tests
* add more test cases for kube selection
* remove prefix testing
* add origin cloud label in tests
* refactor the check for multiple cluster login into a func

* [v13] remove prefix matching in tctl (#32104)

Backports #31916 to branch/v13.

* remove prefix matching in tctl
* replace prefix matching with exact discovered name match as a fallback
  when no resource full name matches the name given by a user
* refactor test helpers
* avoid decoding yaml/json into already initialized var

---------

Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>
@GavinFrazar GavinFrazar changed the title remove tsh kube prefix matching remove (not released) tsh kube prefix matching Sep 19, 2023
@GavinFrazar GavinFrazar changed the title remove (not released) tsh kube prefix matching remove (the never released) tsh kube prefix matching Sep 19, 2023
github-merge-queue Bot pushed a commit that referenced this pull request Sep 19, 2023
backports #31852 to branch/v14.

* remove tsh kube prefix matching
* fix retry with relogin for ambiguous clusters
* fix access request func to only request specified cluster
* consolidate test setup for login/proxy kube selection tests
* add more test cases for kube selection
* remove prefix testing
* add origin cloud label in tests
* refactor the check for multiple cluster login into a func
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kubernetes-access merge-for-v14 size/sm tsh tsh - Teleport's command line tool for logging into nodes running Teleport. ux

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants