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

appliedmanifestwork eviction #190

Merged

Conversation

skeeey
Copy link
Member

@skeeey skeeey commented Mar 2, 2023

No description provided.

@openshift-ci openshift-ci bot requested review from elgnay and qiujian16 March 2, 2023 11:58
@skeeey skeeey force-pushed the amw-eviction branch 2 times, most recently from 70bb703 to ea5e66c Compare March 3, 2023 01:47
@skeeey
Copy link
Member Author

skeeey commented Mar 3, 2023

refer to open-cluster-management-io/ocm#123

@skeeey
Copy link
Member Author

skeeey commented Mar 3, 2023

/assign @qiujian16

@skeeey
Copy link
Member Author

skeeey commented Mar 3, 2023

/hold

if evictionStartTime == nil {
copied := appliedManifestWork.DeepCopy()
copied.Status.EvictionStartTime = &metav1.Time{Time: now}
_, err := m.appliedManifestWorkClient.UpdateStatus(ctx, copied, metav1.UpdateOptions{})
Copy link
Member

Choose a reason for hiding this comment

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

can we patch?

Copy link
Member Author

Choose a reason for hiding this comment

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

using patch here

hubHash string
agentID string
evictionGracePeriod time.Duration
rateLimiter workqueue.RateLimiter
}

func NewUnManagedAppliedWorkController(
Copy link
Member

Choose a reason for hiding this comment

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

let's add some doc for this controller.

Copy link
Member Author

Choose a reason for hiding this comment

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

added

}

return factory.New().
WithInformersQueueKeyFunc(func(obj runtime.Object) string {
Copy link
Member

Choose a reason for hiding this comment

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

if we do not add this eventhandler, how could the controller know when a manifestwork is deleted?

Copy link
Member Author

@skeeey skeeey Mar 3, 2023

Choose a reason for hiding this comment

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

I think this controller will not handle the manifestwork deletion, it just need to know the relating manifestwork can be found from hub or not, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

added, and I also remove the https://github.com/open-cluster-management-io/work/pull/190/files#diff-7d50afd5fa68dd772f0ace48c6b0b06cb79e670b3604840100f9db9a89d6ed59R74, so that we have a uniform way to handle if the manifestwork is missing on the hub

func (m *unmanagedAppliedWorkController) patchEvictionStartTime(ctx context.Context,
appliedManifestWork *workapiv1.AppliedManifestWork, evictionStartTime *metav1.Time) error {
oldData, err := json.Marshal(workapiv1.AppliedManifestWork{
Status: appliedManifestWork.Status,
Copy link
Member

Choose a reason for hiding this comment

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

we should only patch the eviction time, right?

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, we should

@skeeey
Copy link
Member Author

skeeey commented Mar 13, 2023

/unhold

@@ -378,6 +378,22 @@ func AppliedManifestworkHubHashFilter(hubHash string) factory.EventFilterFunc {
}
}

// AppliedManifestWorkEvictionFilter filter the appliedmanifestwork belonging to this hub or this work agent
func AppliedManifestWorkEvictionFilter(hubHash, agentID string) factory.EventFilterFunc {
Copy link
Member

Choose a reason for hiding this comment

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

We need some explanation of this filter, why evictionfilter needs to consider hub hash and agent id. Or we name it as AppliedManifestWorkFilterByHubHashOrAgentID

func(obj runtime.Object) string {
accessor, _ := meta.Accessor(obj)
return accessor.GetName()
}, helper.AppliedManifestWorkEvictionFilter(hubHash, agentID), appliedManifestWorkInformer.Informer()).
Copy link
Member

Choose a reason for hiding this comment

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

why we care about hubhash with different agent? Consider another agent with the same hubHash but different agent id.

Copy link
Member Author

Choose a reason for hiding this comment

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

there is one case the hub is unchanged, but the klusterlet cr is recreated

Copy link
Member Author

@skeeey skeeey Mar 14, 2023

Choose a reason for hiding this comment

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

changed the filter to AppliedManifestworkAgentIDFilter, we only check the a work agent owned appliedmanifestwork

@qiujian16
Copy link
Member

/approve
/hold

Signed-off-by: Wei Liu <liuweixa@redhat.com>
Copy link
Member

@qiujian16 qiujian16 left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

@openshift-ci openshift-ci bot added the lgtm label Mar 14, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 14, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qiujian16, skeeey

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

@qiujian16
Copy link
Member

/unhold

@openshift-merge-robot openshift-merge-robot merged commit ee923cd into open-cluster-management-io:main Mar 14, 2023
7 checks passed
@skeeey skeeey deleted the amw-eviction branch March 15, 2023 05:37
xuezhaojun pushed a commit to xuezhaojun/work that referenced this pull request Mar 21, 2023
Signed-off-by: Wei Liu <liuweixa@redhat.com>
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.

None yet

3 participants