Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

Commit

Permalink
add capacity exhausted to cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
dipak-pawar committed Nov 22, 2018
1 parent 23f2d0c commit 50f7cba
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 21 deletions.
2 changes: 2 additions & 0 deletions cluster/repository/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 7 additions & 7 deletions cluster/service/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
28 changes: 14 additions & 14 deletions controller/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
}
}

Expand Down
8 changes: 8 additions & 0 deletions migration/migration_blackbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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"))
}
2 changes: 2 additions & 0 deletions migration/sql-files/004-add-capacity-exhausted-to-cluster.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Store capacity_exhausted for cluster
ALTER TABLE cluster ADD COLUMN capacity_exhausted boolean;

0 comments on commit 50f7cba

Please sign in to comment.