Skip to content
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

issue-559, Cadence controller integration of the rate limiter #597

Merged
merged 1 commit into from
Oct 20, 2023

Conversation

worryg0d
Copy link
Collaborator

Our custom rate limiter, which allows rate-limiting the amount of reconciliation for resources, was integrated into the cadence controller.

Also, the cadence controller was covered with integration tests.

@worryg0d worryg0d added enhancement New feature or request test Сover the code with tests refactor Code improvements or refactorings labels Oct 16, 2023
@worryg0d worryg0d self-assigned this Oct 16, 2023
@worryg0d worryg0d force-pushed the issue-559-cadence-rate-limiter-integration branch 5 times, most recently from 403f7cc to 2574fce Compare October 17, 2023 10:57
}
}

func (r *CadenceReconciler) HandleCreateCluster(
ctx context.Context,
cadence *v1beta1.Cadence,
logger logr.Logger,
) reconcile.Result {
) (ctrl.Result, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why have you changed a package from reconcile to ctrl?

Copy link
Collaborator Author

@worryg0d worryg0d Oct 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we generate a controller with kubebuilder it creates default reconcile with ctrl.Result as returning value.
ctlr.Result is an alias for reconcile.Result. So, I decided to use the alias to avoid additional imports

Comment on lines 62 to 106
ginkgo.When("deleting cadence resource", func() {
ginkgo.It("should successfully delete cadence resource in k8s and Instaclustr", func() {
cadenceManifest := *cadenceManifest
cadenceManifest.ResourceVersion = ""
cadenceManifest.Name += "-deleting"
cadenceManifest.Spec.Name += "-deleting"

gomega.Expect(k8sClient.Create(ctx, &cadenceManifest)).Should(gomega.Succeed())

key := client.ObjectKeyFromObject(&cadenceManifest)
cadence := &v1beta1.Cadence{}

gomega.Eventually(func(g gomega.Gomega) {
g.Expect(k8sClient.Get(ctx, key, cadence)).Should(gomega.Succeed(), "should get the cadence resource")
g.Expect(cadence.Status.ID).ShouldNot(gomega.BeEmpty(), "the cadence id should not be empty")
}, timeout, interval).Should(gomega.Succeed())

gomega.Expect(k8sClient.Delete(ctx, cadence)).Should(gomega.Succeed())

gomega.Eventually(func(g gomega.Gomega) {
c := &v1beta1.Cadence{}
g.Expect(k8sClient.Get(ctx, key, c)).ShouldNot(gomega.Succeed())
}, timeout, interval).Should(gomega.Succeed())

gomega.Eventually(func() error {
_, err := instaClient.GetCadence(cadence.Status.ID)
return err
}, timeout, interval).Should(gomega.Equal(instaclustr.NotFound))
})
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may delete the existing cluster that you created above in the ginkgo.When("apply valid cadence manifest", func() { case, instead of creating another cluster

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense, fixed

Comment on lines 94 to 122
ginkgo.It("should create cadence and all packaged resources in k8s and on Instaclustr", func() {
cadenceManifest := *cadenceManifest
cadenceManifest.ResourceVersion = ""
cadenceManifest.Spec.StandardProvisioning = nil
cadenceManifest.Spec.Name += "-packaged-provisioning"
cadenceManifest.Name += "-packaged-provisioning"
cadenceManifest.Spec.PackagedProvisioning = []*v1beta1.PackagedProvisioning{
{
UseAdvancedVisibility: true,
BundledKafkaSpec: &v1beta1.BundledKafkaSpec{
NodeSize: "test-kafka-node-size-1",
NodesNumber: 2,
Network: "10.0.0.0/16",
ReplicationFactor: 2,
PartitionsNumber: 2,
},
BundledOpenSearchSpec: &v1beta1.BundledOpenSearchSpec{
NodeSize: "test-opensearch-node-size-1",
ReplicationFactor: 2,
Network: "10.1.0.0/16",
},
BundledCassandraSpec: &v1beta1.BundledCassandraSpec{
NodeSize: "test-cassandra-node-size-1",
NodesNumber: 2,
ReplicationFactor: 2,
Network: "10.2.0.0/16",
},
},
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest you create a new data_test file for the packaged provisioning resources

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added new data file for packaged provisioning

Comment on lines 162 to 160
ginkgo.When("deleting cadence resource with packaged provisioning", func() {
ginkgo.It("should successfully delete cadence and bundled resources in k8s and Instaclustr", func() {
cadenceManifest := *cadenceManifest
cadenceManifest.ResourceVersion = ""
cadenceManifest.Spec.StandardProvisioning = nil
cadenceManifest.Spec.Name += "-packaged-provisioning-deleting"
cadenceManifest.Name += "-packaged-provisioning-deleting"
cadenceManifest.Spec.PackagedProvisioning = []*v1beta1.PackagedProvisioning{
{
UseAdvancedVisibility: true,
BundledKafkaSpec: &v1beta1.BundledKafkaSpec{
NodeSize: "test-kafka-node-size-1",
NodesNumber: 2,
Network: "10.0.0.0/16",
ReplicationFactor: 2,
PartitionsNumber: 2,
},
BundledOpenSearchSpec: &v1beta1.BundledOpenSearchSpec{
NodeSize: "test-opensearch-node-size-1",
ReplicationFactor: 2,
Network: "10.1.0.0/16",
},
BundledCassandraSpec: &v1beta1.BundledCassandraSpec{
NodeSize: "test-cassandra-node-size-1",
NodesNumber: 2,
ReplicationFactor: 2,
Network: "10.2.0.0/16",
},
},
}

gomega.Expect(k8sClient.Create(ctx, &cadenceManifest)).Should(gomega.Succeed())

key := client.ObjectKeyFromObject(&cadenceManifest)
cadence := &v1beta1.Cadence{}

gomega.Eventually(func(g gomega.Gomega) {
g.Expect(k8sClient.Get(ctx, key, cadence)).Should(gomega.Succeed(), "should get the cadence resource")
g.Expect(cadence.Status.ID).ShouldNot(gomega.BeEmpty(), "the cadence id should not be empty")
}, timeout, interval).Should(gomega.Succeed())

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this all may also be removed. Just delete the existing one, that you created above

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@worryg0d worryg0d force-pushed the issue-559-cadence-rate-limiter-integration branch from 2574fce to e04924f Compare October 18, 2023 09:59
@worryg0d worryg0d requested a review from ribaraka October 18, 2023 10:01
@worryg0d worryg0d force-pushed the issue-559-cadence-rate-limiter-integration branch from e04924f to f283c60 Compare October 18, 2023 10:02
@worryg0d worryg0d force-pushed the issue-559-cadence-rate-limiter-integration branch from f283c60 to 07cc9ff Compare October 18, 2023 12:34
@worryg0d worryg0d force-pushed the issue-559-cadence-rate-limiter-integration branch from 07cc9ff to 855af61 Compare October 20, 2023 09:33
@testisnullus testisnullus merged commit f98094f into main Oct 20, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor Code improvements or refactorings test Сover the code with tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants