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

differentiate discovered resource names #28845

Merged
merged 7 commits into from Jul 31, 2023

Conversation

GavinFrazar
Copy link
Contributor

@GavinFrazar GavinFrazar commented Jul 8, 2023

This PR implements discovery resource (database/kube cluster) renaming for RFD 129:

TODO followup PRs:

  • tsh kube/app UX updates
  • tctl UX update

Related issue:

Changelog: Teleport Discovery Service will automatically rename database and kube cluster resources to add a suffix consisting of additional distinguishing metadata. This change is intended to avoid resource name collisions where multiple resources have the same name across regions, accounts, clouds, etc.

@GavinFrazar GavinFrazar changed the base branch from master to gavinfrazar/tsh-resource-selection-ux July 8, 2023 07:37
@GavinFrazar GavinFrazar force-pushed the gavinfrazar/differentiate-discovered-databases branch 2 times, most recently from 36d881d to 7a0a16d Compare July 8, 2023 08:13
@GavinFrazar GavinFrazar force-pushed the gavinfrazar/tsh-resource-selection-ux branch from 88c5196 to 0abf7a0 Compare July 14, 2023 22:30
Base automatically changed from gavinfrazar/tsh-resource-selection-ux to master July 14, 2023 23:59
@GavinFrazar GavinFrazar force-pushed the gavinfrazar/differentiate-discovered-databases branch from 7a0a16d to e1d07b2 Compare July 15, 2023 04:30
@GavinFrazar GavinFrazar changed the base branch from master to gavinfrazar/move-discovery-added-labels-into-constants July 15, 2023 04:31
@GavinFrazar GavinFrazar force-pushed the gavinfrazar/differentiate-discovered-databases branch from e1d07b2 to 74271f7 Compare July 15, 2023 04:38
Base automatically changed from gavinfrazar/move-discovery-added-labels-into-constants to master July 18, 2023 18:35
@GavinFrazar GavinFrazar force-pushed the gavinfrazar/differentiate-discovered-databases branch from 74271f7 to 88d0c5c Compare July 19, 2023 00:01
@GavinFrazar GavinFrazar marked this pull request as ready for review July 19, 2023 00:01
@github-actions github-actions bot added database-access Database access related issues and PRs discovery size/md labels Jul 19, 2023
lib/cloud/clients.go Outdated Show resolved Hide resolved
lib/srv/discovery/common/renaming.go Show resolved Hide resolved
lib/srv/discovery/fetchers/db/aws.go Show resolved Hide resolved
lib/srv/discovery/fetchers/db/aws.go Show resolved Hide resolved
lib/srv/discovery/fetchers/db/aws.go Show resolved Hide resolved
@smallinsky smallinsky requested a review from greedy52 July 20, 2023 09:53
Copy link
Contributor

@greedy52 greedy52 left a comment

Choose a reason for hiding this comment

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

Left two comments but overall LGTM. And thanks for the refactor!

Comment on lines 37 to 42
suffix := makeAWSDiscoverySuffix(databaseNameValidator,
db.GetName(),
matcherType,
meta.Region,
meta.AccountID,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

does this guarantee the name is unique? For e.g. an RDS instance and an RDS aroura cluster with same name in same region, same account? Similarly, Azure Redis vs Azure Redis enterprise.

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, thanks for pointing this out!

For Azure: Redis vs Redis Enterprise names must be unique because of the way Azure sets up DNS. I double checked that Azure enforces this just now.
Redis: <name>.redis.cache.windows.net
SQL Server: <name>.database.windows.net
Postgres: <name.postgres.database.azure.com
MySQL: <name>.mysql.database.azure.com

After experimenting some more in aws console, within a region database instance name must be unique amongst other instances (regardless of whether mysql or postgres), and Aurora cluster name must be unique amongst clusters (regardless of whether mysql or postgres). Since we group these under the single matcher type "rds", it won't be guaranteed to be unique :( I'll have to figure out some way to handle this

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe Redis enterprise uses a different suffix:

Screenshot 2023-07-22 at 3 13 32 PM

// Redis (non-Enterprise) endpoint looks like this:
// name.redis.cache.windows.net
case strings.HasSuffix(host, RedisEndpointSuffix):
return strings.TrimSuffix(host, RedisEndpointSuffix), nil
// Redis Enterprise endpoint looks like this:
// name.region.redisenterprise.cache.azure.net
case strings.HasSuffix(host, RedisEnterpriseEndpointSuffix):

But regardless, we may have a problem when multiple fetchers share a matcher.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@greedy52 coming back to this:

We are already renaming Aurora cluster dbs with a suffix: -custom, or -reader, but we use the aurora cluster identifier as the first part of the name, not the individual instances' names.

Therefore, I think we just need to distinguish between cluster dbs and instance dbs to get (most likely) unique naming for RDS/Aurora dbs.

  • changed the suffix to use either rds or rds-aurora.

For Redis, I tested the naming incorrectly in Azure when I tried, you're right that the names can overlap:

  • changed the suffix to use eitherredis or redis-enterprise

The others are not an issue due to naming uniqueness rules in Azure. Even SQL server vs managed SQL instance.

commit: 09d6033

and 3163807

lib/srv/db/watcher_test.go Show resolved Hide resolved
lib/srv/discovery/fetchers/db/aws.go Show resolved Hide resolved
lib/srv/discovery/fetchers/db/db.go Show resolved Hide resolved
@rosstimothy rosstimothy removed their request for review July 25, 2023 19:04
@GavinFrazar GavinFrazar added this pull request to the merge queue Jul 31, 2023
Merged via the queue into master with commit 5c1d8d6 Jul 31, 2023
19 of 20 checks passed
@GavinFrazar GavinFrazar deleted the gavinfrazar/differentiate-discovered-databases branch July 31, 2023 18:08
@tigrato tigrato mentioned this pull request Aug 1, 2023
tigrato added a commit that referenced this pull request Aug 1, 2023
After merging #28845, the cluster name is different and the test failed.
Since the AWS E2E tests are not required, the merge happened and broke
all tests.

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
github-merge-queue bot pushed a commit that referenced this pull request Aug 1, 2023
After merging #28845, the cluster name is different and the test failed.
Since the AWS E2E tests are not required, the merge happened and broke
all tests.

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
@GavinFrazar
Copy link
Contributor Author

for future reference - a lot of the changes from this PR will be backported to make backporting other changes possible.

The renaming functionality itself is not being backported though, and only v14+ discovery service will rename discovered resources.

GavinFrazar added a commit that referenced this pull request Aug 16, 2023
* backport #28845 to branch/v13
* remove renaming of discovered resources for backport
github-merge-queue bot pushed a commit that referenced this pull request Sep 11, 2023
* backport #28845 to branch/v13
* remove renaming of discovered resources for backport

Co-authored-by: Gavin Frazar <gavin.frazar@goteleport.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database-access Database access related issues and PRs discovery size/md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants