diff --git a/cluster/repository/cluster.go b/cluster/repository/cluster.go index 21390a9..3310fa7 100644 --- a/cluster/repository/cluster.go +++ b/cluster/repository/cluster.go @@ -48,6 +48,8 @@ type Cluster struct { AuthDefaultScope string // Cluster type. Such as OSD, OSO, OCP, etc Type string + // cluster capacity exhausted by default false + CapacityExhausted bool } // GormClusterRepository is the implementation of the storage interface for Cluster. diff --git a/cluster/service/cluster.go b/cluster/service/cluster.go index b14c8ff..f1c474d 100644 --- a/cluster/service/cluster.go +++ b/cluster/service/cluster.go @@ -42,13 +42,13 @@ func NewClusterService(context servicectx.ServiceContext, loader ConfigLoader) s func (c clusterService) CreateOrSaveOSOClusterFromConfig(ctx context.Context) error { for _, osoCluster := range c.loader.GetOSOClusters() { cluster := &repository.Cluster{ - Name: osoCluster.Name, - URL: httpsupport.AddTrailingSlashToURL(osoCluster.APIURL), - ConsoleURL: httpsupport.AddTrailingSlashToURL(osoCluster.ConsoleURL), - MetricsURL: httpsupport.AddTrailingSlashToURL(osoCluster.MetricsURL), - LoggingURL: httpsupport.AddTrailingSlashToURL(osoCluster.LoggingURL), - AppDNS: osoCluster.AppDNS, - //CapacityExhausted: clusterConfig.CapacityExhausted, + Name: osoCluster.Name, + URL: httpsupport.AddTrailingSlashToURL(osoCluster.APIURL), + ConsoleURL: httpsupport.AddTrailingSlashToURL(osoCluster.ConsoleURL), + MetricsURL: httpsupport.AddTrailingSlashToURL(osoCluster.MetricsURL), + LoggingURL: httpsupport.AddTrailingSlashToURL(osoCluster.LoggingURL), + AppDNS: osoCluster.AppDNS, + CapacityExhausted: osoCluster.CapacityExhausted, SaToken: osoCluster.ServiceAccountToken, SaUsername: osoCluster.ServiceAccountUsername, diff --git a/controller/clusters.go b/controller/clusters.go index c531254..abcf4cb 100644 --- a/controller/clusters.go +++ b/controller/clusters.go @@ -62,22 +62,22 @@ func (c *ClustersController) ShowAuthClient(ctx *app.ShowAuthClientClustersConte return app.JSONErrorResponse(ctx, errors.NewUnauthorizedError("unauthorized access to cluster info")) } var data []*app.FullClusterData - for _, clusterConfig := range c.config.GetOSOClusters() { + for _, ososCluster := range c.config.GetOSOClusters() { cluster := &app.FullClusterData{ - Name: clusterConfig.Name, - APIURL: httpsupport.AddTrailingSlashToURL(clusterConfig.APIURL), - ConsoleURL: httpsupport.AddTrailingSlashToURL(clusterConfig.ConsoleURL), - MetricsURL: httpsupport.AddTrailingSlashToURL(clusterConfig.MetricsURL), - LoggingURL: httpsupport.AddTrailingSlashToURL(clusterConfig.LoggingURL), - AppDNS: clusterConfig.AppDNS, - CapacityExhausted: clusterConfig.CapacityExhausted, + Name: ososCluster.Name, + APIURL: httpsupport.AddTrailingSlashToURL(ososCluster.APIURL), + ConsoleURL: httpsupport.AddTrailingSlashToURL(ososCluster.ConsoleURL), + MetricsURL: httpsupport.AddTrailingSlashToURL(ososCluster.MetricsURL), + LoggingURL: httpsupport.AddTrailingSlashToURL(ososCluster.LoggingURL), + AppDNS: ososCluster.AppDNS, + CapacityExhausted: ososCluster.CapacityExhausted, - AuthClientDefaultScope: clusterConfig.AuthClientDefaultScope, - AuthClientID: clusterConfig.AuthClientID, - AuthClientSecret: clusterConfig.AuthClientSecret, - ServiceAccountToken: clusterConfig.ServiceAccountToken, - ServiceAccountUsername: clusterConfig.ServiceAccountUsername, - TokenProviderID: clusterConfig.TokenProviderID, + AuthClientDefaultScope: ososCluster.AuthClientDefaultScope, + AuthClientID: ososCluster.AuthClientID, + AuthClientSecret: ososCluster.AuthClientSecret, + ServiceAccountToken: ososCluster.ServiceAccountToken, + ServiceAccountUsername: ososCluster.ServiceAccountUsername, + TokenProviderID: ososCluster.TokenProviderID, } data = append(data, cluster) } diff --git a/migration/migration.go b/migration/migration.go index acc8e48..93fa0b1 100644 --- a/migration/migration.go +++ b/migration/migration.go @@ -18,6 +18,7 @@ func Steps() Scripts { {"001-cluster.sql"}, {"002-cluster-on-delete-cascade.sql"}, {"003-unique-index-on-cluster-api-url.sql"}, + {"004-add-capacity-exhausted-to-cluster.sql"}, } } diff --git a/migration/migration_blackbox_test.go b/migration/migration_blackbox_test.go index a21409a..a9eba61 100644 --- a/migration/migration_blackbox_test.go +++ b/migration/migration_blackbox_test.go @@ -82,6 +82,7 @@ func (s *MigrationTestSuite) TestMigrate() { s.T().Run("testMigration001Cluster", testMigration001Cluster) s.T().Run("testMigration002ClusterOnDeleteCascade", testMigration002ClusterOnDeleteCascade) s.T().Run("testMigration003UniqueIndexOnClusterApiUrl", testMigration003UniqueIndexOnClusterApiUrl) + s.T().Run("testMigration004AddCapacityExhaustedToCluster", testMigration004AddCapacityExhaustedToCluster) } func testMigration001Cluster(t *testing.T) { @@ -155,3 +156,10 @@ func testMigration003UniqueIndexOnClusterApiUrl(t *testing.T) { assert.True(t, dialect.HasIndex("cluster", "idx_cluster_url")) } + +func testMigration004AddCapacityExhaustedToCluster(t *testing.T) { + err := migrationsupport.Migrate(sqlDB, databaseName, migration.Steps()[:5]) + require.NoError(t, err) + + assert.True(t, dialect.HasColumn("cluster", "capacity_exhausted")) +} diff --git a/migration/sql-files/004-add-capacity-exhausted-to-cluster.sql b/migration/sql-files/004-add-capacity-exhausted-to-cluster.sql new file mode 100644 index 0000000..38a7b97 --- /dev/null +++ b/migration/sql-files/004-add-capacity-exhausted-to-cluster.sql @@ -0,0 +1,2 @@ +-- Store identity provider username for the external token +ALTER TABLE cluster ADD COLUMN capacity_exhausted boolean;