Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

remove check dc from CC object (for mutli-cluster) #179

Merged
merged 3 commits into from
Feb 6, 2020
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ anaconda-mode/

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
coverage.html

### Vim ###
# swap
Expand Down
6,059 changes: 0 additions & 6,059 deletions coverage.html

This file was deleted.

4 changes: 2 additions & 2 deletions pkg/controller/cassandracluster/node_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ func (jolokiaClient *JolokiaClient) hasLeavingNodes() (bool, error) {
return len(leavingNodes) > 0, nil
}

/*HasDataInDC checks partition ranges of all non local keyspaces and ensure no data is replicated to the chosen datacenter*/
func (jolokiaClient *JolokiaClient) HasDataInDC(dc string) ([]string, error) {
/*NonLocalKeyspacesInDC checks partition ranges of all non local keyspaces and ensure no data is replicated to the chosen datacenter*/
func (jolokiaClient *JolokiaClient) NonLocalKeyspacesInDC(dc string) ([]string, error) {
keyspaces, err := jolokiaClient.nonLocalKeyspaces()
keyspacesWithDataInDC := []string{}
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/cassandracluster/node_operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func TestReplicateData(t *testing.T) {

jolokiaClient, _ := NewJolokiaClient(host, JolokiaPort, nil,
v1.LocalObjectReference{}, "ns")
keyspacesWithData, err := jolokiaClient.HasDataInDC("dc2")
keyspacesWithData, err := jolokiaClient.NonLocalKeyspacesInDC("dc2")

if err != nil {
t.Errorf("hasData failed with : %s", err)
Expand Down
11 changes: 6 additions & 5 deletions pkg/controller/cassandracluster/pod_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,17 +677,20 @@ func (rcc *ReconcileCassandraCluster) runUpgradeSSTables(hostName string, cc *ap

func (rcc *ReconcileCassandraCluster) runRebuild(hostName string, cc *api.CassandraCluster, dcRackName string, pod v1.Pod) error {
var err error
var keyspaces []string
var rebuildFrom, labelSet = pod.GetLabels()["operation-argument"]
operation := strings.Title(api.OperationRebuild)

logrus.WithFields(logrus.Fields{"cluster": cc.Name, "rack": dcRackName, "pod": pod.Name,
"hostName": hostName, "operation": operation}).Info("Operation start")

jolokiaClient, err := NewJolokiaClient(hostName, JolokiaPort, rcc,
cc.Spec.ImageJolokiaSecret, cc.Namespace)

if labelSet != true {
err = errors.New("operation-argument is needed to get the datacenter name to rebuild from")
} else if cc.IsValidDC(rebuildFrom) == false {
err = fmt.Errorf("%s is not an existing datacenter", rebuildFrom)
}
} else if keyspaces, err = jolokiaClient.NonLocalKeyspacesInDC(rebuildFrom); err == nil && len(keyspaces) == 0 {
err = fmt.Errorf("%s has no keyspace to replicate data from", rebuildFrom) }

// In case of an error set the status on the pod and skip it
if err != nil {
Expand All @@ -697,8 +700,6 @@ func (rcc *ReconcileCassandraCluster) runRebuild(hostName string, cc *api.Cassan
logrus.WithFields(logrus.Fields{"cluster": cc.Name, "rack": dcRackName, "pod": pod.Name,
"datacenter": rebuildFrom, "operation": operation}).Info("Execute the Jolokia Operation")

jolokiaClient, err := NewJolokiaClient(hostName, JolokiaPort, rcc,
cc.Spec.ImageJolokiaSecret, cc.Namespace)
if err == nil {
err = jolokiaClient.NodeRebuild(rebuildFrom)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/cassandracluster/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,11 @@ func (rcc *ReconcileCassandraCluster) CheckNonAllowedScaleDown(cc *api.Cassandra
cc.Spec.ImageJolokiaSecret, cc.Namespace)
var keyspacesWithData []string
if err == nil {
keyspacesWithData, err = jolokiaClient.HasDataInDC(dcName)
keyspacesWithData, err = jolokiaClient.NonLocalKeyspacesInDC(dcName)
}
if err != nil {
logrus.WithFields(logrus.Fields{"cluster": cc.Name}).Warningf(
"The Operator has refused the ScaleDown (HasDataInDC failed %s). ", err)
"The Operator has refused the ScaleDown (NonLocalKeyspacesInDC failed %s). ", err)
cc.Spec.Topology = oldCRD.Spec.Topology
return true, api.ActionCorrectCRDConfig
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/cassandracluster/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ func TestCheckNonAllowedChangesScaleDown(t *testing.T) {
hostName := fmt.Sprintf("%s.%s", pod.Spec.Hostname, pod.Spec.Subdomain)
rcc.CreatePod(pod)

//Mock Jolokia Call to HasDataInDC
//Mock Jolokia Call to NonLocalKeyspacesInDC
httpmock.Activate()
defer httpmock.DeactivateAndReset()
keyspacesDescribed := []string{}
Expand Down