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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Enqueue location upon synctarget update #2624

Merged

Conversation

qiujian16
Copy link
Contributor

We cannot directly read the logicalcluster path from synctarget to get the related placement, since the value of that path is not unique. Instead, we need to get the location of the related synctarget at first, which always has the path annotation.

Signed-off-by: Jian Qiu jqiu@redhat.com

Summary

Related issue(s)

Fixes #2579

@@ -215,7 +215,7 @@ func (c *controller) enqueueLocation(obj interface{}) {
placements = append(placements, placementsByPath...)
}

logger := logging.WithObject(logging.WithReconciler(klog.Background(), ControllerName), location)
logging.WithObject(logger, location)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
logging.WithObject(logger, location)
logger = logging.WithObject(logger, location)

return
}
placements = append(placements, placementsByPath...)
}

logger := logging.WithObject(logging.WithReconciler(klog.Background(), ControllerName), obj.(*workloadv1alpha1.SyncTarget))
Copy link
Member

Choose a reason for hiding this comment

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

Seems to me that the SyncTarget value added here to the logger, will be, at least in some logger implementation, overwritten by the same operation applied in enqueueLocation()

for _, placement := range placements {
c.enqueuePlacement(placement, logger, " because of SyncTarget")
for _, location := range locations {
c.enqueueLocation(location, logger, " because of SyncTarget")
Copy link
Member

Choose a reason for hiding this comment

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

Instead of managing the source (==reason) of the enqueue by a suffix, can't we simply add distinct values ?
Something like: logger.WithValues(logging.FromPrefix("locationReason")) and logger.WithValues(logging.FromPrefix("syncTargetReason")) ?

So you can accumulate the reason objects if needed, and would have always a fixed log message.

We cannot directly read the logicalcluster path from synctarget
to get the related placement, since the value of that path is not
unique. Instead, we need to get the location of the related synctarget
at first, which always has the path annotation.

Signed-off-by: Jian Qiu <jqiu@redhat.com>
if err != nil {
runtime.HandleError(err)
return
func (c *controller) enqueueSyncTarget(obj interface{}, logger logr.Logger) {
Copy link
Member

Choose a reason for hiding this comment

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

this is very noisy. We should rethink whether we really need to enqueue half of the world.

  1. What is the exact reason we have to enqueue a sync target?
  2. What can we do to get the placements more directly?

Copy link
Member

Choose a reason for hiding this comment

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

Goal: only sync the placement that actually schedules to that SyncTarget.

Copy link
Contributor Author

@qiujian16 qiujian16 Jan 18, 2023

Choose a reason for hiding this comment

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

ideally we should only enqueue location and scheduled synctarget here. The missing part is we do not know what APIs are compatible in the location. So if a synctarget is updated with "api compaible/non-comptaible", we have to re-select the clusters.

Copy link
Member

Choose a reason for hiding this comment

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

So if a synctarget is updated with "api compaible/non-comptaible"

For that we could have a special case, couldn't we?

Copy link
Member

Choose a reason for hiding this comment

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

Also, can we queue only those locations that are affected, e.g. that include the SyncTarget? If you remove a label from a SyncTarget, we could also see that and queue those locations where this SyncTarget was removed from.

Copy link
Member

Choose a reason for hiding this comment

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

ideally we should only enqueue location and scheduled synctarget here. The missing part is we do not know what APIs are compatible in the location. So if a synctarget is updated with "api compaible/non-comptaible", we have to re-select the clusters.

Actually, I now think the fix is not correct: the old code did not look at the SyncTarget, but on the LogicalCluster. The LogicalCluster always has a path annotation. What is missing is that we don't label the logical cluster for replication. Compare pkg/reconciler/tenancy/replicatelogicalcluster.

Copy link
Member

Choose a reason for hiding this comment

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

Nvmd:

On the other hand, the new change does not really cause more noise, but it will list all locations and from there get all placements that reference these locations. So there is hope that these are not all placements, vs. the old code that queued all placements.

@davidfestal davidfestal added the area/transparent-multi-cluster Related to scheduling of workloads into pclusters. label Jan 30, 2023
@davidfestal davidfestal self-assigned this Jan 30, 2023
@davidfestal davidfestal added this to the v0.11 milestone Feb 9, 2023
@sttts
Copy link
Member

sttts commented Feb 9, 2023

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 9, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 9, 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 Feb 9, 2023
@openshift-merge-robot openshift-merge-robot merged commit 880576a into kcp-dev:main Feb 9, 2023
@qiujian16 qiujian16 deleted the fix-synctarget-enqueue branch February 9, 2023 23:33
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. area/transparent-multi-cluster Related to scheduling of workloads into pclusters. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Placement is not updated when the SyncTarget Heartbeat condition changes
4 participants