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

Add ExtractDatabaseInfo Func for Cassandra #1351

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions apis/kubedb/v1alpha2/cassandra_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"gomodules.xyz/pointer"
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/types"
"k8s.io/klog/v2"
"kmodules.xyz/client-go/apiextensions"
Expand All @@ -40,6 +41,7 @@ import (
appcat "kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1"
mona "kmodules.xyz/monitoring-agent-api/api/v1"
ofst "kmodules.xyz/offshoot-api/api/v2"
pslister "kubeops.dev/petset/client/listers/apps/v1"
)

type CassandraApp struct {
Expand Down Expand Up @@ -419,3 +421,12 @@ func (r *Cassandra) GetSeed() string {
}
return seed
}

func (c *Cassandra) ReplicasAreReady(lister pslister.PetSetLister) (bool, string, error) {
// Desire number of petSets
expectedItems := 1
if c.Spec.Topology != nil {
expectedItems = len(c.Spec.Topology.Rack)
}
return checkReplicasOfPetSet(lister.PetSets(c.Namespace), labels.SelectorFromSet(c.OffshootLabels()), expectedItems)
}
11 changes: 11 additions & 0 deletions pkg/controller/petset/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ func (c *Controller) extractDatabaseInfo(ps *petsetapps.PetSet) (*databaseInfo,
}
switch owner.Kind {

case olddbapi.ResourceKindCassandra:
dbInfo.opts.GVR.Resource = olddbapi.ResourcePluralCassandra
cas, err := c.DBClient.KubedbV1alpha2().Cassandras(dbInfo.opts.Namespace).Get(context.TODO(), dbInfo.opts.Name, metav1.GetOptions{})
if err != nil {
return nil, err
}
dbInfo.replicasReady, dbInfo.msg, err = cas.ReplicasAreReady(c.PSLister)
if err != nil {
return nil, err
}

case olddbapi.ResourceKindClickHouse:
dbInfo.opts.GVR.Resource = olddbapi.ResourcePluralClickHouse
ch, err := c.DBClient.KubedbV1alpha2().ClickHouses(dbInfo.opts.Namespace).Get(context.TODO(), dbInfo.opts.Name, metav1.GetOptions{})
Expand Down
Loading