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

Commit

Permalink
close if statement
Browse files Browse the repository at this point in the history
  • Loading branch information
erdrix committed Feb 4, 2020
1 parent f5a9135 commit 2e1fea0
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
8 changes: 4 additions & 4 deletions coverage.html
Original file line number Diff line number Diff line change
Expand Up @@ -3389,8 +3389,8 @@
<span class="cov0" title="0">return len(leavingNodes) &gt; 0, nil</span>
}

/*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) <span class="cov8" title="1">{
/*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) <span class="cov8" title="1">{
keyspaces, err := jolokiaClient.nonLocalKeyspaces()
keyspacesWithDataInDC := []string{}
if err != nil </span><span class="cov0" title="0">{
Expand Down Expand Up @@ -5083,11 +5083,11 @@
cc.Spec.ImageJolokiaSecret, cc.Namespace)
var keyspacesWithData []string
if err == nil </span><span class="cov8" title="1">{
keyspacesWithData, err = jolokiaClient.HasDataInDC(dcName)
keyspacesWithData, err = jolokiaClient.NonLocalKeyspacesInDC(dcName)
}</span>
<span class="cov8" title="1">if err != nil </span><span class="cov0" title="0">{
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
}</span>
Expand Down
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
8 changes: 3 additions & 5 deletions pkg/controller/cassandracluster/pod_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,10 +689,9 @@ func (rcc *ReconcileCassandraCluster) runRebuild(hostName string, cc *api.Cassan

if labelSet != true {
err = errors.New("operation-argument is needed to get the datacenter name to rebuild from")
} else if keyspaces, err = jolokiaClient.HasDataInDC(rebuildFrom); err == nil && len(keyspaces) == 0 {
err = fmt.Errorf("%s is not has no nonLocalKeyspace defined", 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 {
return err
Expand All @@ -701,7 +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")


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

0 comments on commit 2e1fea0

Please sign in to comment.