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

🌱 reconciler/cache/reconciler: simplify and generalize #2609

Merged

Conversation

sttts
Copy link
Member

@sttts sttts commented Jan 12, 2023

Generalized to host more resources more easily and simplified whole flow.
Generalized to host more resources more easily and simplified whole flow.
Generalized to host more resources more easily and simplified whole flow.
Generalized to host more resources more easily and simplified whole flow.
Generalized to host more resources more easily and simplified whole flow.

@openshift-ci openshift-ci bot requested review from davidfestal and ncdc January 12, 2023 12:26
// the replication function handles the following cases:
// 1. creation of the object in the cache server when the cached object is not found by retrieveLocalObject
// 2. deletion of the object from the cache server when the original/local object was removed OR was not found by retrieveLocalObject
// 1. creation of the object in the cache server when the cached object is not found by getLocalCopy
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't it getGlobalCopy?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, we create an obj when it wasn't found in the globalCache

Copy link
Member Author

Choose a reason for hiding this comment

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

done

if err != nil {
return err
// local is gone or being deleted. Delete in cache.
if !localExists || !localCopy.GetDeletionTimestamp().IsZero() {
Copy link
Contributor

Choose a reason for hiding this comment

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

How does it play with finalizers? Doesn't it remove the object from the cache when finalizers may be holding the local copy? Do we want that?

Copy link
Contributor

Choose a reason for hiding this comment

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

we patched the cache server to ignore Finalizers

Copy link
Member Author

Choose a reason for hiding this comment

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

very good question. So we should keep updating it, but filter the deletion timestsamp?

Does the cache-server ignore or follow finalizers?

Copy link
Contributor

Choose a reason for hiding this comment

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

removing an object is enough

Copy link
Member Author

Choose a reason for hiding this comment

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

follow-up

return err

// Object doesn't exist anymore, delete it from the global cache.
logger.V(1).WithValues("cluster", clusterName, "namespace", ns, "name", name).Info("Deleting object from global cache")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: it seems that some other controllers log similar events at V(2)

Copy link
Member Author

Choose a reason for hiding this comment

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

done

logger.V(1).WithValues("cluster", clusterName, "namespace", ns, "name", name).Info("Deleting object from global cache")
if err := r.deleteObject(ctx, clusterName, ns, name); err != nil && !errors.IsNotFound(err) {
runtime.HandleError(err)
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.

no retry?

Copy link
Contributor

@p0lyn0mial p0lyn0mial Jan 12, 2023

Choose a reason for hiding this comment

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

oh, right, we should retry

Copy link
Member Author

Choose a reason for hiding this comment

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

done

// local exists, global doesn't. Create in cache.
if !globalExists {
// TODO: in the future the original RV will have to be stored in an annotation (?)
// so that the clients that need to modify the original/local object can do i
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "can do it"

@sttts sttts force-pushed the sttts-replication-controller-rewrite branch from 19e4bde to af43265 Compare January 12, 2023 13:52
@fgiloux
Copy link
Contributor

fgiloux commented Jan 12, 2023

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 12, 2023
Co-authored-by: Lukasz Szaszkiewicz <lukasz.szaszkiewicz@gmail.com>
Co-authored-by: Stefan Schimanski <sttts@redhat.com>
@sttts sttts force-pushed the sttts-replication-controller-rewrite branch from af43265 to 1a046b6 Compare January 12, 2023 13:58
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jan 12, 2023
@fgiloux
Copy link
Contributor

fgiloux commented Jan 12, 2023

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 12, 2023
@sttts
Copy link
Member Author

sttts commented Jan 12, 2023

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 12, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sttts

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-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 12, 2023
@openshift-merge-robot openshift-merge-robot merged commit 31c76aa into kcp-dev:main Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants