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

Watching for Kyma Custom Resource #7

Merged
merged 32 commits into from
Jun 21, 2023

Conversation

mvshao
Copy link
Contributor

@mvshao mvshao commented May 10, 2023

Description

Changes proposed in this pull request:

  • implemented first version of compass-manager
  • implemented logic for watching Kyma CR
  • implemented event filter

Related issue(s)
kyma-project/kyma#9

@mvshao mvshao added the area/application-connector Issues or PRs related to application connectivity label May 10, 2023
@kyma-bot kyma-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 10, 2023
@kyma-bot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@kyma-bot kyma-bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label May 10, 2023
@mvshao mvshao changed the title [WIP] Watching for Kyma Custom Resource [WIP] Watching for Kyma Custom Resource - flow with For() method May 10, 2023
@mvshao mvshao changed the title [WIP] Watching for Kyma Custom Resource - flow with For() method [WIP] Watching for Kyma Custom Resource May 10, 2023
@VOID404
Copy link
Contributor

VOID404 commented May 11, 2023

/test all

@mvshao
Copy link
Contributor Author

mvshao commented May 15, 2023

/test all

@mvshao
Copy link
Contributor Author

mvshao commented May 19, 2023

/test all

@mvshao
Copy link
Contributor Author

mvshao commented May 19, 2023

/test all

@mvshao mvshao changed the title [WIP] Watching for Kyma Custom Resource Watching for Kyma Custom Resource May 22, 2023
@mvshao mvshao marked this pull request as ready for review May 22, 2023 07:13
@mvshao mvshao requested a review from a team as a code owner May 22, 2023 07:13
@kyma-bot kyma-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 22, 2023

cm.Log.Infof("reconciliation triggered for resource named: %s", req.Name)
kymaName := req.Name
kubeconfigSecretName := "kubeconfig-" + req.Name
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it isa good idea to build the secret name. The more bulletproof solution would be to find the secret based on a label.

@@ -0,0 +1,48 @@
package v1beta1
Copy link
Contributor

Choose a reason for hiding this comment

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

Compass Manager doesn't need to define its own CRD.

@@ -0,0 +1,50 @@
---
Copy link
Contributor

Choose a reason for hiding this comment

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

Not needed, as Compass Manager doesn't need have its own CRD.

@@ -0,0 +1,20 @@
// Package v1beta1 contains API Schema definitions for the operator v1beta1 API group
Copy link
Contributor

Choose a reason for hiding this comment

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

Not needed, as Compass Manager doesn't need have its own CRD.

@@ -0,0 +1,16 @@
# The following patch enables a conversion webhook for the CRD
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it needed? I think not, as Compass Manager doesn't need have its own CRD.

@@ -0,0 +1,31 @@
# permissions for end users to edit compassmanagers.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is not needed

UpdateFunc: func(e event.UpdateEvent) bool {
return cm.checkUpdateCompassLabel(e.ObjectNew, e.ObjectOld)
},
GenericFunc: func(e event.GenericEvent) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we need to provide GenericFunc.

LabelSelector: labelSelector,
})
if err != nil {
cm.Log.Infof("%v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Logging errors with Info level is misleading.

instance := &kyma.Kyma{}
err := cm.Client.Get(context.Background(), objKey, instance)
if err != nil {
if errors.IsNotFound(err) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to distinguish error type here.

func (cm *CompassManagerReconciler) SetupWithManager(mgr ctrl.Manager) error {
fieldSelectorPredicate := predicate.Funcs{
CreateFunc: func(e event.CreateEvent) bool {
return cm.checkCompassLabel(e.Object)
Copy link
Contributor

Choose a reason for hiding this comment

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

checkCompassLabel is not descriptive enough.


err = cm.Client.Update(context.Background(), instance)
if err != nil {
log.Infof("%v, %s", err, " failed to update Kyma Custom Resource")
Copy link
Contributor

Choose a reason for hiding this comment

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

Logging errors with Info level is misleading.

@mvshao
Copy link
Contributor Author

mvshao commented Jun 6, 2023

@akgalwas Thank you for your review and suggestions! 😄

@mvshao
Copy link
Contributor Author

mvshao commented Jun 12, 2023

/check-cla

controllers/compassmanager_controller_test.go Outdated Show resolved Hide resolved
controllers/compassmanager_controller_test.go Outdated Show resolved Hide resolved
controllers/compassmanager_controller_test.go Outdated Show resolved Hide resolved
h.shouldCreateKyma(testSuiteKyma.Name, testSuiteKyma)

// then
h.shouldCheckCompassLabel(testSuiteKyma.Name, testSuiteKyma.Namespace, true)
Copy link
Contributor

Choose a reason for hiding this comment

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

This assertion is not correct. We should wait for some time, and periodically ensure the predicate (label not set) is met. This is not how this code works. As it uses Eventually the predicate is true the first time it is checked before timeout is passed. I would suggest Consistently directive instead on Eventually.

controllers/compassmanager_controller_test.go Outdated Show resolved Hide resolved
controllers/compassmanager_controller_test.go Outdated Show resolved Hide resolved
controllers/compassmanager_controller_test.go Outdated Show resolved Hide resolved
controllers/compassmanager_controller_test.go Outdated Show resolved Hide resolved
controllers/compassmanager_controller_test.go Outdated Show resolved Hide resolved
controllers/compassmanager_controller_test.go Outdated Show resolved Hide resolved
@kyma-bot
Copy link
Contributor

@mvshao: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-compass-manager-lint 623034c link false /test pull-compass-manager-lint

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@kyma-bot kyma-bot added the lgtm Looks good to me! label Jun 21, 2023
@kyma-bot kyma-bot merged commit ee54e54 into kyma-project:main Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/application-connector Issues or PRs related to application connectivity lgtm Looks good to me! size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants