diff --git a/lib/auth/auth_with_roles_test.go b/lib/auth/auth_with_roles_test.go index 9b490fc98cc0b..a20749aa93977 100644 --- a/lib/auth/auth_with_roles_test.go +++ b/lib/auth/auth_with_roles_test.go @@ -1920,6 +1920,7 @@ func TestKubernetesClusterCRUD_DiscoveryService(t *testing.T) { Status: aws.String(eks.ClusterStatusActive), }) require.NoError(t, err) + eksCluster.SetOrigin(types.OriginCloud) // Discovery service must not have access to non-cloud cluster (cluster // without "cloud" origin label). @@ -1939,6 +1940,7 @@ func TestKubernetesClusterCRUD_DiscoveryService(t *testing.T) { Status: aws.String(eks.ClusterStatusActive), }) require.NoError(t, err) + clusterWithDynamicLabels.SetOrigin(types.OriginCloud) clusterWithDynamicLabels.SetDynamicLabels(map[string]types.CommandLabel{ "hostname": &types.CommandLabelV2{ Period: types.Duration(time.Hour), @@ -1954,7 +1956,7 @@ func TestKubernetesClusterCRUD_DiscoveryService(t *testing.T) { t.Run("Read", func(t *testing.T) { clusters, err := discoveryClt.GetKubernetesClusters(ctx) require.NoError(t, err) - require.Equal(t, clusters, []types.KubeCluster{eksCluster}) + require.Empty(t, cmp.Diff([]types.KubeCluster{eksCluster}, clusters)) }) t.Run("Update", func(t *testing.T) { require.NoError(t, discoveryClt.UpdateKubernetesCluster(ctx, eksCluster)) diff --git a/lib/integrations/awsoidc/listdatabases_test.go b/lib/integrations/awsoidc/listdatabases_test.go index c4f3d3927ba7d..6c76925975a36 100644 --- a/lib/integrations/awsoidc/listdatabases_test.go +++ b/lib/integrations/awsoidc/listdatabases_test.go @@ -188,14 +188,13 @@ func TestListDatabases(t *testing.T) { Name: "my-db", Description: "RDS instance in ", Labels: map[string]string{ - "account-id": "123456789012", - "endpoint-type": "instance", - "engine": "postgres", - "engine-version": "", - "region": "", - "status": "available", - "teleport.dev/cloud": "AWS", - "teleport.dev/origin": "cloud", + "account-id": "123456789012", + "endpoint-type": "instance", + "engine": "postgres", + "engine-version": "", + "region": "", + "status": "available", + "teleport.dev/cloud": "AWS", }, }, types.DatabaseSpecV3{ @@ -253,14 +252,13 @@ func TestListDatabases(t *testing.T) { Name: "my-db", Description: "RDS instance in ", Labels: map[string]string{ - "account-id": "123456789012", - "endpoint-type": "instance", - "engine": "postgres", - "engine-version": "", - "region": "", - "status": "available", - "teleport.dev/cloud": "AWS", - "teleport.dev/origin": "cloud", + "account-id": "123456789012", + "endpoint-type": "instance", + "engine": "postgres", + "engine-version": "", + "region": "", + "status": "available", + "teleport.dev/cloud": "AWS", }, }, types.DatabaseSpecV3{ @@ -305,14 +303,13 @@ func TestListDatabases(t *testing.T) { Name: "my-dbc", Description: "Aurora cluster in ", Labels: map[string]string{ - "account-id": "123456789012", - "endpoint-type": "primary", - "engine": "aurora-postgresql", - "engine-version": "", - "region": "", - "status": "available", - "teleport.dev/cloud": "AWS", - "teleport.dev/origin": "cloud", + "account-id": "123456789012", + "endpoint-type": "primary", + "engine": "aurora-postgresql", + "engine-version": "", + "region": "", + "status": "available", + "teleport.dev/cloud": "AWS", }, }, types.DatabaseSpecV3{ diff --git a/lib/services/database.go b/lib/services/database.go index cb5e15d95ef78..f91e94a1a70d9 100644 --- a/lib/services/database.go +++ b/lib/services/database.go @@ -1540,7 +1540,6 @@ func labelsFromAWSMetadata(meta *types.AWS) map[string]string { labels[types.DiscoveryLabelAccountID] = meta.AccountID labels[types.DiscoveryLabelRegion] = meta.Region } - labels[types.OriginLabel] = types.OriginCloud labels[types.CloudLabel] = types.CloudAWS return labels } @@ -1561,7 +1560,6 @@ func labelsFromMetaAndEndpointType(meta *types.AWS, endpointType string, extraLa // azureTagsToLabels converts Azure tags to a labels map. func azureTagsToLabels(tags map[string]string) map[string]string { labels := make(map[string]string) - labels[types.OriginLabel] = types.OriginCloud labels[types.CloudLabel] = types.CloudAzure return addLabels(labels, tags) } diff --git a/lib/services/database_test.go b/lib/services/database_test.go index 40eeca989b29f..d1b9e4c0bf386 100644 --- a/lib/services/database_test.go +++ b/lib/services/database_test.go @@ -547,7 +547,6 @@ func TestDatabaseFromAzureDBServer(t *testing.T) { types.DiscoveryLabelEngine: "Microsoft.DBforMySQL/servers", types.DiscoveryLabelEngineVersion: "5.7", types.DiscoveryLabelAzureResourceGroup: "defaultRG", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAzure, types.DiscoveryLabelAzureSubscriptionID: "sub1", "foo": "bar", @@ -596,7 +595,6 @@ func TestDatabaseFromAzureRedis(t *testing.T) { types.DiscoveryLabelEngine: "Microsoft.Cache/Redis", types.DiscoveryLabelEngineVersion: "6.0", types.DiscoveryLabelAzureResourceGroup: group, - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAzure, types.DiscoveryLabelAzureSubscriptionID: subscription, "foo": "bar", @@ -655,7 +653,6 @@ func TestDatabaseFromAzureRedisEnterprise(t *testing.T) { types.DiscoveryLabelEngine: "Microsoft.Cache/redisEnterprise", types.DiscoveryLabelEngineVersion: "6.0", types.DiscoveryLabelAzureResourceGroup: group, - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAzure, types.DiscoveryLabelAzureSubscriptionID: subscription, types.DiscoveryLabelEndpointType: "OSSCluster", @@ -703,7 +700,6 @@ func TestDatabaseFromRDSInstance(t *testing.T) { Description: "RDS instance in us-west-1", Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "us-west-1", types.DiscoveryLabelEngine: RDSEnginePostgres, @@ -764,7 +760,6 @@ func TestDatabaseFromRDSV2Instance(t *testing.T) { Description: "RDS instance in us-west-1", Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "us-west-1", types.DiscoveryLabelEngine: RDSEnginePostgres, @@ -842,7 +837,6 @@ func TestDatabaseFromRDSInstanceNameOverride(t *testing.T) { Description: "RDS instance in us-west-1", Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "us-west-1", types.DiscoveryLabelEngine: RDSEnginePostgres, @@ -911,7 +905,6 @@ func TestDatabaseFromRDSCluster(t *testing.T) { Description: "Aurora cluster in us-east-1", Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "us-east-1", types.DiscoveryLabelEngine: RDSEngineAuroraMySQL, @@ -936,7 +929,6 @@ func TestDatabaseFromRDSCluster(t *testing.T) { Description: "Aurora cluster in us-east-1 (reader endpoint)", Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "us-east-1", types.DiscoveryLabelEngine: RDSEngineAuroraMySQL, @@ -958,7 +950,6 @@ func TestDatabaseFromRDSCluster(t *testing.T) { t.Run("custom endpoints", func(t *testing.T) { expectedLabels := map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "us-east-1", types.DiscoveryLabelEngine: RDSEngineAuroraMySQL, @@ -1051,7 +1042,6 @@ func TestDatabaseFromRDSV2Cluster(t *testing.T) { Description: "Aurora cluster in us-east-1", Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "us-east-1", types.DiscoveryLabelEngine: RDSEngineAuroraMySQL, @@ -1129,7 +1119,6 @@ func TestDatabaseFromRDSClusterNameOverride(t *testing.T) { Description: "Aurora cluster in us-east-1", Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "us-east-1", types.DiscoveryLabelEngine: RDSEngineAuroraMySQL, @@ -1155,7 +1144,6 @@ func TestDatabaseFromRDSClusterNameOverride(t *testing.T) { Description: "Aurora cluster in us-east-1 (reader endpoint)", Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "us-east-1", types.DiscoveryLabelEngine: RDSEngineAuroraMySQL, @@ -1178,7 +1166,6 @@ func TestDatabaseFromRDSClusterNameOverride(t *testing.T) { t.Run("custom endpoints", func(t *testing.T) { expectedLabels := map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "us-east-1", types.DiscoveryLabelEngine: RDSEngineAuroraMySQL, @@ -1263,7 +1250,6 @@ func TestDatabaseFromRDSProxy(t *testing.T) { Labels: map[string]string{ "key": "val", types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "ca-central-1", types.DiscoveryLabelEngine: "MYSQL", @@ -1295,7 +1281,6 @@ func TestDatabaseFromRDSProxy(t *testing.T) { Labels: map[string]string{ "key": "val", types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "ca-central-1", types.DiscoveryLabelEngine: "MYSQL", @@ -1458,11 +1443,10 @@ func TestAzureTagsToLabels(t *testing.T) { } labels := azureTagsToLabels(azureTags) wantLabels := map[string]string{ - "Name": "test", - "Env": "dev", - "foo:bar": "some-id", - types.OriginLabel: types.OriginCloud, - types.CloudLabel: types.CloudAzure, + "Name": "test", + "Env": "dev", + "foo:bar": "some-id", + types.CloudLabel: types.CloudAzure, } require.Equal(t, wantLabels, labels) } @@ -1493,7 +1477,6 @@ func TestDatabaseFromRedshiftCluster(t *testing.T) { Description: "Redshift cluster in us-east-1", Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "us-east-1", "key": "val", @@ -1547,7 +1530,6 @@ func TestDatabaseFromRedshiftCluster(t *testing.T) { Description: "Redshift cluster in us-east-1", Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "us-east-1", overrideLabel: "mycluster-override-2", @@ -1627,7 +1609,6 @@ func TestDatabaseFromElastiCacheConfigurationEndpoint(t *testing.T) { Description: "ElastiCache cluster in us-east-1 (configuration endpoint)", Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "us-east-1", types.DiscoveryLabelEndpointType: "configuration", @@ -1703,7 +1684,6 @@ func TestDatabaseFromElastiCacheConfigurationEndpointNameOverride(t *testing.T) Description: "ElastiCache cluster in us-east-1 (configuration endpoint)", Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "us-east-1", types.DiscoveryLabelEndpointType: "configuration", @@ -1762,7 +1742,6 @@ func TestDatabaseFromElastiCacheNodeGroups(t *testing.T) { Description: "ElastiCache cluster in us-east-1 (primary endpoint)", Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "us-east-1", types.DiscoveryLabelEndpointType: "primary", @@ -1789,7 +1768,6 @@ func TestDatabaseFromElastiCacheNodeGroups(t *testing.T) { Description: "ElastiCache cluster in us-east-1 (reader endpoint)", Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "us-east-1", types.DiscoveryLabelEndpointType: "reader", @@ -1850,7 +1828,6 @@ func TestDatabaseFromElastiCacheNodeGroupsNameOverride(t *testing.T) { Description: "ElastiCache cluster in us-east-1 (primary endpoint)", Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "us-east-1", types.DiscoveryLabelEndpointType: "primary", @@ -1878,7 +1855,6 @@ func TestDatabaseFromElastiCacheNodeGroupsNameOverride(t *testing.T) { Description: "ElastiCache cluster in us-east-1 (reader endpoint)", Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "us-east-1", types.DiscoveryLabelEndpointType: "reader", @@ -1927,7 +1903,6 @@ func TestDatabaseFromMemoryDBCluster(t *testing.T) { Description: "MemoryDB cluster in us-east-1", Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "us-east-1", types.DiscoveryLabelEndpointType: "cluster", @@ -1962,7 +1937,6 @@ func TestDatabaseFromRedshiftServerlessWorkgroup(t *testing.T) { Description: "Redshift Serverless workgroup in eu-west-2", Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "eu-west-2", types.DiscoveryLabelEndpointType: "workgroup", @@ -1998,7 +1972,6 @@ func TestDatabaseFromRedshiftServerlessVPCEndpoint(t *testing.T) { Description: "Redshift Serverless endpoint in eu-west-2", Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "eu-west-2", types.DiscoveryLabelEndpointType: "vpc-endpoint", @@ -2054,7 +2027,6 @@ func TestDatabaseFromMemoryDBClusterNameOverride(t *testing.T) { Description: "MemoryDB cluster in us-east-1", Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, types.DiscoveryLabelRegion: "us-east-1", types.DiscoveryLabelEndpointType: "cluster", @@ -2448,7 +2420,6 @@ func TestDatabaseFromAzureMySQLFlexServer(t *testing.T) { types.DiscoveryLabelEngine: provider, types.DiscoveryLabelEngineVersion: "8.0.21", types.DiscoveryLabelAzureResourceGroup: group, - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAzure, types.DiscoveryLabelAzureSubscriptionID: subID, "foo": "bar", @@ -2525,7 +2496,6 @@ func TestDatabaseFromAzurePostgresFlexServer(t *testing.T) { types.DiscoveryLabelEngine: provider, types.DiscoveryLabelEngineVersion: "14", types.DiscoveryLabelAzureResourceGroup: group, - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAzure, types.DiscoveryLabelAzureSubscriptionID: subID, "foo": "bar", @@ -2623,7 +2593,6 @@ func TestMakeAzureDatabaseLoginUsername(t *testing.T) { types.DiscoveryLabelEngine: tt.engine, types.DiscoveryLabelEngineVersion: "1.2.3", types.DiscoveryLabelAzureResourceGroup: group, - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAzure, types.DiscoveryLabelAzureSubscriptionID: subID, "foo": "bar", diff --git a/lib/services/kubernetes.go b/lib/services/kubernetes.go index b9a16460cad71..8e00113a9b8fb 100644 --- a/lib/services/kubernetes.go +++ b/lib/services/kubernetes.go @@ -219,7 +219,6 @@ func NewKubeClusterFromAzureAKS(cluster *azure.AKSCluster) (types.KubeCluster, e // labelsFromAzureKubeCluster creates kube cluster labels. func labelsFromAzureKubeCluster(cluster *azure.AKSCluster) map[string]string { labels := azureTagsToLabels(cluster.Tags) - labels[types.OriginLabel] = types.OriginCloud labels[types.CloudLabel] = types.CloudAzure labels[types.DiscoveryLabelRegion] = cluster.Location @@ -258,7 +257,6 @@ func getOrSetDefaultGCPDescription(cluster gcp.GKECluster) string { // labelsFromGCPKubeCluster creates kube cluster labels. func labelsFromGCPKubeCluster(cluster gcp.GKECluster) map[string]string { labels := maps.Clone(cluster.Labels) - labels[types.OriginLabel] = types.OriginCloud labels[types.CloudLabel] = types.CloudGCP labels[types.DiscoveryLabelGCPLocation] = cluster.Location @@ -293,7 +291,6 @@ func NewKubeClusterFromAWSEKS(cluster *eks.Cluster) (types.KubeCluster, error) { // labelsFromAWSKubeCluster creates kube cluster labels. func labelsFromAWSKubeCluster(cluster *eks.Cluster, parsedARN arn.ARN) map[string]string { labels := awsEKSTagsToLabels(cluster.Tags) - labels[types.OriginLabel] = types.OriginCloud labels[types.CloudLabel] = types.CloudAWS labels[types.DiscoveryLabelRegion] = parsedARN.Region diff --git a/lib/services/kubernetes_test.go b/lib/services/kubernetes_test.go index eaed30dc3b36c..9313963f85abe 100644 --- a/lib/services/kubernetes_test.go +++ b/lib/services/kubernetes_test.go @@ -92,7 +92,6 @@ func TestNewKubeClusterFromAWSEKS(t *testing.T) { Labels: map[string]string{ types.DiscoveryLabelAccountID: "123456789012", types.DiscoveryLabelRegion: "eu-west-1", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAWS, overrideLabel: "override-1", "env": "prod", @@ -135,7 +134,6 @@ func TestNewKubeClusterFromAzureAKS(t *testing.T) { types.DiscoveryLabelRegion: "uswest1", types.DiscoveryLabelAzureResourceGroup: "group1", types.DiscoveryLabelAzureSubscriptionID: "subID", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudAzure, overrideLabel: "override-1", "env": "prod", @@ -179,7 +177,6 @@ func TestNewKubeClusterFromGCPGKE(t *testing.T) { Labels: map[string]string{ types.DiscoveryLabelGCPLocation: "central-1", types.DiscoveryLabelGCPProjectID: "p1", - types.OriginLabel: types.OriginCloud, types.CloudLabel: types.CloudGCP, overrideLabel: "override-1", "env": "prod", diff --git a/lib/srv/discovery/common/watcher.go b/lib/srv/discovery/common/watcher.go index 858431377d316..858e5b9a6d310 100644 --- a/lib/srv/discovery/common/watcher.go +++ b/lib/srv/discovery/common/watcher.go @@ -148,6 +148,7 @@ func (w *Watcher) fetchAndSend() { // Set the origin to Cloud indicating that the resource was imported from a cloud provider. staticLabels[types.OriginLabel] = types.OriginCloud + staticLabels[types.CloudLabel] = lFetcher.Cloud() r.SetStaticLabels(staticLabels) } diff --git a/lib/srv/discovery/discovery_test.go b/lib/srv/discovery/discovery_test.go index 008373566ba01..a759737ced477 100644 --- a/lib/srv/discovery/discovery_test.go +++ b/lib/srv/discovery/discovery_test.go @@ -897,6 +897,7 @@ func mustConvertEKSToKubeCluster(t *testing.T, eksCluster *eks.Cluster, discover require.NoError(t, err) cluster.GetStaticLabels()[types.TeleportInternalDiscoveryGroupName] = discoveryGroup common.ApplyEKSNameSuffix(cluster) + cluster.SetOrigin(types.OriginCloud) return cluster } @@ -905,6 +906,7 @@ func mustConvertAKSToKubeCluster(t *testing.T, azureCluster *azure.AKSCluster, d require.NoError(t, err) cluster.GetStaticLabels()[types.TeleportInternalDiscoveryGroupName] = discoveryGroup common.ApplyAKSNameSuffix(cluster) + cluster.SetOrigin(types.OriginCloud) return cluster } @@ -979,6 +981,7 @@ func mustConvertGKEToKubeCluster(t *testing.T, gkeCluster gcp.GKECluster, discov require.NoError(t, err) cluster.GetStaticLabels()[types.TeleportInternalDiscoveryGroupName] = discoveryGroup common.ApplyGKENameSuffix(cluster) + cluster.SetOrigin(types.OriginCloud) return cluster }