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

Add annotation to pause resource reconciliation #346

Merged
merged 1 commit into from
May 31, 2024

Conversation

osmman
Copy link
Contributor

@osmman osmman commented Apr 26, 2024

Add a new rhtas.redhat.com/pause-reconciliation annotation to pause resource reconciliation. Annotation can be used on any Securesign's custom resource and resources which are owned by them like Deploymen, Service, Ingress

Example custom resource with a paused reconciliation condition

kind: Tuf
metadata:
  annotations:
    rhtas.redhat.com/pause-reconciliation: "true"

@openshift-ci openshift-ci bot requested review from bouskaJ and lkatalin April 26, 2024 11:33
@osmman osmman added the enhancement New feature or request label Apr 26, 2024
Copy link

@openshift-ci openshift-ci bot left a comment

Choose a reason for hiding this comment

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

@osmman: 1 warning.

In response to this:

/lint

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.

controllers/annotations/annotations.go Outdated Show resolved Hide resolved
@osmman osmman force-pushed the pause-annotation branch 2 times, most recently from 5576fe1 to b004eee Compare April 26, 2024 12:46
@osmman
Copy link
Contributor Author

osmman commented Apr 26, 2024

/lint

Copy link

@openshift-ci openshift-ci bot left a comment

Choose a reason for hiding this comment

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

@osmman: 0 warnings.

In response to this:

/lint

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.

@osmman
Copy link
Contributor Author

osmman commented May 10, 2024

target for 1.1.0 release
/hold

For(&rhtasv1alpha1.CTlog{}).
Owns(&v1.Deployment{}).
Owns(&v12.Service{}).
Watches(&v12.Secret{}, handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, object client.Object) []reconcile.Request {
WatchesMetadata(&v12.Secret{}, handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, object client.Object) []reconcile.Request {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Reading https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/builder#Builder.WatchesMetadata I am not sure about this. We never use &metav1.PartialObjectMetadata{} construct. Can you provide more info, why you are changing this?

Copy link
Contributor Author

@osmman osmman May 28, 2024

Choose a reason for hiding this comment

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

It is to reduce amount of data stored in cache memory. We do not need to fetch secret's data and store them in local cache. We only need metadata to make a decision to enqueue new event.

https://github.com/kubernetes-sigs/cluster-api/blob/2568aa2997bc3900deb8b85d27ca1410d6866b09/exp/addons/internal/controllers/clusterresourceset_controller.go#L75-L87

Copy link
Collaborator

Choose a reason for hiding this comment

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

I did not study the concept deeply but from the documentation

You'll need to pass metav1.PartialObjectMetadata to the client when fetching objects in your reconciler, otherwise you'll end up with a duplicate structured or unstructured cache.

I would be careful with it - we don't want to have duplicate structured or unstructured cache but if you are 100% sure what you are doing, we can merge it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer to store small amount of duplicit data of our managed resources rather then pass thought all secrets in cluster through our local cache.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simple reproducer it to run debugger on this line and compare what is stored in o
https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/predicate/predicate.go#L409


const (
// PausedReconciliation Annotation used to pause resource reconciliation
PausedReconciliation = "rhtas.redhat.com/pause-reconciliation"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer to do that in new PR because it is lot of changes which are not connected to this feature.

@osmman
Copy link
Contributor Author

osmman commented May 28, 2024

/unhold

@bouskaJ
Copy link
Collaborator

bouskaJ commented May 28, 2024

/LGTM

@openshift-ci openshift-ci bot added the lgtm label May 31, 2024
Copy link

openshift-ci bot commented May 31, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bouskaJ, osmman

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

@openshift-merge-bot openshift-merge-bot bot merged commit b0e9150 into main May 31, 2024
11 checks passed
@osmman osmman deleted the pause-annotation branch May 31, 2024 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved enhancement New feature or request lgtm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants