Skip to content

Commit d651b70

Browse files
committed
wip
1 parent 4aaf11b commit d651b70

File tree

4 files changed

+46
-72
lines changed

4 files changed

+46
-72
lines changed

pkg/controller/scylladbcluster/resource.go

-29
Original file line numberDiff line numberDiff line change
@@ -815,35 +815,6 @@ func applyDatacenterTemplateOnDatacenter(dcTemplate *scyllav1alpha1.ScyllaDBClus
815815
}
816816
}
817817

818-
func getRemoteNamespaceAndController(controllerProgressingType string, sc *scyllav1alpha1.ScyllaDBCluster, clusterName string, remoteNamespaces map[string]*corev1.Namespace, remoteControllers map[string]metav1.Object) ([]metav1.Condition, *corev1.Namespace, metav1.Object) {
819-
var progressingConditions []metav1.Condition
820-
remoteNamespace, ok := remoteNamespaces[clusterName]
821-
if !ok {
822-
progressingConditions = append(progressingConditions, metav1.Condition{
823-
Type: controllerProgressingType,
824-
Status: metav1.ConditionTrue,
825-
Reason: "WaitingForRemoteNamespace",
826-
Message: fmt.Sprintf("Waiting for Namespace to be created in %q Cluster", clusterName),
827-
ObservedGeneration: sc.Generation,
828-
})
829-
return progressingConditions, nil, nil
830-
}
831-
832-
remoteController, ok := remoteControllers[clusterName]
833-
if !ok {
834-
progressingConditions = append(progressingConditions, metav1.Condition{
835-
Type: controllerProgressingType,
836-
Status: metav1.ConditionTrue,
837-
Reason: "WaitingForRemoteController",
838-
Message: fmt.Sprintf("Waiting for controller object to be created in %q Cluster", clusterName),
839-
ObservedGeneration: sc.Generation,
840-
})
841-
return progressingConditions, nil, nil
842-
}
843-
844-
return progressingConditions, remoteNamespace, remoteController
845-
}
846-
847818
func MakeRemoteConfigMaps(sc *scyllav1alpha1.ScyllaDBCluster, dc *scyllav1alpha1.ScyllaDBClusterDatacenter, remoteNamespace *corev1.Namespace, remoteController metav1.Object, localConfigMapLister corev1listers.ConfigMapLister, managingClusterDomain string) ([]metav1.Condition, []*corev1.ConfigMap, error) {
848819
var requiredRemoteConfigMaps []*corev1.ConfigMap
849820

pkg/controller/scylladbcluster/sync_scylladbdatacenter.go

+23-17
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,29 @@ func (scc *Controller) syncRemoteScyllaDBDatacenters(
5252
return progressingConditions, fmt.Errorf("can't prune scylladbdatacenter(s) in %q Datacenter of %q ScyllaDBCluster: %w", dc.Name, naming.ObjRef(sc), err)
5353
}
5454

55-
for i := range sc.Spec.Datacenters {
56-
if sc.Spec.Datacenters[i].Name == dc.Name {
57-
break
58-
}
59-
previousDCSpec := sc.Spec.Datacenters[i]
60-
previousDCSDCName := naming.ScyllaDBDatacenterName(sc, &previousDCSpec)
61-
previousDCSDC, ok := remoteScyllaDBDatacenters[previousDCSpec.RemoteKubernetesClusterName][previousDCSDCName]
62-
if !ok {
63-
klog.V(4).InfoS("Waiting for datacenter to be created", "ScyllaDBCluster", klog.KObj(sc), "ScyllaDBDatacenter", klog.KObj(requiredScyllaDBDatacenter), "Datacenter", previousDCSpec.Name)
64-
progressingConditions = append(progressingConditions, metav1.Condition{
65-
Type: fmt.Sprintf(remoteScyllaDBDatacenterControllerDatacenterProgressingConditionFormat, dc.Name),
66-
Status: metav1.ConditionTrue,
67-
Reason: "WaitingForScyllaDBDatacenterCreation",
68-
Message: fmt.Sprintf("Waiting for ScyllaDBDatacenter %q to be created.", previousDCSDCName),
69-
ObservedGeneration: sc.Generation,
70-
})
71-
} else {
55+
_, sdcExists := remoteScyllaDBDatacenters[dc.RemoteKubernetesClusterName][requiredScyllaDBDatacenter.Name]
56+
if !sdcExists {
57+
klog.V(4).InfoS("Required ScyllaDBDatacenter doesn't exists, awaiting all previous DC to finish bootstrapping", "ScyllaDBCluster", klog.KObj(sc), "ScyllaDBDatacenter", klog.KObj(requiredScyllaDBDatacenter))
58+
for i := range sc.Spec.Datacenters {
59+
if sc.Spec.Datacenters[i].Name == dc.Name {
60+
break
61+
}
62+
previousDCSpec := sc.Spec.Datacenters[i]
63+
previousDCSDCName := naming.ScyllaDBDatacenterName(sc, &previousDCSpec)
64+
previousDCSDC, ok := remoteScyllaDBDatacenters[previousDCSpec.RemoteKubernetesClusterName][previousDCSDCName]
65+
if !ok {
66+
klog.V(4).InfoS("Waiting for datacenter to be created", "ScyllaDBCluster", klog.KObj(sc), "ScyllaDBDatacenter", klog.KObj(requiredScyllaDBDatacenter), "Datacenter", previousDCSpec.Name)
67+
progressingConditions = append(progressingConditions, metav1.Condition{
68+
Type: fmt.Sprintf(remoteScyllaDBDatacenterControllerDatacenterProgressingConditionFormat, dc.Name),
69+
Status: metav1.ConditionTrue,
70+
Reason: "WaitingForScyllaDBDatacenterCreation",
71+
Message: fmt.Sprintf("Waiting for ScyllaDBDatacenter %q to be created.", previousDCSDCName),
72+
ObservedGeneration: sc.Generation,
73+
})
74+
75+
return progressingConditions, nil
76+
}
77+
7278
rolledOut, err := controllerhelpers.IsScyllaDBDatacenterRolledOut(previousDCSDC)
7379
if err != nil {
7480
return progressingConditions, fmt.Errorf("can't check if scylladbdatacenter %q is rolled out: %w", naming.ObjRef(previousDCSDC), err)

test/e2e/set/scylladbcluster/multidatacenter/scylladbcluster_fault_tolerance.go

+23-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package multidatacenter
22

33
import (
44
"context"
5+
"encoding/base64"
56
"fmt"
67

78
g "github.com/onsi/ginkgo/v2"
@@ -54,10 +55,17 @@ var _ = g.Describe("Multi datacenter ScyllaDBCluster", framework.MultiDatacenter
5455

5556
o.Expect(lastDCRKCKubeconfigSecret.Data).To(o.HaveKey(kubeconfigKey))
5657
o.Expect(lastDCRKCKubeconfigSecret.Data[kubeconfigKey]).ToNot(o.BeEmpty())
57-
lastDCRKCWorkingKubeconfig := lastDCRKCKubeconfigSecret.Data[kubeconfigKey]
58+
lastDCRKCWorkingKubeconfigBytes := lastDCRKCKubeconfigSecret.Data[kubeconfigKey]
5859

59-
lastDCRKCKubeconfigSecret.Data[kubeconfigKey] = scyllafixture.UnauthorizedKubeconfigBytes
60-
lastDCRKCKubeconfigSecret, err = metaCluster.KubeAdminClient().CoreV1().Secrets(lastDCRKCKubeconfigSecret.Namespace).Update(ctx, lastDCRKCKubeconfigSecret, metav1.UpdateOptions{})
60+
_, err = metaCluster.KubeAdminClient().CoreV1().Secrets(lastDCRKCKubeconfigSecret.Namespace).Patch(
61+
ctx,
62+
lastDCRKCKubeconfigSecret.Name,
63+
types.JSONPatchType,
64+
[]byte(fmt.Sprintf(
65+
`[{"op": "replace", "path": "/spec/data/%s", "value": "%s"}]`, kubeconfigKey, base64.StdEncoding.EncodeToString(scyllafixture.UnauthorizedKubeconfigBytes),
66+
)),
67+
metav1.PatchOptions{},
68+
)
6169
o.Expect(err).NotTo(o.HaveOccurred())
6270

6371
framework.By("Scaling the ScyllaDBCluster up to create a new node in each datacenter")
@@ -86,7 +94,9 @@ var _ = g.Describe("Multi datacenter ScyllaDBCluster", framework.MultiDatacenter
8694
lastDCIdx := len(sc.Spec.Datacenters) - 1
8795
var conditions []func(cluster *scyllav1alpha1.ScyllaDBCluster) (bool, error)
8896
for i := 0; i < lastDCIdx; i++ {
89-
conditions = append(conditions, utils.IsScyllaDBClusterDatacenterRolledOutFunc(&sc.Spec.Datacenters[i]))
97+
conditions = append(conditions, func(cluster *scyllav1alpha1.ScyllaDBCluster) (bool, error) {
98+
return cluster.Status.Datacenters[i].Nodes != nil && *cluster.Status.Datacenters[i].Nodes == newNodes, nil
99+
})
90100
}
91101
conditions = append(conditions, utils.IsScyllaDBClusterDatacenterDegradedFunc(&sc.Spec.Datacenters[lastDCIdx]))
92102
return conditions
@@ -95,8 +105,15 @@ var _ = g.Describe("Multi datacenter ScyllaDBCluster", framework.MultiDatacenter
95105
o.Expect(err).NotTo(o.HaveOccurred())
96106

97107
framework.By("Fixing Operator access to remote Kubernetes cluster associated with last DC")
98-
lastDCRKCKubeconfigSecret.Data[kubeconfigKey] = lastDCRKCWorkingKubeconfig
99-
lastDCRKCKubeconfigSecret, err = metaCluster.KubeAdminClient().CoreV1().Secrets(lastDCRKCKubeconfigSecret.Namespace).Update(ctx, lastDCRKCKubeconfigSecret, metav1.UpdateOptions{})
108+
_, err = metaCluster.KubeAdminClient().CoreV1().Secrets(lastDCRKCKubeconfigSecret.Namespace).Patch(
109+
ctx,
110+
lastDCRKCKubeconfigSecret.Name,
111+
types.JSONPatchType,
112+
[]byte(fmt.Sprintf(
113+
`[{"op": "replace", "path": "/spec/data/%s", "value": "%s"}]`, kubeconfigKey, base64.StdEncoding.EncodeToString(lastDCRKCWorkingKubeconfigBytes),
114+
)),
115+
metav1.PatchOptions{},
116+
)
100117
o.Expect(err).NotTo(o.HaveOccurred())
101118

102119
framework.By("Waiting for the ScyllaDBCluster %q roll out (RV=%s)", sc.Name, sc.ResourceVersion)

test/e2e/utils/helpers.go

-20
Original file line numberDiff line numberDiff line change
@@ -216,26 +216,6 @@ func IsScyllaDBClusterDegraded(sc *scyllav1alpha1.ScyllaDBCluster) (bool, error)
216216
return helpers.IsStatusConditionPresentAndTrue(sc.Status.Conditions, scyllav1alpha1.DegradedCondition, sc.Generation), nil
217217
}
218218

219-
func IsScyllaDBClusterDatacenterRolledOutFunc(dc *scyllav1alpha1.ScyllaDBClusterDatacenter) func(sc *scyllav1alpha1.ScyllaDBCluster) (bool, error) {
220-
return func(sc *scyllav1alpha1.ScyllaDBCluster) (bool, error) {
221-
if !helpers.IsStatusConditionPresentAndTrue(sc.Status.Conditions, fmt.Sprintf(internalapi.DatacenterAvailableConditionFormat, dc.Name), sc.Generation) {
222-
return false, nil
223-
}
224-
225-
if !helpers.IsStatusConditionPresentAndFalse(sc.Status.Conditions, fmt.Sprintf(internalapi.DatacenterProgressingConditionFormat, dc.Name), sc.Generation) {
226-
return false, nil
227-
}
228-
229-
if !helpers.IsStatusConditionPresentAndFalse(sc.Status.Conditions, fmt.Sprintf(internalapi.DatacenterDegradedConditionFormat, dc.Name), sc.Generation) {
230-
return false, nil
231-
}
232-
233-
framework.Infof("ScyllaDBCluster %s Datacenter %s (RV=%s) is rolled out", klog.KObj(sc), dc.Name, sc.ResourceVersion)
234-
235-
return true, nil
236-
}
237-
}
238-
239219
func IsScyllaDBClusterDatacenterDegradedFunc(dc *scyllav1alpha1.ScyllaDBClusterDatacenter) func(sc *scyllav1alpha1.ScyllaDBCluster) (bool, error) {
240220
return func(sc *scyllav1alpha1.ScyllaDBCluster) (bool, error) {
241221
return helpers.IsStatusConditionPresentAndTrue(sc.Status.Conditions, fmt.Sprintf(internalapi.DatacenterDegradedConditionFormat, dc.Name), sc.Generation), nil

0 commit comments

Comments
 (0)