-
Notifications
You must be signed in to change notification settings - Fork 38
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
KO-165: Added support for simultaneous scale-down and rolling restart SC cluster #233
Changes from 3 commits
0725215
00cbd2d
7b83ba8
921154a
b722c57
6f9aa0b
b2371b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,9 @@ package controllers | |
|
||
import ( | ||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/util/sets" | ||
|
||
asdbv1 "github.com/aerospike/aerospike-kubernetes-operator/api/v1" | ||
"github.com/aerospike/aerospike-management-lib/deployment" | ||
as "github.com/ashishshinde/aerospike-client-go/v6" | ||
) | ||
|
@@ -16,12 +18,12 @@ func (r *SingleClusterReconciler) getAndSetRoster( | |
return err | ||
} | ||
|
||
removedNSes, err := r.removedNamespaces(allHostConns) | ||
ignorableNamespaces, err := r.getIgnorableNamespaces(allHostConns) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return deployment.GetAndSetRoster(r.Log, allHostConns, policy, rosterNodeBlockList, removedNSes) | ||
return deployment.GetAndSetRoster(r.Log, allHostConns, policy, rosterNodeBlockList, ignorableNamespaces) | ||
} | ||
|
||
func (r *SingleClusterReconciler) validateSCClusterState(policy *as.ClientPolicy, ignorablePods []corev1.Pod) error { | ||
|
@@ -30,10 +32,58 @@ func (r *SingleClusterReconciler) validateSCClusterState(policy *as.ClientPolicy | |
return err | ||
} | ||
|
||
removedNSes, err := r.removedNamespaces(allHostConns) | ||
ignorableNamespaces, err := r.getIgnorableNamespaces(allHostConns) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return deployment.ValidateSCClusterState(r.Log, allHostConns, policy, removedNSes) | ||
return deployment.ValidateSCClusterState(r.Log, allHostConns, policy, ignorableNamespaces) | ||
} | ||
|
||
func (r *SingleClusterReconciler) addedSCNamespaces(allHostConns []*deployment.HostConn) ([]string, error) { | ||
var ( | ||
specSCNamespaces = sets.NewString() | ||
newAddedSCNamespaces = sets.NewString() | ||
) | ||
|
||
// Look inside only 1st rack. SC namespaces should be same across all the racks | ||
rack := r.aeroCluster.Spec.RackConfig.Racks[0] | ||
nsList := rack.AerospikeConfig.Value["namespaces"].([]interface{}) | ||
|
||
for _, nsConfInterface := range nsList { | ||
if asdbv1.IsNSSCEnabled(nsConfInterface.(map[string]interface{})) { | ||
specSCNamespaces.Insert(nsConfInterface.(map[string]interface{})["name"].(string)) | ||
} | ||
} | ||
|
||
nodesNamespaces, err := deployment.GetClusterNamespaces(r.Log, r.getClientPolicy(), allHostConns) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// Check if SC namespaces are present in all node's namespaces, if not then it's a new SC namespace | ||
for _, namespaces := range nodesNamespaces { | ||
nodeNamespaces := sets.NewString(namespaces...) | ||
newAddedSCNamespaces.Insert(specSCNamespaces.Difference(nodeNamespaces).List()...) | ||
} | ||
|
||
return newAddedSCNamespaces.List(), nil | ||
} | ||
|
||
func (r *SingleClusterReconciler) getIgnorableNamespaces(allHostConns []*deployment.HostConn) ( | ||
sets.Set[string], error) { | ||
removedNSes, err := r.removedNamespaces(allHostConns) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
addSCNamespaces, err := r.addedSCNamespaces(allHostConns) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it ok to get sc namespaces from all the hosts even if there are some entries in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As per discussion, not much useful. So skipping extra checks for RosterNodeBlockList |
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
ignorableNamespaces := sets.New[string](removedNSes...) | ||
ignorableNamespaces.Insert(addSCNamespaces...) | ||
|
||
return ignorableNamespaces, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we call
deployment.GetClusterNamespaces
in bothremovedNamespaces
as well asr.addedSCNamespaces
, see if we can reduce calls here.