Skip to content

Commit

Permalink
total nodes number displaying for clusters was implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
tengu-alt committed Feb 26, 2024
1 parent 13f37bd commit e7a5430
Show file tree
Hide file tree
Showing 23 changed files with 202 additions and 36 deletions.
56 changes: 28 additions & 28 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,14 @@
"filename": "apis/clusters/v1beta1/cadence_types.go",
"hashed_secret": "a242f4a16b957f7ff99eb24e189e94d270d2348b",
"is_verified": false,
"line_number": 292
"line_number": 293
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/cadence_types.go",
"hashed_secret": "a57ce131bd944bdf8ba2f2f93e179dc416ed0315",
"is_verified": false,
"line_number": 301
"line_number": 302
}
],
"apis/clusters/v1beta1/cassandra_types.go": [
Expand All @@ -185,21 +185,21 @@
"filename": "apis/clusters/v1beta1/cassandra_types.go",
"hashed_secret": "331cc743251c3b9504229de4d139c539da121a33",
"is_verified": false,
"line_number": 238
"line_number": 252
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/cassandra_types.go",
"hashed_secret": "0ad8d7005e084d4f028a4277b73c6fab24269c17",
"is_verified": false,
"line_number": 324
"line_number": 339
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/cassandra_types.go",
"hashed_secret": "e0a46b27231f798fe22dc4d5d82b5feeb5dcf085",
"is_verified": false,
"line_number": 411
"line_number": 426
}
],
"apis/clusters/v1beta1/cassandra_webhook.go": [
Expand All @@ -217,14 +217,14 @@
"filename": "apis/clusters/v1beta1/kafka_types.go",
"hashed_secret": "964c67cddfe8e6707157152dcf319126502199dc",
"is_verified": false,
"line_number": 271
"line_number": 274
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafka_types.go",
"hashed_secret": "589a0ad3cc6bc886a00c46a22e5065c48bd8e1b2",
"is_verified": false,
"line_number": 417
"line_number": 434
}
],
"apis/clusters/v1beta1/kafkaconnect_types.go": [
Expand All @@ -233,84 +233,84 @@
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "46fe9b29395041087f91b33bd8c5c6177cd42fd1",
"is_verified": false,
"line_number": 253
"line_number": 268
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "4b3af1508421e2fa591c5b260c36dd06fdd872a5",
"is_verified": false,
"line_number": 297
"line_number": 312
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "cf45830dd81b7e1a8b5ffbc2d95b112771524117",
"is_verified": false,
"line_number": 307
"line_number": 322
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "138905ac46675150bf790088ec56b2efc6a64697",
"is_verified": false,
"line_number": 318
"line_number": 333
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "3948059919ffeee8ecc42149cb386f43d2f06f74",
"is_verified": false,
"line_number": 323
"line_number": 338
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "87f1180476a944c4162d1af55efedc8f3e3b609c",
"is_verified": false,
"line_number": 474
"line_number": 489
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "f0f06c9167ce61a586749bb183ac6a3756dd6010",
"is_verified": false,
"line_number": 484
"line_number": 499
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "2042128e13ef5ede4af44271160c72f64564c632",
"is_verified": false,
"line_number": 495
"line_number": 510
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "82dc9ca8ba09262ce948227aeb5d9db8084eeb5d",
"is_verified": false,
"line_number": 500
"line_number": 515
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "5f915325aef923cdc945f639f14c2f854b4214d6",
"is_verified": false,
"line_number": 524
"line_number": 539
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "5ffe533b830f08a0326348a9160afafc8ada44db",
"is_verified": false,
"line_number": 557
"line_number": 572
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
"is_verified": false,
"line_number": 562
"line_number": 577
}
],
"apis/clusters/v1beta1/postgresql_types.go": [
Expand All @@ -319,21 +319,21 @@
"filename": "apis/clusters/v1beta1/postgresql_types.go",
"hashed_secret": "5ffe533b830f08a0326348a9160afafc8ada44db",
"is_verified": false,
"line_number": 354
"line_number": 355
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/postgresql_types.go",
"hashed_secret": "a3d7d4a96d18c8fc5a1cf9c9c01c45b4690b4008",
"is_verified": false,
"line_number": 360
"line_number": 361
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/postgresql_types.go",
"hashed_secret": "a57ce131bd944bdf8ba2f2f93e179dc416ed0315",
"is_verified": false,
"line_number": 480
"line_number": 495
}
],
"apis/clusters/v1beta1/redis_types.go": [
Expand All @@ -342,21 +342,21 @@
"filename": "apis/clusters/v1beta1/redis_types.go",
"hashed_secret": "bc1c5ae5fd4a238d86261f422e62c489de408c22",
"is_verified": false,
"line_number": 169
"line_number": 171
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/redis_types.go",
"hashed_secret": "d62d56668a8c859e768e8250ed2fb690d03cead3",
"is_verified": false,
"line_number": 225
"line_number": 227
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/redis_types.go",
"hashed_secret": "d0e8e6fc5dce4d2b452e344ae41900b566ac01d1",
"is_verified": false,
"line_number": 270
"line_number": 272
}
],
"apis/clusters/v1beta1/redis_webhook.go": [
Expand All @@ -374,14 +374,14 @@
"filename": "apis/clusters/v1beta1/zookeeper_types.go",
"hashed_secret": "5ffe533b830f08a0326348a9160afafc8ada44db",
"is_verified": false,
"line_number": 235
"line_number": 247
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/zookeeper_types.go",
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
"is_verified": false,
"line_number": 240
"line_number": 252
}
],
"apis/clusters/v1beta1/zz_generated.deepcopy.go": [
Expand Down Expand Up @@ -1146,5 +1146,5 @@
}
]
},
"generated_at": "2024-02-26T10:23:28Z"
"generated_at": "2024-02-26T14:23:35Z"
}
15 changes: 15 additions & 0 deletions apis/clusters/v1beta1/cadence_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ type CadenceDataCentreStatus struct {
//+kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.version"
//+kubebuilder:printcolumn:name="ID",type="string",JSONPath=".status.id"
//+kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.state"
//+kubebuilder:printcolumn:name="Node count",type="string",JSONPath=".status.nodeCount"

// Cadence is the Schema for the cadences API
type Cadence struct {
Expand Down Expand Up @@ -412,6 +413,20 @@ func (cs *CadenceStatus) FromInstAPI(instaModel *models.CadenceCluster) {
cs.GenericStatus.FromInstAPI(&instaModel.GenericClusterFields)
cs.targetSecondaryFromInstAPI(instaModel.TargetSecondaryCadence)
cs.DCsFromInstAPI(instaModel.DataCentres)
cs.GetNodeCount()
}

func (cs *CadenceStatus) GetNodeCount() {
var total, running int
for _, dc := range cs.DataCentres {
for _, node := range dc.Nodes {
total++
if node.Status == models.RunningStatus {
running++
}
}
}
cs.NodeCount = fmt.Sprintf("%v/%v", running, total)
}

func (cs *CadenceStatus) targetSecondaryFromInstAPI(instaModels []*models.CadenceDependencyTarget) {
Expand Down
16 changes: 16 additions & 0 deletions apis/clusters/v1beta1/cassandra_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1beta1

import (
"fmt"
"strconv"

k8scorev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -112,6 +113,19 @@ func (s *CassandraStatus) DataCentresEqual(o *CassandraStatus) bool {
return true
}

func (cs *CassandraStatus) GetNodeCount() {
var total, running int
for _, dc := range cs.DataCentres {
for _, node := range dc.Nodes {
total++
if node.Status == models.RunningStatus {
running++
}
}
}
cs.NodeCount = fmt.Sprintf("%v/%v", running, total)
}

type CassandraDataCentre struct {
GenericDataCentreSpec `json:",inline"`

Expand Down Expand Up @@ -245,6 +259,7 @@ func (c *CassandraSpec) IsEqual(o *CassandraSpec) bool {
//+kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.version"
//+kubebuilder:printcolumn:name="ID",type="string",JSONPath=".status.id"
//+kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.state"
//+kubebuilder:printcolumn:name="Node count",type="string",JSONPath=".status.nodeCount"

// Cassandra is the Schema for the cassandras API
type Cassandra struct {
Expand Down Expand Up @@ -469,6 +484,7 @@ func (cs *CassandraSpec) AreDCsEqual(dcs []*CassandraDataCentre) bool {
func (cs *CassandraStatus) FromInstAPI(instModel *models.CassandraCluster) {
cs.GenericStatus.FromInstAPI(&instModel.GenericClusterFields)
cs.dcsFromInstAPI(instModel.DataCentres)
cs.GetNodeCount()
}

func (cs *CassandraStatus) dcsFromInstAPI(instModels []*models.CassandraDataCentre) {
Expand Down
1 change: 1 addition & 0 deletions apis/clusters/v1beta1/generic_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type GenericStatus struct {
ID string `json:"id,omitempty"`
State string `json:"state,omitempty"`
CurrentClusterOperationStatus string `json:"currentClusterOperationStatus,omitempty"`
NodeCount string `json:"nodeCount,omitempty"`

MaintenanceEvents []*v1beta1.ClusteredMaintenanceEventStatus `json:"maintenanceEvents,omitempty"`
}
Expand Down
17 changes: 17 additions & 0 deletions apis/clusters/v1beta1/kafka_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package v1beta1

import (
"fmt"

k8scorev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
Expand Down Expand Up @@ -185,6 +187,7 @@ func (s *KafkaStatus) ToOnPremises() ClusterStatus {
//+kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.version"
//+kubebuilder:printcolumn:name="ID",type="string",JSONPath=".status.id"
//+kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.state"
//+kubebuilder:printcolumn:name="Node count",type="string",JSONPath=".status.nodeCount"

// Kafka is the Schema for the kafkas API
type Kafka struct {
Expand Down Expand Up @@ -377,6 +380,20 @@ func (ks *KafkaSpec) FromInstAPI(instaModel *models.KafkaCluster) {
func (ks *KafkaStatus) FromInstAPI(instaModel *models.KafkaCluster) {
ks.GenericStatus.FromInstAPI(&instaModel.GenericClusterFields)
ks.DCsFromInstAPI(instaModel.DataCentres)
ks.GetNodeCount()
}

func (ks *KafkaStatus) GetNodeCount() {
var total, running int
for _, dc := range ks.DataCentres {
for _, node := range dc.Nodes {
total++
if node.Status == models.RunningStatus {
running++
}
}
}
ks.NodeCount = fmt.Sprintf("%v/%v", running, total)
}

func (ks *KafkaSpec) DCsFromInstAPI(instaModels []*models.KafkaDataCentre) {
Expand Down
15 changes: 15 additions & 0 deletions apis/clusters/v1beta1/kafkaconnect_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ type KafkaConnectDataCentreStatus struct {
//+kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.version"
//+kubebuilder:printcolumn:name="ID",type="string",JSONPath=".status.id"
//+kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.state"
//+kubebuilder:printcolumn:name="Node count",type="string",JSONPath=".status.nodeCount"

// KafkaConnect is the Schema for the kafkaconnects API
type KafkaConnect struct {
Expand Down Expand Up @@ -209,6 +210,20 @@ func (ks *KafkaConnectSpec) FromInstAPI(instaModel *models.KafkaConnectCluster)
func (ks *KafkaConnectStatus) FromInstAPI(instaModel *models.KafkaConnectCluster) {
ks.GenericStatus.FromInstAPI(&instaModel.GenericClusterFields)
ks.DCsFromInstAPI(instaModel.DataCentres)
ks.GetNodeCount()
}

func (ks *KafkaConnectStatus) GetNodeCount() {
var total, running int
for _, dc := range ks.DataCentres {
for _, node := range dc.Nodes {
total++
if node.Status == models.RunningStatus {
running++
}
}
}
ks.NodeCount = fmt.Sprintf("%v/%v", running, total)
}

func (ks *KafkaConnectSpec) DCsFromInstAPI(instaModels []*models.KafkaConnectDataCentre) {
Expand Down
Loading

0 comments on commit e7a5430

Please sign in to comment.