Skip to content

Commit

Permalink
WIP - panic when downscale + functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
averdagu committed Nov 22, 2023
1 parent 7005acc commit cc9a5a0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
30 changes: 27 additions & 3 deletions controllers/ovndbcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/go-logr/logr"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -589,12 +590,25 @@ func (r *OVNDBClusterReconciler) reconcileServices(
if err != nil {
return ctrl.Result{}, err
}
// Delete DNS thingy
dnsRecord := &infranetworkv1.DNSData{}
dnsName := "dns-" + serviceName + fmt.Sprintf("-%d", i)
dnsNamespace := helper.GetBeforeObject().GetNamespace()
Log.Info(fmt.Sprintf("Name: %v, Namespace: %v", dnsName, dnsNamespace))
test_err := helper.GetClient().Get(ctx, types.NamespacedName{Name: dnsName, Namespace: dnsNamespace}, dnsRecord)
if test_err != nil {
Log.Info(fmt.Sprintf("Error: %v", test_err))
}
err := helper.GetClient().Delete(ctx, dnsRecord)
if err != nil {
Log.Info(fmt.Sprintf("Error: %v", err))
}

}
}

Log.Info("DNS Starts here")
Log.Info(fmt.Sprintf("AAA - Using instance: %v", instance))
Log.Info(fmt.Sprintf("AAA - Using instance.spec: %v", instance.Spec))

serviceName = ovndbcluster.ServiceNameSB
if instance.Spec.DBType == v1beta1.NBDBType {
serviceName = ovndbcluster.ServiceNameNB
Expand All @@ -606,7 +620,14 @@ func (r *OVNDBClusterReconciler) reconcileServices(
if err != nil {
return ctrl.Result{}, err
}
for _, ovnPod := range podList.Items {
if len(podList.Items) > int(*(instance.Spec.Replicas)) {

}
for i, ovnPod := range podList.Items {
if i >= int(*(instance.Spec.Replicas)) {
Log.Info(fmt.Sprintf("In iteration %v is OOO, exit", i))
break
}
Log.Info(fmt.Sprintf("Using Pod: %v", ovnPod.Name))
var dnsName string
var dnsIP string
Expand All @@ -619,6 +640,9 @@ func (r *OVNDBClusterReconciler) reconcileServices(
ovnPod.Name,
ovnPod.Namespace,
)
if err != nil {
return ctrl.Result{}, err
}
hostname := svc.ObjectMeta.Annotations[infranetworkv1.AnnotationHostnameKey]
hostnames = append(hostnames, hostname)

Expand Down
8 changes: 5 additions & 3 deletions tests/functional/ovncontroller_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ var _ = Describe("OVNController controller", func() {
daemonSetName,
map[string][]string{namespace + "/internalapi": {"10.0.0.1"}},
)
ExpectedExternalSBEndpoint := "tcp:ovsdbserver-sb." + namespace + ".svc:6642"
externalSBEndpoint := "10.0.0.254"
SetExternalEndpoint(dbs[1], externalSBEndpoint)

Expand All @@ -377,7 +378,7 @@ var _ = Describe("OVNController controller", func() {
}, timeout, interval).ShouldNot(BeNil())

Expect(th.GetConfigMap(externalCM).Data["ovsdb-config"]).Should(
ContainSubstring("ovn-remote: %s", externalSBEndpoint))
ContainSubstring("ovn-remote: %s", ExpectedExternalSBEndpoint))
Expect(th.GetConfigMap(externalCM).Data["ovsdb-config"]).Should(
ContainSubstring("ovn-encap-type: %s", "geneve"))
})
Expand Down Expand Up @@ -460,21 +461,22 @@ var _ = Describe("OVNController controller", func() {
map[string][]string{namespace + "/internalapi": {"10.0.0.1"}},
)
externalSBEndpoint := "10.0.0.254"
ExpectedExternalSBEndpoint := "tcp:ovsdbserver-sb." + namespace + ".svc:6642"
SetExternalEndpoint(dbs[1], externalSBEndpoint)

Eventually(func() corev1.ConfigMap {
return *th.GetConfigMap(externalCM)
}, timeout, interval).ShouldNot(BeNil())

Expect(th.GetConfigMap(externalCM).Data["ovsdb-config"]).Should(
ContainSubstring("ovn-remote: %s", externalSBEndpoint))
ContainSubstring("ovn-remote: %s", ExpectedExternalSBEndpoint))

newExternalSBEndpoint := "10.0.0.250"
SetExternalEndpoint(dbs[1], newExternalSBEndpoint)

Eventually(func(g Gomega) {
g.Expect(th.GetConfigMap(externalCM).Data["ovsdb-config"]).Should(
ContainSubstring("ovn-remote: %s", newExternalSBEndpoint))
ContainSubstring("ovn-remote: %s", ExpectedExternalSBEndpoint))
}, timeout, interval).Should(Succeed())
})
})
Expand Down

0 comments on commit cc9a5a0

Please sign in to comment.