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

KO-358: Enhance AerospikeBackupService CR with all the possible deployment configuration params #328

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jwalantmodi05
Copy link
Contributor

No description provided.

api/v1beta1/aerospikebackupservice_types.go Outdated Show resolved Hide resolved
api/v1beta1/aerospikebackupservice_types.go Outdated Show resolved Hide resolved
api/v1beta1/aerospikebackupservice_webhook.go Show resolved Hide resolved
api/v1beta1/aerospikebackupservice_webhook.go Outdated Show resolved Hide resolved
api/v1beta1/aerospikebackupservice_webhook.go Outdated Show resolved Hide resolved
test/backup_service/backup_service_test.go Show resolved Hide resolved
test/backup_service/backup_service_test.go Outdated Show resolved Hide resolved
test/backup_service/test_utils.go Outdated Show resolved Hide resolved
test/backup_service/backup_service_test.go Outdated Show resolved Hide resolved
test/backup_service/test_utils.go Outdated Show resolved Hide resolved
Comment on lines +27 to +46
- admissionReviewVersions:
- v1
clientConfig:
service:
name: webhook-service
namespace: system
path: /mutate-asdb-aerospike-com-v1beta1-aerospikebackupservice
failurePolicy: Fail
name: maerospikebackupservice.kb.io
rules:
- apiGroups:
- asdb.aerospike.com
apiVersions:
- v1beta1
operations:
- CREATE
- UPDATE
resources:
- aerospikebackupservices
sideEffects: None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add this in helm-chart as well

}

func validateObjectMeta(objectMeta *AerospikeObjectMeta) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
func validateObjectMeta(objectMeta *AerospikeObjectMeta) error {
func validatePodObjectMeta(objectMeta *AerospikeObjectMeta) error {

}
func (r *AerospikeBackupService) validateResourcesField() (admission.Warnings, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a new line

if r.Spec.Resources != nil && r.Spec.PodSpec.ServiceContainerSpec.Resources != nil {
if !reflect.DeepEqual(r.Spec.Resources, r.Spec.PodSpec.ServiceContainerSpec.Resources) {
return nil, fmt.Errorf("resources mismatch, different resources requirements found in " +
"spec.resources and spec.podSpec.serviceContainer.resources")
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need of else statement if you are returning from if.
You can simply have warn section below if statement

actual := deploy.Spec.Template.ObjectMeta.Annotations
valid := validateLabelsOrAnnotations(actual, annotations)
Expect(valid).To(
BeTrue(), "Unable to find annotations",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
BeTrue(), "Unable to find annotations",
BeTrue(), "Annotations mismatch",

You can also add expected vs found in the error msg if possible

actual = deploy.Spec.Template.ObjectMeta.Labels
valid = validateLabelsOrAnnotations(actual, labels)
Expect(valid).To(
BeTrue(), "Unable to find labels",
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

@@ -281,62 +281,88 @@ var _ = Describe(

})

It("Should validate annotations and labels addition", func() {
It("Should add custom annotations and labels in the backup service deployement pods", func() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
It("Should add custom annotations and labels in the backup service deployement pods", func() {
It("Should add/update custom annotations and labels in the backup service deployement pods", func() {

Comment on lines +295 to +310
deploy, dErr := getBackupServiceDeployment(k8sClient, name, namespace)
Expect(dErr).ToNot(HaveOccurred())

By("Validating Annotations")
actual := deploy.Spec.Template.ObjectMeta.Annotations
valid := validateLabelsOrAnnotations(actual, annotations)
Expect(valid).To(
BeTrue(), "Unable to find annotations",
)

By("Validating Labels")
actual = deploy.Spec.Template.ObjectMeta.Labels
valid = validateLabelsOrAnnotations(actual, labels)
Expect(valid).To(
BeTrue(), "Unable to find labels",
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

See if you can move this in a func (eg. validatePodObjectMeta) for reusing in both create and update flow

Comment on lines 383 to 385
requestMem := resource.MustParse("1Gi")
requestCPU := resource.MustParse("200m")
limitMem := resource.MustParse("2Gi")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Reduce the memory request and cpu.
It might cause issue while running tests on local dev clusters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I will reduce it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants