-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
403f7cc
to
2574fce
Compare
} | ||
} | ||
|
||
func (r *CadenceReconciler) HandleCreateCluster( | ||
ctx context.Context, | ||
cadence *v1beta1.Cadence, | ||
logger logr.Logger, | ||
) reconcile.Result { | ||
) (ctrl.Result, error) { |
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.
why have you changed a package from reconcile to ctrl?
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.
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
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)) | ||
}) | ||
}) |
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.
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
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.
It makes sense, fixed
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", | ||
}, | ||
}, | ||
} |
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.
I suggest you create a new data_test file for the packaged provisioning resources
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.
Added new data file for packaged provisioning
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()) | ||
|
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.
this all may also be removed. Just delete the existing one, that you created above
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.
Fixed
2574fce
to
e04924f
Compare
e04924f
to
f283c60
Compare
f283c60
to
07cc9ff
Compare
07cc9ff
to
855af61
Compare
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.