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

fix watch resources in each controller #1263

Merged
merged 1 commit into from
Dec 10, 2024
Merged

Conversation

ldpliu
Copy link
Contributor

@ldpliu ldpliu commented Dec 4, 2024

Summary

We did not watch globalhub applied resources previously, if user changed these resources, we should rollback them.

Related issue(s)

Fixes #

Tests

  • Unit/function tests have been added and incorporated into make unit-tests.
  • Integration tests have been added and incorporated into make integration-test.
  • E2E tests have been added and incorporated into make e2e-test-all.
  • List other manual tests you have done.
    • manually removed the manager role/rolebinding, they will be recreated.

@ldpliu ldpliu force-pushed the fix-watch branch 7 times, most recently from 5a7d871 to d3c913a Compare December 5, 2024 06:19
@ldpliu
Copy link
Contributor Author

ldpliu commented Dec 5, 2024

/test test-integration

@ldpliu
Copy link
Contributor Author

ldpliu commented Dec 5, 2024

/cc @clyang82 @yanmxa

@openshift-ci openshift-ci bot requested review from clyang82 and yanmxa December 5, 2024 09:18
if backupController != nil {
return backupController, nil
}
log.Infof("start backup controller")

Copy link
Contributor

Choose a reason for hiding this comment

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

move it after IsACMResourceReady

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

if grafanaController != nil {
return grafanaController, nil
}
log.Info("start grafana controller")
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

if !config.WithInventory(initOption.MulticlusterGlobalHub) {
return nil, nil
}
log.Info("start inventory controller")

Copy link
Contributor

Choose a reason for hiding this comment

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

move it after GetStorageConnection

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -156,7 +158,17 @@ func (r *GrafanaReconciler) SetupWithManager(mgr ctrl.Manager) error {
Watches(&corev1.ConfigMap{},
&handler.EnqueueRequestForObject{}, builder.WithPredicates(configmapPred)).
Watches(&appsv1.Deployment{},
&handler.EnqueueRequestForObject{}, builder.WithPredicates(deplomentPred))
&handler.EnqueueRequestForObject{}, builder.WithPredicates(deploymentPred)).
Watches(&corev1.Service{},
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to add more permissions for this controller

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

if managedHubController != nil {
return managedHubController, nil
}
log.Info("start managedhub controller")

Copy link
Contributor

Choose a reason for hiding this comment

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

move it after IsACMResourceReady

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

&handler.EnqueueRequestForObject{}, builder.WithPredicates(config.GeneralPredicate)).
Watches(&rbacv1.Role{},
&handler.EnqueueRequestForObject{}, builder.WithPredicates(config.GeneralPredicate)).
Watches(&rbacv1.RoleBinding{},
Copy link
Contributor

Choose a reason for hiding this comment

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

add more permissions for this controller

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


if r.enableMetrics {
mgrBuilder = mgrBuilder.
Watches(&promv1.PrometheusRule{},
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it work when switch enableMetrics from false to true?

Copy link
Contributor Author

@ldpliu ldpliu Dec 9, 2024

Choose a reason for hiding this comment

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

changed to watch the resources when crd exist

@@ -148,7 +148,7 @@ var kafkaPred = predicate.Funcs{
}

func StartKafkaController(ctx context.Context, mgr ctrl.Manager, transporter transport.Transporter) error {
log.Info("start kafka controller")
log.Debug("start kafka controller")
if startedKafkaController {
return nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Move it after startedKafkaController. Use Info for consistence?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

if webhookReconciler != nil {
return webhookReconciler, nil
}
log.Info("start webhook controller")
Copy link
Contributor

Choose a reason for hiding this comment

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

move it after IsACMResourceReady

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@ldpliu
Copy link
Contributor Author

ldpliu commented Dec 9, 2024

/retest

Copy link
Contributor

@clyang82 clyang82 left a comment

Choose a reason for hiding this comment

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

LGTM

@openshift-ci openshift-ci bot added the lgtm label Dec 10, 2024
Copy link

openshift-ci bot commented Dec 10, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: clyang82, ldpliu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@clyang82 clyang82 merged commit fbf7e3a into stolostron:main Dec 10, 2024
13 of 14 checks passed
Copy link

openshift-ci bot commented Dec 10, 2024

@ldpliu: 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
ci/prow/test-integration e9162d4 link unknown /test test-integration

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-sigs/prow repository. I understand the commands that are listed here.

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

Successfully merging this pull request may close these issues.

2 participants